#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 /*<<< orphan*/ scanf(char *, char **);
int main() {
  char s1[100], s2[100], i, j;
  printf("Enter first string: ");
  scanf("%s", &s1);
  printf("Enter second string: ");
  scanf("%s", &s2);
  for (i = 0; s1[i] != '\0'; ++i)
    ;
  for (j = 0; s2[j] != '\0'; ++j, ++i) {
    s1[i] = s2[j];
  }
  s1[i] = '\0';
  printf("After concatenation: %s", s1);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xef5(%rip),%rdi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xed4(%rip),%rdi
call   1040 <scanf@plt>
movb   $0x0,-0xe1(%rbp)
movsbq -0xe1(%rbp),%rax
ff
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11a6 <main+0x86>
jmp    1193 <main+0x73>
mov    -0xe1(%rbp),%al
add    $0x1,%al
mov    %al,-0xe1(%rbp)
jmp    1178 <main+0x58>
movb   $0x0,-0xe2(%rbp)
movsbq -0xe2(%rbp),%rax
ff
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1202 <main+0xe2>
movsbq -0xe2(%rbp),%rax
ff
mov    -0xe0(%rbp,%rax,1),%cl
movsbq -0xe1(%rbp),%rax
ff
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0xe2(%rbp),%al
add    $0x1,%al
mov    %al,-0xe2(%rbp)
mov    -0xe1(%rbp),%al
add    $0x1,%al
mov    %al,-0xe1(%rbp)
jmp    11ad <main+0x8d>
movsbq -0xe1(%rbp),%rax
ff
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xecf(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeff(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x70(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
nopw   0x0(%rax,%rax,1)
movsbq %bl,%rcx
lea    0x1(%rcx),%ebx
cmpb   $0x0,(%rsp,%rcx,1)
jne    1170 <main+0x50>
mov    0x70(%rsp),%al
test   %al,%al
je     11b6 <main+0x96>
mov    $0x1,%cl
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%rcx,1),%edx
add    $0xfe,%dl
movsbq %dl,%rdx
mov    %al,(%rsp,%rdx,1)
movsbq %cl,%rcx
movzbl 0x70(%rsp,%rcx,1),%eax
add    $0x1,%cl
test   %al,%al
jne    1190 <main+0x70>
add    %cl,%bl
add    $0xfe,%bl
movsbq %bl,%rcx
movb   $0x0,(%rsp,%rcx,1)
lea    0xe6a(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"Enter first string: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"Enter second string: \00"
@.str.3 = [24 x i8] c"After concatenation: %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 = bitcast [100 x i8]* %1 to i8**
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%9 = bitcast [100 x i8]* %2 to i8**
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %9)
br label %11
11: ; preds = %11, %0
%12 = phi i8 [ 0, %0 ], [ %17, %11 ]
%13 = sext i8 %12 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
%17 = add i8 %12, 1
br i1 %16, label %18, label %11
18: ; preds = %11
%19 = load i8, i8* %4
%20 = icmp eq i8 %19, 0
br i1 %20, label %35, label %21
21: ; preds = %18, %21
%22 = phi i8 [ %31, %21 ], [ %19, %18 ]
%23 = phi i8 [ %27, %21 ], [ 0, %18 ]
%24 = phi i8 [ %28, %21 ], [ %12, %18 ]
%25 = sext i8 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %25
store i8 %22, i8* %26
%27 = add i8 %23, 1
%28 = add i8 %24, 1
%29 = sext i8 %27 to i64
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %33, label %21
33: ; preds = %21
%34 = sext i8 %28 to i64
br label %35
35: ; preds = %33, %18
%36 = phi i64 [ %34, %33 ], [ %13, %18 ]
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %36
store i8 0, i8* %37
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %3)
ret i32 0
}