#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 *, ...);
int string_compare(char *, char *);
int string_concat(char *, char *, int);
int /*<<< orphan*/ string_join(char **, int, char *, char *, int);
int string_len(char *);
int /*<<< orphan*/ string_reverse(char *);
int string_substring(char *, char *);
int main(void) {
  char testStr1[] = "Hello World!";
  char testStr2[50] = {'I', ' ', 'a', 'm', ' ', 'a', ' ', 'c',
                       'o', 'm', 'p', 'u', 't', 'e', 'r', '\0'};
  char testStr3[] = "I do multiple things better than you.";
  char testStr4[] = "This string is reversed";
  char testStr5[] = "orl";
  char separator[] = " . ";
  char joinResult[100];
  char *arr[3];
  int len1, len2, len3, copiedChars, comparison, substring;
  len1 = string_len(testStr1);
  len2 = string_len(testStr2);
  len3 = string_len(testStr3);
  printf("Length of the strings:\n [1]. %d\n [2]. %d\n [3]. %d\n\n", len1, len2,
         len3);
  printf("String to reverse: %s", testStr4);
  string_reverse(testStr4);
  printf("\nString after reversal: %s\n\n", testStr4);
  copiedChars = string_concat(testStr2, testStr1, 50);
  printf("The cat'd string from testStr2 and testStr1 is: %s\nCharacters "
         "copied: %d\n\n",
         testStr2, copiedChars);
  comparison = string_compare(testStr1, testStr1);
  printf("Comparison variable: %d\n\n", comparison);
  substring = string_substring(testStr1, testStr5);
  printf("Substring variable: %d\n\n", substring);
  arr[0] = testStr1;
  arr[1] = testStr2;
  arr[2] = testStr3;
  string_join(arr, 3, separator, joinResult, 100);
  printf("Joined string result:\n%s\n\n", joinResult);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe67(%rip),%rax
mov    %rax,-0x11(%rbp)
mov    0xe65(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xe60(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xf66(%rip),%rsi
mov    $0x32,%edx
call   1060 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xf91(%rip),%rsi
mov    $0x26,%edx
call   1060 <memcpy@plt>
mov    0xfb0(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xfaa(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xfa4(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xe04(%rip),%eax
mov    %eax,-0xa4(%rbp)
mov    0xdfc(%rip),%eax
mov    %eax,-0xa8(%rbp)
lea    -0x11(%rbp),%rdi
call   1090 <string_len@plt>
mov    %eax,-0x134(%rbp)
lea    -0x50(%rbp),%rdi
call   1090 <string_len@plt>
mov    %eax,-0x138(%rbp)
lea    -0x80(%rbp),%rdi
call   1090 <string_len@plt>
mov    %eax,-0x13c(%rbp)
mov    -0x134(%rbp),%esi
mov    -0x138(%rbp),%edx
mov    -0x13c(%rbp),%ecx
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rsi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1050 <string_reverse@plt>
lea    -0xa0(%rbp),%rsi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x32,%edx
call   1070 <string_concat@plt>
mov    %eax,-0x140(%rbp)
lea    -0x50(%rbp),%rsi
mov    -0x140(%rbp),%edx
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x11(%rbp),%rdi
lea    -0x11(%rbp),%rsi
call   1030 <string_compare@plt>
mov    %eax,-0x144(%rbp)
mov    -0x144(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x11(%rbp),%rdi
lea    -0xa4(%rbp),%rsi
call   10a0 <string_substring@plt>
mov    %eax,-0x148(%rbp)
mov    -0x148(%rbp),%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x11(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x130(%rbp),%rdi
lea    -0xa8(%rbp),%rdx
lea    -0x110(%rbp),%rcx
mov    $0x3,%esi
mov    $0x64,%r8d
call   1080 <string_join@plt>
lea    -0x110(%rbp),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x140,%rsp
movabs $0x21646c726f5720,%rax
mov    %rax,0x15(%rsp)
movabs $0x6f57206f6c6c6548,%rax
20 57 6f
mov    %rax,0x10(%rsp)
movzwl 0xf9c(%rip),%eax
mov    %ax,0xc0(%rsp)
movaps 0xf7d(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xf5e(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xf3f(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xf80(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xf64(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movabs $0x2e756f79206e61,%rax
mov    %rax,0x7e(%rsp)
movabs $0x64657372657665,%rax
mov    %rax,0x50(%rsp)
movaps 0xf6a(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movl   $0x6c726f,0xc(%rsp)
movl   $0x202e20,0x8(%rsp)
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1080 <string_len@plt>
mov    %eax,%ebp
lea    0x90(%rsp),%r14
mov    %r14,%rdi
call   1080 <string_len@plt>
mov    %eax,%ebx
lea    0x60(%rsp),%r15
mov    %r15,%rdi
call   1080 <string_len@plt>
lea    0xdad(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdcd(%rip),%rdi
lea    0x40(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <string_reverse@plt>
lea    0xdc5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x32,%edx
call   1060 <string_concat@plt>
lea    0xdc1(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r12,%rsi
call   1030 <string_compare@plt>
lea    0xdee(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %r12,%rdi
call   1090 <string_substring@plt>
lea    0xdeb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,0x20(%rsp)
mov    %r14,0x28(%rsp)
mov    %r15,0x30(%rsp)
lea    0x20(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0xd0(%rsp),%rbx
mov    $0x3,%esi
mov    %rbx,%rcx
mov    $0x64,%r8d
call   1070 <string_join@plt>
lea    0xdc0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.testStr1 = [13 x i8] c"Hello World!\00"
@__const.main.testStr2 = <{ [15 x i8], [35 x i8] }> <{ [15 x i8] c"I am a computer", [35 x i8] zeroinitializer }>
@__const.main.testStr3 = [38 x i8] c"I do multiple things better than you.\00"
@__const.main.testStr4 = [24 x i8] c"This string is reversed\00"
@__const.main.testStr5 = [4 x i8] c"orl\00"
@__const.main.separator = [4 x i8] c" . \00"
@.str = [52 x i8] c"Length of the strings:\0A [1]. %d\0A [2]. %d\0A [3]. %d\0A\0A\00"
@.str.1 = [22 x i8] c"String to reverse: %s\00"
@.str.2 = [29 x i8] c"\0AString after reversal: %s\0A\0A\00"
@.str.3 = [75 x i8] c"The cat'd string from testStr2 and testStr1 is: %s\0ACharacters copied: %d\0A\0A\00"
@.str.4 = [26 x i8] c"Comparison variable: %d\0A\0A\00"
@.str.5 = [25 x i8] c"Substring variable: %d\0A\0A\00"
@.str.6 = [27 x i8] c"Joined string result:\0A%s\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [13 x i8]
%3 = alloca [50 x i8]
%4 = alloca [38 x i8]
%5 = alloca [24 x i8]
%6 = alloca [4 x i8]
%7 = alloca [4 x i8]
%8 = alloca [100 x i8]
%9 = alloca [3 x i8*]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %1
%16 = bitcast [13 x i8]* %2 to i8*
%17 = bitcast [50 x i8]* %3 to i8*
%18 = bitcast [38 x i8]* %4 to i8*
%19 = bitcast [24 x i8]* %5 to i8*
%20 = bitcast [4 x i8]* %6 to i8*
%21 = bitcast [4 x i8]* %7 to i8*
%22 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%23 = call i32 @string_len(i8* %22)
store i32 %23, i32* %10
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%25 = call i32 @string_len(i8* %24)
store i32 %25, i32* %11
%26 = getelementptr inbounds [38 x i8], [38 x i8]* %4, i64 0, i64 0
%27 = call i32 @string_len(i8* %26)
store i32 %27, i32* %12
%28 = load i32, i32* %10
%29 = load i32, i32* %11
%30 = load i32, i32* %12
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
%32 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
%35 = call i32 @string_reverse(i8* %34)
%36 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%39 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%40 = call i32 @string_concat(i8* %38, i8* %39, i32 50)
store i32 %40, i32* %13
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%42 = load i32, i32* %13
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0), i8* %41, i32 %42)
%44 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%45 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%46 = call i32 @string_compare(i8* %44, i8* %45)
store i32 %46, i32* %14
%47 = load i32, i32* %14
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%50 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%51 = call i32 @string_substring(i8* %49, i8* %50)
store i32 %51, i32* %15
%52 = load i32, i32* %15
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%55 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 0
store i8* %54, i8** %55
%56 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%57 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 1
store i8* %56, i8** %57
%58 = getelementptr inbounds [38 x i8], [38 x i8]* %4, i64 0, i64 0
%59 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 2
store i8* %58, i8** %59
%60 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 0
%61 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%63 = call i32 @string_join(i8** %60, i32 3, i8* %61, i8* %62, i32 100)
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %64)
ret i32 0
}

LLVM IR (-O2):
@__const.main.testStr1 = [13 x i8] c"Hello World!\00"
@__const.main.testStr2 = <{ [15 x i8], [35 x i8] }> <{ [15 x i8] c"I am a computer", [35 x i8] zeroinitializer }>
@__const.main.testStr3 = [38 x i8] c"I do multiple things better than you.\00"
@__const.main.testStr4 = [24 x i8] c"This string is reversed\00"
@.str = [52 x i8] c"Length of the strings:\0A [1]. %d\0A [2]. %d\0A [3]. %d\0A\0A\00"
@.str.1 = [22 x i8] c"String to reverse: %s\00"
@.str.2 = [29 x i8] c"\0AString after reversal: %s\0A\0A\00"
@.str.3 = [75 x i8] c"The cat'd string from testStr2 and testStr1 is: %s\0ACharacters copied: %d\0A\0A\00"
@.str.4 = [26 x i8] c"Comparison variable: %d\0A\0A\00"
@.str.5 = [25 x i8] c"Substring variable: %d\0A\0A\00"
@.str.6 = [27 x i8] c"Joined string result:\0A%s\0A\0A\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = alloca [50 x i8]
%3 = alloca [38 x i8]
%4 = alloca [24 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca [3 x i8*]
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [38 x i8], [38 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [24 x i8], [24 x i8]* %4, i64 0, i64 0
%13 = bitcast i32* %5 to i8*
store i32 7107183, i32* %5
%14 = bitcast i32* %6 to i8*
store i32 2108960, i32* %6
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%16 = bitcast [3 x i8*]* %8 to i8*
%17 = call i32 @string_len(i8* %9)
%18 = call i32 @string_len(i8* %10)
%19 = call i32 @string_len(i8* %11)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%22 = call i32 @string_reverse(i8* %12)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%24 = call i32 @string_concat(i8* %10, i8* %9, i32 50)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0), i8* %10, i32 %24)
%26 = call i32 @string_compare(i8* %9, i8* %9)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = call i32 @string_substring(i8* %9, i8* %13)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
store i8* %9, i8** %30
%31 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 1
store i8* %10, i8** %31
%32 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 2
store i8* %11, i8** %32
%33 = call i32 @string_join(i8** %30, i32 3, i8* %14, i8* %15, i32 100)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %15)
ret i32 0
}