#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char, char, int);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  const int dim = 50;
  int i = 0;
  char nome[dim];
  char *p;
  p = &nome[0];
  p = nome;
  strcpy(nome, "trovi un gatto nero morto");
  for (i = 0; *p != '\0' && i < dim; ++i) {
    printf("indirizzo: %p, contenuto: %1c\t%4d,  i: %2d\n", p, *p, *p, i);
    ++p;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xea5(%rip),%rsi
lea    -0x60(%rbp),%rdi
call   1030 <strcpy@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x61(%rbp)
je     118a <main+0x6a>
cmpl   $0x32,-0xc(%rbp)
setl   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    119a <main+0x7a>
jmp    11da <main+0xba>
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0xc(%rbp),%r8d
lea    0xe65(%rip),%rdi
movsbl %cl,%edx
movsbl %al,%ecx
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <main+0x4b>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xed2(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    (%rsp),%al
test   %al,%al
je     117c <main+0x5c>
xor    %ebx,%ebx
lea    0xed4(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rsi
movsbl %al,%ecx
mov    %r14,%rdi
mov    %ecx,%edx
mov    %ebx,%r8d
call   1040 <printf@plt>
movzbl 0x1(%rsp,%rbx,1),%eax
test   %al,%al
je     117c <main+0x5c>
mov    %rbx,%rcx
add    $0x1,%rcx
cmp    $0x31,%ebx
mov    %rcx,%rbx
jb     1150 <main+0x30>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"trovi un gatto nero morto\00"
@.str.1 = [44 x i8] c"indirizzo: %p, contenuto: %1c\09%4d, i: %2d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
store i32 50, i32* %2
store i32 0, i32* %3
%6 = call i8* @llvm.stacksave()
store i8* %6, i8** %4
%7 = alloca i8, i64 50
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8* %8, i8** %5
store i8* %7, i8** %5
%9 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %10
10: ; preds = %30, %0
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 50
br label %18
18: ; preds = %15, %10
%19 = phi i1 [ false, %10 ], [ %17, %15 ]
br i1 %19, label %20, label %33
20: ; preds = %18
%21 = load i8*, i8** %5
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = load i32, i32* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8 signext %23, i8 signext %25, i32 %26)
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
br label %30
30: ; preds = %20
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %10
33: ; preds = %18
%34 = load i8*, i8** %4
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [26 x i8] c"trovi un gatto nero morto\00"
@.str.1 = [44 x i8] c"indirizzo: %p, contenuto: %1c\09%4d, i: %2d\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %0, %6
%7 = phi i8 [ %13, %6 ], [ %4, %0 ]
%8 = phi i8* [ %11, %6 ], [ %2, %0 ]
%9 = phi i32 [ %12, %6 ], [ 0, %0 ]
%10 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8 signext %7, i8 signext %7, i32 %9)
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = add nuw nsw i32 %9, 1
%13 = load i8, i8* %11
%14 = icmp ne i8 %13, 0
%15 = icmp ult i32 %9, 49
%16 = and i1 %14, %15
br i1 %16, label %6, label %17
17: ; preds = %6, %0
ret i32 0
}