#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(void) {
  char str1[100] = {0}, str2[100];
  int len1, len2;
  printf("Enter first string: ");
  gets(str1);
  len1 = strlen(str1);
  printf("Enter second string: ");
  gets(str2);
  len2 = strlen(str2);
  for (size_t i = len1, j = 0; j < len2; i++, j++) {
    str1[i] = str2[j];
  }
  printf("The concatenated: %s", str1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xe4(%rbp)
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1060 <gets@plt>
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xe8(%rbp)
movslq -0xe4(%rbp),%rax
mov    %rax,-0xf0(%rbp)
movq   $0x0,-0xf8(%rbp)
mov    -0xf8(%rbp),%rax
movslq -0xe8(%rbp),%rcx
cmp    %rcx,%rax
jae    1226 <main+0xe6>
mov    -0xf8(%rbp),%rax
mov    -0xe0(%rbp,%rax,1),%cl
mov    -0xf0(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0xf0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    11cd <main+0x8d>
lea    -0x70(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     11cf <main+0x8f>
movslq %ebp,%rcx
lea    (%rsp,%rcx,1),%rdi
movslq %eax,%rdx
lea    0x70(%rsp),%rsi
call   1050 <memcpy@plt>
lea    0xe55(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Enter first string: \00"
@.str.1 = [22 x i8] c"Enter second string: \00"
@.str.2 = [21 x i8] c"The concatenated: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = bitcast [100 x i8]* %2 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%16 = call i32 @gets(i8* %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %5
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
store i64 %20, i64* %6
store i64 0, i64* %7
br label %21
21: ; preds = %32, %0
%22 = load i64, i64* %7
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = icmp ult i64 %22, %24
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = load i64, i64* %7
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = load i64, i64* %6
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %30
store i8 %29, i8* %31
br label %32
32: ; preds = %26
%33 = load i64, i64* %6
%34 = add i64 %33, 1
store i64 %34, i64* %6
%35 = load i64, i64* %7
%36 = add i64 %35, 1
store i64 %36, i64* %7
br label %21
37: ; preds = %21
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Enter first string: \00"
@.str.1 = [22 x i8] c"Enter second string: \00"
@.str.2 = [21 x i8] c"The concatenated: %s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @strlen(i8* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @gets(i8* %4)
%10 = call i32 @strlen(i8* %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %0
%13 = sext i32 %7 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = getelementptr [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%16 = sext i32 %10 to i64
br label %17
17: ; preds = %12, %0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}