#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[80], s2[40];
  int i, j;
  printf("input string1:\n");
  scanf("%s", s1);
  printf("input string2:\n");
  scanf("%s", s2);
  i = 0;
  j = 0;
  while (s1[i] != '\0')
    i++;
  while (s2[j] != '\0')
    s1[i++] = s2[j++];
  s1[i] = '\0';
  printf("\nThe new string is:%s\n", s1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
movslq -0x94(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11ae <main+0x8e>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1185 <main+0x65>
jmp    11b3 <main+0x93>
movslq -0x98(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1201 <main+0xe1>
mov    -0x98(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x98(%rbp)
cltq
mov    -0x90(%rbp,%rax,1),%cl
mov    -0x94(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x94(%rbp)
cltq
mov    %cl,-0x60(%rbp,%rax,1)
jmp    11b3 <main+0x93>
movslq -0x94(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rbx
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,0x31(%rsp,%rax,1)
lea    0x1(%rax),%rax
jne    1180 <main+0x50>
mov    (%rsp),%cl
test   %cl,%cl
je     11b3 <main+0x83>
mov    %eax,%eax
lea    0x1(%rsp),%rdx
nopl   0x0(%rax)
mov    %cl,0x30(%rsp,%rax,1)
add    $0x1,%rax
movzbl (%rdx),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    11a0 <main+0x70>
mov    %eax,%eax
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xe42(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"input string1:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"input string2:\0A\00"
@.str.3 = [23 x i8] c"\0AThe new string is:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [40 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%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 ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
store i32 0, i32* %4
store i32 0, i32* %5
br label %12
12: ; preds = %19, %0
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [80 x i8], [80 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 %22
19: ; preds = %12
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %12
22: ; preds = %12
br label %23
23: ; preds = %30, %22
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %23
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %38
store i8 %35, i8* %39
br label %23
40: ; preds = %23
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %42
store i8 0, i8* %43
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %44)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [23 x i8] c"\0AThe new string is:%s\0A\00"
@str = [15 x i8] c"input string1:\00"
@str.4 = [15 x i8] c"input string2:\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [40 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = call i32 @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 ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %9
9: ; preds = %9, %0
%10 = phi i64 [ %14, %9 ], [ 0, %0 ]
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = add nuw i64 %10, 1
br i1 %13, label %15, label %9
15: ; preds = %9
%16 = load i8, i8* %4
%17 = icmp eq i8 %16, 0
br i1 %17, label %30, label %18
18: ; preds = %15
%19 = and i64 %10, 4294967295
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ %19, %18 ], [ %25, %20 ]
%22 = phi i64 [ 0, %18 ], [ %24, %20 ]
%23 = phi i8 [ %16, %18 ], [ %28, %20 ]
%24 = add nuw nsw i64 %22, 1
%25 = add nuw i64 %21, 1
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %21
store i8 %23, i8* %26
%27 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %24
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %20
30: ; preds = %20, %15
%31 = phi i64 [ %10, %15 ], [ %25, %20 ]
%32 = and i64 %31, 4294967295
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %32
store i8 0, i8* %33
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %3)
ret i32 0
}