#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 */
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *strCat(char *, char *);
int strComp(char *, char *);
int /*<<< orphan*/ strCopy(char *, char *);
int strLen(char *);
int main() {
  char string1[] = "hello";
  char string2[] = " world";
  int match = strComp(string1, string2);
  printf("Match: %d\n", match);
  int length1 = strLen(string1);
  int length2 = strLen(string2);
  printf("Length 1: %d\n", length1);
  printf("Length 2: %d\n", length2);
  char *catStr = strCat(string1, string2);
  printf("Concatenated: %s\n", catStr);
  char *copiedStr = malloc(strLen(catStr));
  strCopy(copiedStr, catStr);
  printf("Copied: %s\n", copiedStr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xe92(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xe8c(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xe84(%rip),%eax
mov    %eax,-0xd(%rbp)
mov    0xe7e(%rip),%ax
mov    %ax,-0x9(%rbp)
mov    0xe76(%rip),%al
mov    %al,-0x7(%rbp)
lea    -0x6(%rbp),%rdi
lea    -0xd(%rbp),%rsi
call   1060 <strComp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
call   1040 <strLen@plt>
mov    %eax,-0x18(%rbp)
lea    -0xd(%rbp),%rdi
call   1040 <strLen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
lea    -0xd(%rbp),%rsi
call   1080 <strCat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <strLen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strCopy@plt>
mov    -0x30(%rbp),%rsi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movw   $0x6f,0xc(%rsp)
movl   $0x6c6c6568,0x8(%rsp)
6c
movl   $0x646c72,0x13(%rsp)
movl   $0x726f7720,0x10(%rsp)
72
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <strComp@plt>
lea    0xe68(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
call   1040 <strLen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strLen@plt>
mov    %eax,%ebx
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <strCat@plt>
mov    %rax,%rbx
lea    0xe3d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <strLen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1070 <strCopy@plt>
lea    0xe21(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.string1 = [6 x i8] c"hello\00"
@__const.main.string2 = [7 x i8] c" world\00"
@.str = [11 x i8] c"Match: %d\0A\00"
@.str.1 = [14 x i8] c"Length 1: %d\0A\00"
@.str.2 = [14 x i8] c"Length 2: %d\0A\00"
@.str.3 = [18 x i8] c"Concatenated: %s\0A\00"
@.str.4 = [12 x i8] c"Copied: %s\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [7 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = bitcast [6 x i8]* %1 to i8*
%9 = bitcast [7 x i8]* %2 to i8*
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%12 = call i32 @strComp(i8* %10, i8* %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%16 = call i32 @strLen(i8* %15)
store i32 %16, i32* %4
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%18 = call i32 @strLen(i8* %17)
store i32 %18, i32* %5
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%25 = call i8* @strCat(i8* %23, i8* %24)
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @strLen(i8* %28)
%30 = call i8* @malloc(i32 %29)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = load i8*, i8** %6
%33 = call i32 @strCopy(i8* %31, i8* %32)
%34 = load i8*, i8** %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %34)
ret i32 0
}

LLVM IR (-O2):
@__const.main.string1 = [6 x i8] c"hello\00"
@__const.main.string2 = [7 x i8] c" world\00"
@.str = [11 x i8] c"Match: %d\0A\00"
@.str.1 = [14 x i8] c"Length 1: %d\0A\00"
@.str.2 = [14 x i8] c"Length 2: %d\0A\00"
@.str.3 = [18 x i8] c"Concatenated: %s\0A\00"
@.str.4 = [12 x i8] c"Copied: %s\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%5 = call i32 @strComp(i8* %3, i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @strLen(i8* %3)
%8 = call i32 @strLen(i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%11 = call i8* @strCat(i8* %3, i8* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = call i32 @strLen(i8* %11)
%14 = call i8* @malloc(i32 %13)
%15 = call i32 @strCopy(i8* %14, i8* %11)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %14)
ret i32 0
}