#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 *);
char *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";
  char *ret = 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    $0x50,%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>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xd,-0x8(%rbp)
jge    11da <main+0xaa>
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ab <main+0x7b>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movb   $0x0,-0x13(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe42(%rip),%rdi
call   1030 <mystrcmp@plt>
cmp    $0x0,%rax
jne    1219 <main+0xe9>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1227 <main+0xf7>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%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]
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [22 x i8]* %3 to i8*
%7 = bitcast [22 x i8]* %4 to i8*
%8 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%10 = call i8* @mystrcpy(i8* %8, i8* %9)
store i8* %10, i8** %5
store i32 0, i32* %2
br label %11
11: ; preds = %21, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 13
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %11
24: ; preds = %11
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 13
store i8 0, i8* %26
%27 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%28 = call i64 @mystrcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %34
32: ; preds = %24
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
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 i8* @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
}