#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 getchar();
int getlinee(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat1(char *, char *, int, int);
int main() {
  int len1, len2, first, c;
  char s1[1000];
  char s2[1000];
  first = 1;
  while (1) {
    if (first != 1) {
      printf("\nDo you want to continue?(Y\\N)");
      if (((c = getchar()) == 'y') || (c == 'Y')) {
        c = getchar();
        printf("\nPlease enter first string\n");
        len1 = getlinee(s1, 1000);
        printf("Please enter second string\n");
        len2 = getlinee(s2, 1000);
        strcat1(s1, s2, len1, len2);
        printf("The resulting string is:\n%s", s1);
      } else if ((c == 'n') || (c == 'N'))
        break;
      else
        printf("I don't understand that command\n");
    } else {
      printf("Please enter first string\n");
      len1 = getlinee(s1, 1000);
      printf("Please enter second string\n");
      len2 = getlinee(s2, 1000);
      strcat1(s1, s2, len1, len2);
      printf("The resulting string is:\n%s", s1);
      first = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
je     1240 <main+0x100>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x79,%eax
je     118e <main+0x4e>
cmpl   $0x59,-0x14(%rbp)
jne    120f <main+0xcf>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <getlinee@plt>
mov    %eax,-0x8(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <getlinee@plt>
mov    %eax,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1050 <strcat1@plt>
lea    -0x400(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0xfb>
cmpl   $0x6e,-0x14(%rbp)
je     1223 <main+0xe3>
cmpl   $0x4e,-0x14(%rbp)
jne    1228 <main+0xe8>
jmp    12be <main+0x17e>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0xfb>
jmp    12b9 <main+0x179>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <getlinee@plt>
mov    %eax,-0x8(%rbp)
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <getlinee@plt>
mov    %eax,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1050 <strcat1@plt>
lea    -0x400(%rbp),%rsi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d8,%rsp
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0x3f0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1070 <getlinee@plt>
mov    %eax,%ebp
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1070 <getlinee@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1060 <strcat1@plt>
lea    0xe69(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe39(%rip),%r13
lea    0xe8d(%rip),%rbp
lea    0xe66(%rip),%r14
jmp    1239 <main+0xe9>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1070 <getlinee@plt>
mov    %eax,%r12d
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1070 <getlinee@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
mov    %eax,%ecx
call   1060 <strcat1@plt>
lea    0xdf0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
and    $0xffffffdf,%eax
cmp    $0x59,%eax
je     11e0 <main+0x90>
cmp    $0x4e,%eax
je     1261 <main+0x111>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    1239 <main+0xe9>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0ADo you want to continue?(Y\\N)\00"
@.str.1 = [28 x i8] c"\0APlease enter first string\0A\00"
@.str.2 = [28 x i8] c"Please enter second string\0A\00"
@.str.3 = [28 x i8] c"The resulting string is:\0A%s\00"
@.str.4 = [33 x i8] c"I don't understand that command\0A\00"
@.str.5 = [27 x i8] c"Please enter first string\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1000 x i8]
%7 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 1, i32* %4
br label %8
8: ; preds = %0, %58
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %44
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (...) @getchar()
store i32 %13, i32* %5
%14 = icmp eq i32 %13, 121
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 89
br i1 %17, label %18, label %33
18: ; preds = %15, %11
%19 = call i32 (...) @getchar()
store i32 %19, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%22 = call i32 @getlinee(i8* %21, i32 1000)
store i32 %22, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%25 = call i32 @getlinee(i8* %24, i32 1000)
store i32 %25, i32* %3
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 @strcat1(i8* %26, i8* %27, i32 %28, i32 %29)
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %31)
br label %43
33: ; preds = %15
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 110
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 78
br i1 %38, label %39, label %40
39: ; preds = %36, %33
br label %59
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40
br label %43
43: ; preds = %42, %18
br label %58
44: ; preds = %8
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%47 = call i32 @getlinee(i8* %46, i32 1000)
store i32 %47, i32* %2
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%50 = call i32 @getlinee(i8* %49, i32 1000)
store i32 %50, i32* %3
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%53 = load i32, i32* %2
%54 = load i32, i32* %3
%55 = call i32 @strcat1(i8* %51, i8* %52, i32 %53, i32 %54)
%56 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %56)
store i32 0, i32* %4
br label %58
58: ; preds = %44, %43
br label %8
59: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"\0ADo you want to continue?(Y\\N)\00"
@.str.3 = [28 x i8] c"The resulting string is:\0A%s\00"
@str = [26 x i8] c"Please enter first string\00"
@str.7 = [32 x i8] c"I don't understand that command\00"
@str.8 = [27 x i8] c"\0APlease enter first string\00"
@str.9 = [27 x i8] c"Please enter second string\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%6 = call i32 @getlinee(i8* %3, i32 1000)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%8 = call i32 @getlinee(i8* %4, i32 1000)
%9 = call i32 @strcat1(i8* %3, i8* %4, i32 %6, i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %11
11: ; preds = %23, %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (...) @getchar()
%14 = and i32 %13, -33
switch i32 %14, label %24 [
i32 89, label %15
i32 78, label %26
]
15: ; preds = %11
%16 = call i32 (...) @getchar()
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%18 = call i32 @getlinee(i8* %3, i32 1000)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%20 = call i32 @getlinee(i8* %4, i32 1000)
%21 = call i32 @strcat1(i8* %3, i8* %4, i32 %18, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %23
23: ; preds = %15, %24
br label %11
24: ; preds = %11
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
br label %23
26: ; preds = %11
ret i32 0
}