#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*/ My_strcat(unsigned char *, unsigned char *);
int /*<<< orphan*/ print_options_str_manip();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
void str_manip_main() {
  unsigned char str1[100] = "array1";
  unsigned char str2[100] = "array2";
  unsigned int option = 0;
  unsigned int exit_count = 0;
  while (exit_count < 5) {
    print_options_str_manip();
    scanf("%d", &option);
    if (0 == option) {
      printf(
          "Hope you enjoyed learning \"string manipulation\", Goodbye!!!\r\n");
      break;
    }
    switch (option) {
    case 1:
      My_strcat(str1, str2);
      printf("\r\nYour concatinated string is \"%s\"\r\n", str1);
      break;
    default:
      printf("Wrong option!!!!\r\nWhat concept would you like to learn? Try "
             "again!!!");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<str_manip_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movb   $0x61,-0x70(%rbp)
movb   $0x72,-0x6f(%rbp)
movb   $0x72,-0x6e(%rbp)
movb   $0x61,-0x6d(%rbp)
movb   $0x79,-0x6c(%rbp)
movb   $0x31,-0x6b(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movb   $0x61,-0xe0(%rbp)
movb   $0x72,-0xdf(%rbp)
movb   $0x72,-0xde(%rbp)
movb   $0x61,-0xdd(%rbp)
movb   $0x79,-0xdc(%rbp)
movb   $0x32,-0xdb(%rbp)
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0xe8(%rbp)
cmpl   $0x5,-0xe8(%rbp)
jae    126a <str_manip_main+0x11a>
mov    $0x0,%al
call   1050 <print_options_str_manip@plt>
lea    0xe11(%rip),%rdi
lea    -0xe4(%rbp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
cmp    -0xe4(%rbp),%eax
jne    121c <str_manip_main+0xcc>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126a <str_manip_main+0x11a>
mov    -0xe4(%rbp),%eax
sub    $0x1,%eax
jne    1257 <str_manip_main+0x107>
jmp    1230 <str_manip_main+0xe0>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <My_strcat@plt>
lea    -0x70(%rbp),%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1265 <str_manip_main+0x115>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <str_manip_main+0x84>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_manip_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movl   $0x0,0xe0(%rsp)
movl   $0x61727261,0x80(%rsp)
61 72 72 61
movw   $0x3179,0x84(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x70(%rsp)
movl   $0x61727261,0x10(%rsp)
61
movw   $0x3279,0x14(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe08(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0x80(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xdf2(%rip),%r13
lea    0xe10(%rip),%rbp
jmp    1238 <str_manip_main+0xe8>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <My_strcat@plt>
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <print_options_str_manip@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     1220 <str_manip_main+0xd0>
test   %eax,%eax
je     1263 <str_manip_main+0x113>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1238 <str_manip_main+0xe8>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [62 x i8] c"Hope you enjoyed learning \22string manipulation\22, Goodbye!!!\0D\0A\00"
@.str.2 = [37 x i8] c"\0D\0AYour concatinated string is \22%s\22\0D\0A\00"
@.str.3 = [69 x i8] c"Wrong option!!!!\0D\0AWhat concept would you like to learn? Try again!!!\00"
define void @str_manip_main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [100 x i8]* %1 to i8*
%6 = bitcast i8* %5 to [100 x i8]*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 0
store i8 97, i8* %7
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 1
store i8 114, i8* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 2
store i8 114, i8* %9
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 3
store i8 97, i8* %10
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 4
store i8 121, i8* %11
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 5
store i8 49, i8* %12
%13 = bitcast [100 x i8]* %2 to i8*
%14 = bitcast i8* %13 to [100 x i8]*
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i32 0, i32 0
store i8 97, i8* %15
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i32 0, i32 1
store i8 114, i8* %16
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i32 0, i32 2
store i8 114, i8* %17
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i32 0, i32 3
store i8 97, i8* %18
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i32 0, i32 4
store i8 121, i8* %19
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i32 0, i32 5
store i8 50, i8* %20
store i32 0, i32* %3
store i32 0, i32* %4
br label %21
21: ; preds = %41, %0
%22 = load i32, i32* %4
%23 = icmp ult i32 %22, 5
br i1 %23, label %24, label %42
24: ; preds = %21
%25 = call i32 (...) @print_options_str_manip()
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%27 = load i32, i32* %3
%28 = icmp eq i32 0, %27
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
br label %42
31: ; preds = %24
%32 = load i32, i32* %3
switch i32 %32, label %39 [
i32 1, label %33
]
33: ; preds = %31
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%36 = call i32 @My_strcat(i8* %34, i8* %35)
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %41
39: ; preds = %31
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %33
br label %21
42: ; preds = %29, %21
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"\0D\0AYour concatinated string is \22%s\22\0D\0A\00"
@.str.3 = [69 x i8] c"Wrong option!!!!\0D\0AWhat concept would you like to learn? Try again!!!\00"
@str = [61 x i8] c"Hope you enjoyed learning \22string manipulation\22, Goodbye!!!\0D\00"
define void @str_manip_main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
store i8 97, i8* %4
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 1
store i8 114, i8* %5
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 2
store i8 114, i8* %6
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 3
store i8 97, i8* %7
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 4
store i8 121, i8* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 5
store i8 49, i8* %9
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8 97, i8* %10
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 1
store i8 114, i8* %11
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 2
store i8 114, i8* %12
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 3
store i8 97, i8* %13
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 4
store i8 121, i8* %14
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 5
store i8 50, i8* %15
%16 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %17
17: ; preds = %28, %0
%18 = call i32 (...) @print_options_str_manip()
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %3
switch i32 %20, label %26 [
i32 0, label %21
i32 1, label %23
]
21: ; preds = %17
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
ret void
23: ; preds = %17
%24 = call i32 @My_strcat(i8* %4, i8* %10)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %28
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
br label %17
}