int main() {
  char str1[30] = {"WRHTEshh22"}, str2[20] = {"125etahe2"};
  printf("Original str1=%s,str2=%s\n", str1, str2);
  nstrcat(str1, str2);
  printf("After:\nstr1=%s\n", str1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xebc(%rip),%ax
mov    %ax,-0x14(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xeb0(%rip),%eax
mov    %eax,-0x40(%rbp)
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x0,%al
call   1040 <nstrcat@plt>
lea    -0x30(%rbp),%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movups 0xee0(%rip),%xmm0
movups %xmm0,0x2e(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xedb(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <nstrcat@plt>
lea    0xecc(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str1 = [30 x i8] c"WRHTEshh22\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.str2 = [20 x i8] c"125etahe2\00\00\00\00\00\00\00\00\00\00\00"
@.str = [26 x i8] c"Original str1=%s,str2=%s\0A\00"
@.str.1 = [16 x i8] c"After:\0Astr1=%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca [20 x i8]
store i32 0, i32* %1
%4 = bitcast [30 x i8]* %2 to i8*
%5 = bitcast [20 x i8]* %3 to i8*
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @nstrcat to i32 (i8*, i8*, ...)*)(i8* %9, i8* %10)
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str1 = [30 x i8] c"WRHTEshh22\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.str2 = [20 x i8] c"125etahe2\00\00\00\00\00\00\00\00\00\00\00"
@.str = [26 x i8] c"Original str1=%s,str2=%s\0A\00"
@.str.1 = [16 x i8] c"After:\0Astr1=%s\0A\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @nstrcat to i32 (i8*, i8*, ...)*)(i8* %3, i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret i32 0
}