#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; i < dim; ++i) {
    printf("indirizzo: %p, contenuto: %1c\t%4d,  i: %2d\n", p, *p, *p, i);
    if (*++p == '\0')
      break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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)
cmpl   $0x32,-0xc(%rbp)
jge    11cf <main+0xaf>
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0xc(%rbp),%r8d
lea    0xe8a(%rip),%rdi
movsbl %cl,%edx
movsbl %al,%ecx
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    11bc <main+0x9c>
jmp    11cf <main+0xaf>
jmp    11c1 <main+0xa1>
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    $0x60,%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>
xor    %ebx,%ebx
mov    (%rsp),%al
lea    0xed8(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
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
jne    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 = %28, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 50
br i1 %12, label %13, label %31
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8 signext %16, i8 signext %18, i32 %19)
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %13
br label %31
27: ; preds = %13
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %10
31: ; preds = %26, %10
%32 = load i8*, i8** %4
%33 = load i32, i32* %1
ret i32 %33
}

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
br label %5
5: ; preds = %5, %0
%6 = phi i8 [ %4, %0 ], [ %11, %5 ]
%7 = phi i8* [ %2, %0 ], [ %10, %5 ]
%8 = phi i32 [ 0, %0 ], [ %13, %5 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8 signext %6, i8 signext %6, i32 %8)
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
%13 = add nuw nsw i32 %8, 1
%14 = icmp eq i32 %13, 50
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %5
16: ; preds = %5
ret i32 0
}