#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 */
scalar_t__ mystrcmp(char *, char *);
int /*<<< orphan*/ mystrcpy(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i;
  char buf[] = "i am really cool too\n";
  char str[] = "i am so cool........\n";
  mystrcpy(buf, str);
  for (i = 0; i < 13; i++)
    printf("%c", buf[i]);
  printf("\n");
  buf[13] = '\0';
  if (mystrcmp("i am so cool.", buf) == 0) {
    printf("The strings match\n");
  } else {
    printf("The strings do not match\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeaf(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    0xea5(%rip),%ax
mov    %ax,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <mystrcpy@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xd,-0x8(%rbp)
jge    11d6 <main+0xa6>
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a7 <main+0x77>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movb   $0x0,-0x13(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1030 <mystrcmp@plt>
cmp    $0x0,%rax
jne    1215 <main+0xe5>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1223 <main+0xf3>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0xa6f6f74206c6f,%rax
mov    %rax,0xe(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0xa2e2e2e2e2e2e,%rax
mov    %rax,0x2e(%rsp)
mov    %rsp,%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <mystrcpy@plt>
movsbl (%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x1(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x2(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x3(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x4(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x5(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x6(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x7(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x8(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0x9(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0xa(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0xb(%rsp),%edi
call   1040 <putchar@plt>
movsbl 0xc(%rsp),%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movb   $0x0,0xd(%rsp)
lea    0xe15(%rip),%rdi
mov    %rbx,%rsi
call   1030 <mystrcmp@plt>
test   %rax,%rax
lea    0xe2a(%rip),%rax
lea    0xe0a(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.buf = [22 x i8] c"i am really cool too\0A\00"
@__const.main.str = [22 x i8] c"i am so cool........\0A\00"
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [14 x i8] c"i am so cool.\00"
@.str.3 = [19 x i8] c"The strings match\0A\00"
@.str.4 = [26 x i8] c"The strings do not match\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [22 x i8]
%4 = alloca [22 x i8]
store i32 0, i32* %1
%5 = bitcast [22 x i8]* %3 to i8*
%6 = bitcast [22 x i8]* %4 to i8*
%7 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%9 = call i32 @mystrcpy(i8* %7, i8* %8)
store i32 0, i32* %2
br label %10
10: ; preds = %20, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 13
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %10
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 13
store i8 0, i8* %25
%26 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%27 = call i64 @mystrcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %33
31: ; preds = %23
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf = [22 x i8] c"i am really cool too\0A\00"
@__const.main.str = [22 x i8] c"i am so cool........\0A\00"
@.str.2 = [14 x i8] c"i am so cool.\00"
@str = [25 x i8] c"The strings do not match\00"
@str.5 = [18 x i8] c"The strings match\00"
define i32 @main() {
%1 = alloca [22 x i8]
%2 = alloca [22 x i8]
%3 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%5 = call i32 @mystrcpy(i8* %3, i8* %4)
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
%8 = call i32 @putchar(i32 %7)
%9 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i32 @putchar(i32 %11)
%13 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 @putchar(i32 %15)
%17 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 @putchar(i32 %19)
%21 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 @putchar(i32 %23)
%25 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 @putchar(i32 %27)
%29 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 @putchar(i32 %31)
%33 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 7
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 @putchar(i32 %35)
%37 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 8
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 @putchar(i32 %39)
%41 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 9
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 @putchar(i32 %43)
%45 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 10
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 @putchar(i32 %47)
%49 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 11
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 @putchar(i32 %51)
%53 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 12
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = call i32 @putchar(i32 %55)
%57 = call i32 @putchar(i32 10)
%58 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 13
store i8 0, i8* %58
%59 = call i64 @mystrcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%60 = icmp eq i64 %59, 0
%61 = select i1 %60, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0)
%62 = call i32 @puts(i8* dereferenceable(1) %61)
ret i32 0
}