#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 *, size_t, ...);
int strncmp(char *, char *, int);
int main(void) {
  size_t i = 0;
  char str[6] = "tortug";
  printf("compare = %d\n", strncmp(str, "tortuga", 6));
  for (i = 0; i < 6; i++) {
    printf("char at %zu == %c\n", i, str[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0xec3(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xebd(%rip),%ax
mov    %ax,-0x12(%rbp)
lea    -0x16(%rbp),%rdi
lea    0xebe(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
movslq %eax,%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x6,-0x10(%rbp)
jae    11b0 <main+0x90>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
movsbl -0x16(%rbp,%rax,1),%edx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1179 <main+0x59>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movw   $0x6775,0xc(%rsp)
movl   $0x74726f74,0x8(%rsp)
74
lea    0xed9(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
movslq %eax,%rsi
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x8(%rsp),%edx
lea    0xeb5(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x9(%rsp),%edx
mov    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xa(%rsp),%edx
mov    $0x2,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xb(%rsp),%edx
mov    $0x3,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xc(%rsp),%edx
mov    $0x4,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xd(%rsp),%edx
mov    $0x5,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str = [6 x i8] c"tortug"
@.str = [14 x i8] c"compare = %d\0A\00"
@.str.1 = [8 x i8] c"tortuga\00"
@.str.2 = [19 x i8] c"char at %zu == %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [6 x i8]
store i32 0, i32* %1
store i64 0, i64* %2
%4 = bitcast [6 x i8]* %3 to i8*
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%6 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 6)
%7 = sext i32 %6 to i64
%8 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %7)
store i64 0, i64* %2
br label %9
9: ; preds = %19, %0
%10 = load i64, i64* %2
%11 = icmp ult i64 %10, 6
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i64, i64* %2
%14 = load i64, i64* %2
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %13, i32 %17)
br label %19
19: ; preds = %12
%20 = load i64, i64* %2
%21 = add i64 %20, 1
store i64 %21, i64* %2
br label %9
22: ; preds = %9
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@__const.main.str = [6 x i8] c"tortug"
@.str = [14 x i8] c"compare = %d\0A\00"
@.str.1 = [8 x i8] c"tortuga\00"
@.str.2 = [19 x i8] c"char at %zu == %c\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 6)
%4 = sext i32 %3 to i64
%5 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %4)
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 0, i32 %7)
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 1, i32 %11)
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 2, i32 %15)
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 3, i32 %19)
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 4, i32 %23)
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 5, i32 %27)
ret i32 0
}