#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 main() {
  int i, j;
  char str1[100 + 1];
  char str2[100 + 1];
  char cat[2 * 100 + 1];
  printf("str1 = ");
  gets(str1);
  printf("str2 = ");
  gets(str2);
  for (i = 0; str1[i] != '\0'; i++) {
    printf("cat[%d] = str[%d] = %c\n", i, i, str1[i]);
    cat[i] = str1[i];
  }
  for (j = 0; str2[j] != '\0'; j++) {
    printf("cat[%d] = str[%d] = %c\n", i + j, i, str2[j]);
    cat[i + j] = str2[j];
  }
  cat[i + j] = '\0';
  printf("cat = %s\n", cat);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1040 <gets@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xf0(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11ba <main+0x9a>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
movslq -0x8(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%ecx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x1c0(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x4a>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1221 <main+0x101>
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
movslq -0xc(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%ecx
ff
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
mov    -0xf0(%rbp,%rax,1),%cl
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cltq
mov    %cl,-0x1c0(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c1 <main+0xa1>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cltq
movb   $0x0,-0x1c0(%rbp,%rax,1)
lea    -0x1c0(%rbp),%rsi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1b8,%rsp
lea    0xecb(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x70(%rsp),%rdi
call   1040 <gets@plt>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rdi
call   1040 <gets@plt>
mov    0x70(%rsp),%al
mov    $0x0,%ebx
test   %al,%al
je     11aa <main+0x8a>
lea    0xe9d(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x70(%rsp,%rbx,1),%ecx
movzbl 0x71(%rsp,%rbx,1),%eax
mov    %cl,0xe0(%rsp,%rbx,1)
add    $0x1,%rbx
test   %al,%al
jne    1180 <main+0x60>
mov    %ebx,%ebx
mov    (%rsp),%al
test   %al,%al
je     11fa <main+0xda>
lea    (%rsp,%rbx,1),%r12
add    $0xe0,%r12
lea    0xe4b(%rip),%r14
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
movsbl %al,%ecx
lea    (%rbx,%r15,1),%esi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl (%rsp,%r15,1),%eax
mov    %al,(%r12,%r15,1)
movzbl 0x1(%rsp,%r15,1),%eax
add    $0x1,%r15
test   %al,%al
jne    11d0 <main+0xb0>
mov    %r15d,%eax
add    %rbx,%rax
movb   $0x0,0xe0(%rsp,%rax,1)
lea    0xe19(%rip),%rdi
lea    0xe0(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"str1 = \00"
@.str.1 = [8 x i8] c"str2 = \00"
@.str.2 = [24 x i8] c"cat[%d] = str[%d] = %c\0A\00"
@.str.3 = [10 x i8] c"cat = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [101 x i8]
%5 = alloca [101 x i8]
%6 = alloca [201 x i8]
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%12 = call i32 @gets(i8* %11)
store i32 0, i32* %2
br label %13
13: ; preds = %36, %0
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %13
%21 = load i32, i32* %2
%22 = load i32, i32* %2
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %22, i32 %27)
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [201 x i8], [201 x i8]* %6, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %20
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %13
39: ; preds = %13
store i32 0, i32* %3
br label %40
40: ; preds = %67, %39
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %70
47: ; preds = %40
%48 = load i32, i32* %2
%49 = load i32, i32* %3
%50 = add nsw i32 %48, %49
%51 = load i32, i32* %2
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %50, i32 %51, i32 %56)
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = load i32, i32* %2
%63 = load i32, i32* %3
%64 = add nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [201 x i8], [201 x i8]* %6, i64 0, i64 %65
store i8 %61, i8* %66
br label %67
67: ; preds = %47
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %40
70: ; preds = %40
%71 = load i32, i32* %2
%72 = load i32, i32* %3
%73 = add nsw i32 %71, %72
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [201 x i8], [201 x i8]* %6, i64 0, i64 %74
store i8 0, i8* %75
%76 = getelementptr inbounds [201 x i8], [201 x i8]* %6, i64 0, i64 0
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %76)
%78 = load i32, i32* %1
ret i32 %78
}

LLVM IR (-O2):
@.str = [8 x i8] c"str1 = \00"
@.str.1 = [8 x i8] c"str2 = \00"
@.str.2 = [24 x i8] c"cat[%d] = str[%d] = %c\0A\00"
@.str.3 = [10 x i8] c"cat = %s\0A\00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = alloca [101 x i8]
%3 = alloca [201 x i8]
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 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 %15, label %21
13: ; preds = %21
%14 = trunc i64 %30 to i32
br label %15
15: ; preds = %13, %0
%16 = phi i32 [ 0, %0 ], [ %14, %13 ]
%17 = load i8, i8* %5
%18 = icmp eq i8 %17, 0
br i1 %18, label %50, label %19
19: ; preds = %15
%20 = zext i32 %16 to i64
br label %34
21: ; preds = %0, %21
%22 = phi i64 [ %30, %21 ], [ 0, %0 ]
%23 = phi i8 [ %32, %21 ], [ %11, %0 ]
%24 = phi i8* [ %31, %21 ], [ %4, %0 ]
%25 = sext i8 %23 to i32
%26 = trunc i64 %22 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %26, i32 %25)
%28 = load i8, i8* %24
%29 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 %22
store i8 %28, i8* %29
%30 = add nuw i64 %22, 1
%31 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %13, label %21
34: ; preds = %19, %34
%35 = phi i64 [ 0, %19 ], [ %44, %34 ]
%36 = phi i8 [ %17, %19 ], [ %46, %34 ]
%37 = phi i8* [ %5, %19 ], [ %45, %34 ]
%38 = sext i8 %36 to i32
%39 = add nuw nsw i64 %35, %20
%40 = trunc i64 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %16, i32 %38)
%42 = load i8, i8* %37
%43 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 %39
store i8 %42, i8* %43
%44 = add nuw i64 %35, 1
%45 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %48, label %34
48: ; preds = %34
%49 = trunc i64 %44 to i32
br label %50
50: ; preds = %48, %15
%51 = phi i32 [ 0, %15 ], [ %49, %48 ]
%52 = add nuw nsw i32 %51, %16
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 %53
store i8 0, i8* %54
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %6)
ret i32 0
}