#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 /*<<< orphan*/ puts(char *);
void main() {
  char a[50], b[50], c[50];
  int i = 0, j = 0;
  printf("Enter 1st String:");
  gets(a);
  printf("Enter 2nd String:");
  gets(b);
  for (i = 0; a[i] != '\0'; i++)
    c[i] = a[i];
  c[i] = ' ';
  for (j = 0; b[j] != '\0'; j++, i++)
    c[i] = b[j];
  c[i] = '\0';
  printf("\n3rd string:");
  puts(c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0xc4(%rbp)
movl   $0x0,-0xc8(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <gets@plt>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0xc4(%rbp)
movslq -0xc4(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11c5 <main+0x95>
movslq -0xc4(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%cl
movslq -0xc4(%rbp),%rax
mov    %cl,-0xc0(%rbp,%rax,1)
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    1183 <main+0x53>
movslq -0xc4(%rbp),%rax
movb   $0x20,-0xc0(%rbp,%rax,1)
20
movl   $0x0,-0xc8(%rbp)
movslq -0xc8(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     122f <main+0xff>
movslq -0xc8(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%cl
movslq -0xc4(%rbp),%rax
mov    %cl,-0xc0(%rbp,%rax,1)
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    11de <main+0xae>
movslq -0xc4(%rbp),%rax
movb   $0x0,-0xc0(%rbp,%rax,1)
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
lea    -0xc0(%rbp),%rdi
call   1030 <puts@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xb8,%rsp
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
lea    0x80(%rsp),%rdi
call   1050 <gets@plt>
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0x40(%rsp),%rdi
call   1050 <gets@plt>
mov    0x80(%rsp),%al
test   %al,%al
je     1197 <main+0x67>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%rsp,%rcx,1)
movzbl 0x81(%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    1180 <main+0x50>
mov    %ecx,%eax
jmp    1199 <main+0x69>
xor    %eax,%eax
movb   $0x20,(%rsp,%rax,1)
mov    0x40(%rsp),%cl
test   %cl,%cl
je     11c4 <main+0x94>
lea    0x41(%rsp),%rdx
nopw   0x0(%rax,%rax,1)
mov    %cl,(%rsp,%rax,1)
add    $0x1,%rax
movzbl (%rdx),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    11b0 <main+0x80>
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1030 <puts@plt>
add    $0xb8,%rsp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter 1st String:\00"
@.str.1 = [18 x i8] c"Enter 2nd String:\00"
@.str.2 = [13 x i8] c"\0A3rd string:\00"
define void @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
store i32 0, i32* %4
br label %12
12: ; preds = %27, %0
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %1, 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 %30
19: ; preds = %12
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %19
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %12
30: ; preds = %12
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %32
store i8 32, i8* %33
store i32 0, i32* %5
br label %34
34: ; preds = %49, %30
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %54
41: ; preds = %34
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %47
store i8 %45, i8* %48
br label %49
49: ; preds = %41
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %34
54: ; preds = %34
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %56
store i8 0, i8* %57
%58 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%59 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%60 = call i32 @puts(i8* %59)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter 1st String:\00"
@.str.1 = [18 x i8] c"Enter 2nd String:\00"
@.str.2 = [13 x i8] c"\0A3rd string:\00"
define void @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @gets(i8* %5)
%11 = load i8, i8* %4
%12 = icmp eq i8 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ 0, %0 ]
%15 = phi i8 [ %19, %13 ], [ %11, %0 ]
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %14
store i8 %15, i8* %16
%17 = add nuw nsw i64 %14, 1
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %13
21: ; preds = %13
%22 = and i64 %17, 4294967295
br label %23
23: ; preds = %21, %0
%24 = phi i64 [ 0, %0 ], [ %22, %21 ]
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %24
store i8 32, i8* %25
%26 = load i8, i8* %5
%27 = icmp eq i8 %26, 0
br i1 %27, label %40, label %28
28: ; preds = %23, %28
%29 = phi i64 [ %34, %28 ], [ %24, %23 ]
%30 = phi i64 [ %33, %28 ], [ 0, %23 ]
%31 = phi i8 [ %36, %28 ], [ %26, %23 ]
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %29
store i8 %31, i8* %32
%33 = add nuw nsw i64 %30, 1
%34 = add nuw i64 %29, 1
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %33
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %38, label %28
38: ; preds = %28
%39 = and i64 %34, 4294967295
br label %40
40: ; preds = %38, %23
%41 = phi i64 [ %39, %38 ], [ %24, %23 ]
%42 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %41
store i8 0, i8* %42
%43 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @puts(i8* %6)
ret void
}