#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*/ copy();
int /*<<< orphan*/ create();
int /*<<< orphan*/ display1();
int /*<<< orphan*/ display2();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ reverse();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ split();
int main() {
  int opt;
  int ch;
  do {
    printf("\n**********************");
    printf("\n1. Create ");
    printf("\n2. reverse");
    printf("\n3. split ");
    printf("\n4. concatenate ");
    printf("\n5. copy");
    printf("\n**********************");
    printf("\nEnter choice : ");
    scanf("%d", &opt);
    printf("\n");
    switch (opt) {
    case 1:
      create();
      display1();
      break;
    case 2:
      printf("original : \n");
      display1();
      reverse();
      printf("\nreversed : \n");
      display2();
      break;
    case 3:
      printf("original : \n");
      display1();
      split();
      printf("\nSplit 1 : \n");
      display1();
      printf("\nSplit 2 : \n");
      display2();
      break;
    case 4:
      break;
    case 5:
      printf("original : \n");
      display1();
      copy();
      printf("\nCopied : \n");
      display2();
      break;
    }
  } while (opt != 6);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7e(%rip),%rdi
mov    %rdi,-0x20(%rbp)
call   1040 <printf@plt>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     12f1 <main+0x171>
mov    -0x18(%rbp),%rax
lea    0xdd4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <create@plt>
mov    $0x0,%al
call   10a0 <display1@plt>
jmp    12f1 <main+0x171>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <display1@plt>
mov    $0x0,%al
call   1030 <reverse@plt>
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <display2@plt>
jmp    12f1 <main+0x171>
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <display1@plt>
mov    $0x0,%al
call   1060 <split@plt>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <display1@plt>
lea    0xdf7(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <display2@plt>
jmp    12f1 <main+0x171>
jmp    12f1 <main+0x171>
lea    0xdb2(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <display1@plt>
mov    $0x0,%al
call   1070 <copy@plt>
lea    0xdcd(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <display2@plt>
jmp    12f6 <main+0x176>
cmpl   $0x6,-0x8(%rbp)
jne    118f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe62(%rip),%rbx
lea    0xea7(%rip),%rbp
lea    0xea9(%rip),%r14
lea    0xeb3(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe2d(%rip),%r13
jmp    121a <main+0x7a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xeb9(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10c0 <display1@plt>
xor    %eax,%eax
call   1090 <copy@plt>
lea    0xe7c(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <display2@plt>
mov    0x4(%rsp),%eax
cmp    $0x6,%eax
je     1319 <main+0x179>
mov    %rbx,%rdi
call   1060 <printf@plt>
lea    0xe03(%rip),%rdi
call   1060 <printf@plt>
lea    0xe03(%rip),%rdi
call   1060 <printf@plt>
lea    0xe03(%rip),%rdi
call   1060 <printf@plt>
lea    0xe02(%rip),%rdi
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x4,%ecx
ja     1211 <main+0x71>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
xor    %eax,%eax
call   10a0 <create@plt>
xor    %eax,%eax
call   10c0 <display1@plt>
jmp    120d <main+0x6d>
nopl   0x0(%rax,%rax,1)
lea    0xde9(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10c0 <display1@plt>
xor    %eax,%eax
call   1030 <reverse@plt>
lea    0xddb(%rip),%rdi
jmp    1201 <main+0x61>
cs nopw 0x0(%rax,%rax,1)
lea    0xdb9(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10c0 <display1@plt>
xor    %eax,%eax
call   1080 <split@plt>
lea    0xd87(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10c0 <display1@plt>
lea    0xd80(%rip),%rdi
jmp    1201 <main+0x61>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0A**********************\00"
@.str.1 = [12 x i8] c"\0A1. Create \00"
@.str.2 = [12 x i8] c"\0A2. reverse\00"
@.str.3 = [11 x i8] c"\0A3. split \00"
@.str.4 = [17 x i8] c"\0A4. concatenate \00"
@.str.5 = [9 x i8] c"\0A5. copy\00"
@.str.6 = [17 x i8] c"\0AEnter choice : \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [13 x i8] c"original : \0A\00"
@.str.10 = [14 x i8] c"\0Areversed : \0A\00"
@.str.11 = [13 x i8] c"\0ASplit 1 : \0A\00"
@.str.12 = [13 x i8] c"\0ASplit 2 : \0A\00"
@.str.13 = [12 x i8] c"\0ACopied : \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %41, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%15 = load i32, i32* %2
switch i32 %15, label %40 [
i32 1, label %16
i32 2, label %19
i32 3, label %25
i32 4, label %33
i32 5, label %34
]
16: ; preds = %4
%17 = call i32 (...) @create()
%18 = call i32 (...) @display1()
br label %40
19: ; preds = %4
%20 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%21 = call i32 (...) @display1()
%22 = call i32 (...) @reverse()
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%24 = call i32 (...) @display2()
br label %40
25: ; preds = %4
%26 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%27 = call i32 (...) @display1()
%28 = call i32 (...) @split()
%29 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%30 = call i32 (...) @display1()
%31 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%32 = call i32 (...) @display2()
br label %40
33: ; preds = %4
br label %40
34: ; preds = %4
%35 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%36 = call i32 (...) @display1()
%37 = call i32 (...) @copy()
%38 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%39 = call i32 (...) @display2()
br label %40
40: ; preds = %4, %34, %33, %25, %19, %16
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = icmp ne i32 %42, 6
br i1 %43, label %4, label %44
44: ; preds = %41
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str = [24 x i8] c"\0A**********************\00"
@.str.1 = [12 x i8] c"\0A1. Create \00"
@.str.2 = [12 x i8] c"\0A2. reverse\00"
@.str.3 = [11 x i8] c"\0A3. split \00"
@.str.4 = [17 x i8] c"\0A4. concatenate \00"
@.str.5 = [9 x i8] c"\0A5. copy\00"
@.str.6 = [17 x i8] c"\0AEnter choice : \00"
@.str.7 = [3 x i8] c"%d\00"
@str.14 = [11 x i8] c"\0ACopied : \00"
@str.16 = [12 x i8] c"\0ASplit 1 : \00"
@str.17 = [12 x i8] c"\0ASplit 2 : \00"
@str.18 = [12 x i8] c"original : \00"
@str.19 = [13 x i8] c"\0Areversed : \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %40, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%13 = call i32 @putchar(i32 10)
%14 = load i32, i32* %1
switch i32 %14, label %40 [
i32 1, label %15
i32 2, label %18
i32 3, label %24
i32 5, label %32
]
15: ; preds = %3
%16 = call i32 (...) @create()
%17 = call i32 (...) @display1()
br label %38
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
%20 = call i32 (...) @display1()
%21 = call i32 (...) @reverse()
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.19, i64 0, i64 0))
%23 = call i32 (...) @display2()
br label %38
24: ; preds = %3
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
%26 = call i32 (...) @display1()
%27 = call i32 (...) @split()
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.16, i64 0, i64 0))
%29 = call i32 (...) @display1()
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.17, i64 0, i64 0))
%31 = call i32 (...) @display2()
br label %38
32: ; preds = %3
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
%34 = call i32 (...) @display1()
%35 = call i32 (...) @copy()
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0))
%37 = call i32 (...) @display2()
br label %38
38: ; preds = %32, %24, %18, %15
%39 = load i32, i32* %1
br label %40
40: ; preds = %38, %3
%41 = phi i32 [ %39, %38 ], [ %14, %3 ]
%42 = icmp eq i32 %41, 6
br i1 %42, label %43, label %3
43: ; preds = %40
ret i32 0
}