#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 *, ...);
int /*<<< orphan*/ strncpy(char *, char *, int const);
int main() {
  const int dim = 50;
  int i = 0;
  char nome[dim];
  char *p;
  p = &nome[0];
  p = nome;
  strncpy(nome,
          "tlovi un gatto nelo molto crocifisso sul mulo accanto a uno "
          "scendiletto postulale di un negozio di massaggi cinese",
          dim);
  nome[dim - 1] = '\0';
  printf("%s\n", nome);
  while (*p != '\0' && i < dim) {
    printf("indirizzo: %p, contenuto: %1c\t%4d,  i: %2d\n", p, *p, *p, i);
    ++p;
    ++i;
  }
}


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    -0x60(%rbp),%rdi
lea    0xea1(%rip),%rsi
mov    $0x32,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x2f(%rbp)
lea    0xeff(%rip),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x61(%rbp)
je     119e <main+0x7e>
cmpl   $0x32,-0xc(%rbp)
setl   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    11ae <main+0x8e>
jmp    11ec <main+0xcc>
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rax
movsbl (%rax),%edx
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    -0xc(%rbp),%r8d
lea    0xeac(%rip),%rdi
mov    $0x0,%al
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    117f <main+0x5f>
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,%rbx
mov    %rbx,%rdi
mov    $0x32,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x31(%rsp)
lea    0xf29(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     119e <main+0x7e>
lea    0xf15(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rsp,%rbx,1),%rsi
movsbl %al,%ecx
mov    %r14,%rdi
mov    %ecx,%edx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x1(%rsp,%rbx,1),%eax
test   %al,%al
je     119e <main+0x7e>
mov    %rbx,%rcx
add    $0x1,%rcx
cmp    $0x31,%ebx
mov    %rcx,%rbx
jb     1170 <main+0x50>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [115 x i8] c"tlovi un gatto nelo molto crocifisso sul mulo accanto a uno scendiletto postulale di un negozio di massaggi cinese\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [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 @strncpy(i8* %7, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0), i32 50)
%10 = getelementptr inbounds i8, i8* %7, i64 49
store i8 0, i8* %10
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %12
12: ; preds = %22, %0
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 50
br label %20
20: ; preds = %17, %12
%21 = phi i1 [ false, %12 ], [ %19, %17 ]
br i1 %21, label %22, label %36
22: ; preds = %20
%23 = load i8*, i8** %5
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = load i32, i32* %3
%31 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 %26, i32 %29, i32 %30)
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %12
36: ; preds = %20
%37 = load i8*, i8** %4
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [115 x i8] c"tlovi un gatto nelo molto crocifisso sul mulo accanto a uno scendiletto postulale di un negozio di massaggi cinese\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [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 @strncpy(i8* %2, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0), i32 50)
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 49
store i8 0, i8* %4
%5 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %0, %8
%9 = phi i8 [ %16, %8 ], [ %6, %0 ]
%10 = phi i8* [ %14, %8 ], [ %2, %0 ]
%11 = phi i32 [ %15, %8 ], [ 0, %0 ]
%12 = sext i8 %9 to i32
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 %12, i32 %12, i32 %11)
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = add nuw nsw i32 %11, 1
%16 = load i8, i8* %14
%17 = icmp ne i8 %16, 0
%18 = icmp ult i32 %11, 49
%19 = and i1 %17, %18
br i1 %19, label %8, label %20
20: ; preds = %8, %0
ret i32 0
}