int main() {
  char a[20], b[20];
  int s1, s2, k;
  printf("Enter first string\n");
  scanf("%s", a);
  printf("Enter the second string\n");
  scanf("%s", b);
  s1 = a;
  s2 = b;
  k = strcat(s1, s2);
  printf("The concatenated string is \n");
  printf("%s", k);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x20(%rbp),%rax
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rax
mov    %eax,-0x48(%rbp)
movslq -0x44(%rbp),%rdi
movslq -0x48(%rbp),%rsi
call   1050 <strcat@plt>
mov    %eax,-0x4c(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%r14
lea    0x20(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r12
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq %r15d,%rbx
movslq %r12d,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter first string\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [25 x i8] c"Enter the second string\0A\00"
@.str.3 = [29 x i8] c"The concatenated string is \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%14 = ptrtoint i8* %13 to i32
store i32 %14, i32* %4
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%16 = ptrtoint i8* %15 to i32
store i32 %16, i32* %5
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
%23 = call i8* @strcat(i8* %19, i8* %22)
%24 = ptrtoint i8* %23 to i32
store i32 %24, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [19 x i8] c"Enter first string\00"
@str.4 = [24 x i8] c"Enter the second string\00"
@str.5 = [28 x i8] c"The concatenated string is \00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = ptrtoint [20 x i8]* %1 to i64
%10 = ptrtoint [20 x i8]* %2 to i64
%11 = shl i64 %9, 32
%12 = ashr exact i64 %11, 32
%13 = inttoptr i64 %12 to i8*
%14 = shl i64 %10, 32
%15 = ashr exact i64 %14, 32
%16 = inttoptr i64 %15 to i8*
%17 = call i8* @strcat(i8* dereferenceable(1) %13, i8* dereferenceable(1) %16)
%18 = trunc i64 %9 to i32
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}