int main() {
  char str1[20] = "abcde", str2[10] = "FGHIJdd";
  printf("length of str1 is %d\nlength of str2 is %d\n", lenStr(str1),
         lenStr(str2));
  printf("str1 is %s,str2 is %s", str1, str2);
  catStr(str1, str2);
  printf("\ncombined length is %d\nAfter combination:%s", lenStr(str1), str1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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),%rax
mov    %rax,-0x2a(%rbp)
mov    0xeac(%rip),%ax
mov    %ax,-0x22(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <lenStr@plt>
mov    %eax,-0x30(%rbp)
lea    -0x2a(%rbp),%rdi
mov    $0x0,%al
call   1050 <lenStr@plt>
mov    -0x30(%rbp),%esi
mov    %eax,%edx
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x2a(%rbp),%rsi
mov    $0x0,%al
call   1030 <catStr@plt>
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <lenStr@plt>
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movabs $0x64644a49484746,%rax
mov    %rax,(%rsp)
movw   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <lenStr@plt>
mov    %eax,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <lenStr@plt>
lea    0xe98(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <catStr@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <lenStr@plt>
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str1 = [20 x i8] c"abcde\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.str2 = [10 x i8] c"FGHIJdd\00\00\00"
@.str = [43 x i8] c"length of str1 is %d\0Alength of str2 is %d\0A\00"
@.str.1 = [22 x i8] c"str1 is %s,str2 is %s\00"
@.str.2 = [44 x i8] c"\0Acombined length is %d\0AAfter combination:%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [10 x i8]
store i32 0, i32* %1
%4 = bitcast [20 x i8]* %2 to i8*
%5 = bitcast [10 x i8]* %3 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @lenStr to i32 (i8*, ...)*)(i8* %6)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @lenStr to i32 (i8*, ...)*)(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @catStr to i32 (i8*, i8*, ...)*)(i8* %14, i8* %15)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @lenStr to i32 (i8*, ...)*)(i8* %17)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %18, i8* %19)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str1 = [20 x i8] c"abcde\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.str2 = [10 x i8] c"FGHIJdd\00\00\00"
@.str = [43 x i8] c"length of str1 is %d\0Alength of str2 is %d\0A\00"
@.str.1 = [22 x i8] c"str1 is %s,str2 is %s\00"
@.str.2 = [44 x i8] c"\0Acombined length is %d\0AAfter combination:%s\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @lenStr to i32 (i8*, ...)*)(i8* %3)
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @lenStr to i32 (i8*, ...)*)(i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
%9 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @catStr to i32 (i8*, i8*, ...)*)(i8* %3, i8* %4)
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @lenStr to i32 (i8*, ...)*)(i8* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %10, i8* %3)
ret i32 0
}