#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 *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int strncmp(char *, char *, int);
int main() {
  size_t intSize = sizeof(int);
  char *name = "Adam";
  printf("%u\n", strlen(name));
  char *name2 = "Bob";
  printf("%i\n", strcmp(name, name2));
  printf("%i\n", strcmp(name, "Adum"));
  printf("%i\n", strcmp(name, name));
  if (strcmp(name, name) == 0)
    printf("The strings are the same.\n");
  printf("%i\n", strncmp(name, name2, 3));
  printf("%i\n", strncmp(name, "Adum", 2));
  printf("%i\n", strncmp(name, "Adamantum", 4));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x4,-0x10(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe87(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1208 <main+0xc8>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %eax,%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xddc(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %eax,%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xdd7(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %eax,%esi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe9b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
lea    0xe84(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11e6 <main+0x96>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe13(%rip),%r14
lea    0xe15(%rip),%rsi
mov    %r14,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
lea    0xe05(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdf6(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xddb(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"Adam\00"
@.str.1 = [4 x i8] c"%u\0A\00"
@.str.2 = [4 x i8] c"Bob\00"
@.str.3 = [4 x i8] c"%i\0A\00"
@.str.4 = [5 x i8] c"Adum\00"
@.str.5 = [27 x i8] c"The strings are the same.\0A\00"
@.str.6 = [10 x i8] c"Adamantum\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i64 4, i64* %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %6)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i64 @strcmp(i8* %8, i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %10)
%12 = load i8*, i8** %3
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %13)
%15 = load i8*, i8** %3
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %17)
%19 = load i8*, i8** %3
%20 = load i8*, i8** %3
%21 = call i64 @strcmp(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %23, %0
%26 = load i8*, i8** %3
%27 = load i8*, i8** %4
%28 = call i32 @strncmp(i8* %26, i8* %27, i32 3)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = load i8*, i8** %3
%31 = call i32 @strncmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 2)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = load i8*, i8** %3
%34 = call i32 @strncmp(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 4)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"Adam\00"
@.str.1 = [4 x i8] c"%u\0A\00"
@.str.2 = [4 x i8] c"Bob\00"
@.str.3 = [4 x i8] c"%i\0A\00"
@.str.4 = [5 x i8] c"Adum\00"
@.str.6 = [10 x i8] c"Adamantum\00"
@str = [26 x i8] c"The strings are the same.\00"
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%3 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %3)
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %5)
%7 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %7)
%9 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 2)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = tail call i32 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 4)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %18)
ret i32 0
}