#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*/ concat(char *, char *, int);
int /*<<< orphan*/ copy(char *);
int /*<<< orphan*/ pal(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rev(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char s1[100], s2[100];
  int choice, len, ans = 5;
  printf("\nEnter string s1: ");
  scanf("%s", s1);
  for (len = 0; s1[len] != '\0'; ++len)
    ;
  printf("Length of string: %d\n", len);
  while (ans == 5) {
    printf("\n1) To copy a string");
    printf("\n2) To reverse a string");
    printf("\n3) To find whether it is palindrome or not");
    printf("\n4) To concatenate two strings");
    printf("\nEnter 1,2,3 or 4: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      copy(s1);
      break;
    case 2:
      rev(s1, len);
      break;
    case 3:
      pal(s1, len);
      break;
    case 4:
      printf("Enter second string: ");
      scanf("%s", s2);
      concat(s1, s2, len);
      break;
    default:
      printf("\nInvalid Choice");
    }
    printf("\nEnter 5 to continue, else exit: ");
    scanf("%d", &ans);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0xec(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
movl   $0x0,-0xe8(%rbp)
movslq -0xe8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11d4 <main+0x74>
jmp    11c0 <main+0x60>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    11a6 <main+0x46>
mov    -0xe8(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x5,-0xec(%rbp)
jne    1346 <main+0x1e6>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xf9(%rbp)
call   1040 <printf@plt>
mov    -0xf9(%rbp),%al
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xf9(%rbp),%al
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
mov    -0xf9(%rbp),%al
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xf9(%rbp),%al
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
mov    -0xf9(%rbp),%al
lea    0xe6a(%rip),%rdi
lea    -0xe4(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0xe4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0xf8(%rbp)
sub    $0x3,%eax
ja     1310 <main+0x1b0>
mov    -0xf8(%rbp),%rax
lea    0xd6d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x70(%rbp),%rdi
call   1060 <copy@plt>
jmp    131e <main+0x1be>
lea    -0x70(%rbp),%rdi
mov    -0xe8(%rbp),%esi
call   1030 <rev@plt>
jmp    131e <main+0x1be>
lea    -0x70(%rbp),%rdi
mov    -0xe8(%rbp),%esi
call   1070 <pal@plt>
jmp    131e <main+0x1be>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0xe8(%rbp),%edx
call   1050 <concat@plt>
jmp    131e <main+0x1be>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd95(%rip),%rdi
lea    -0xec(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
jmp    11e8 <main+0x88>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
movl   $0x5,0x8(%rsp)
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmpb   $0x0,0x0(%rbp)
lea    0x1(%rbp),%rbp
jne    11b0 <main+0x50>
lea    0xe62(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef4(%rip),%r14
lea    0xc(%rsp),%rbp
lea    0xf11(%rip),%r15
lea    0x8(%rsp),%r13
lea    0xe14(%rip),%r12
jmp    1222 <main+0xc2>
xchg   %ax,%ax
lea    0xeea(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xchg   %ax,%ax
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmpl   $0x5,0x8(%rsp)
jne    1334 <main+0x1d4>
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe24(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11f0 <main+0x90>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0x10(%rsp),%rdi
call   1060 <copy@plt>
jmp    1200 <main+0xa0>
nopl   (%rax)
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1030 <rev@plt>
jmp    1200 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1070 <pal@plt>
jmp    1200 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd2e(%rip),%rdi
mov    %r12,%r14
mov    %r13,%r12
mov    %r15,%r13
lea    0x80(%rsp),%r15
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r13,%r15
mov    %r12,%r13
mov    %r14,%r12
lea    0xda0(%rip),%r14
mov    %ebx,%edx
call   1050 <concat@plt>
jmp    1200 <main+0xa0>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0AEnter string s1: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"Length of string: %d\0A\00"
@.str.3 = [21 x i8] c"\0A1) To copy a string\00"
@.str.4 = [24 x i8] c"\0A2) To reverse a string\00"
@.str.5 = [44 x i8] c"\0A3) To find whether it is palindrome or not\00"
@.str.6 = [31 x i8] c"\0A4) To concatenate two strings\00"
@.str.7 = [20 x i8] c"\0AEnter 1,2,3 or 4: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [22 x i8] c"Enter second string: \00"
@.str.10 = [16 x i8] c"\0AInvalid Choice\00"
@.str.11 = [34 x i8] c"\0AEnter 5 to continue, else exit: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
store i32 0, i32* %5
br label %10
10: ; preds = %18, %0
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %10
br label %18
18: ; preds = %17
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %10
21: ; preds = %10
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %56, %21
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 5
br i1 %26, label %27, label %59
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%34 = load i32, i32* %4
switch i32 %34, label %54 [
i32 1, label %35
i32 2, label %38
i32 3, label %42
i32 4, label %46
]
35: ; preds = %27
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%37 = call i32 @copy(i8* %36)
br label %56
38: ; preds = %27
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%40 = load i32, i32* %5
%41 = call i32 @rev(i8* %39, i32 %40)
br label %56
42: ; preds = %27
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%44 = load i32, i32* %5
%45 = call i32 @pal(i8* %43, i32 %44)
br label %56
46: ; preds = %27
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%49 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %48)
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%52 = load i32, i32* %5
%53 = call i32 @concat(i8* %50, i8* %51, i32 %52)
br label %56
54: ; preds = %27
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %56
56: ; preds = %54, %46, %42, %38, %35
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
%58 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %6)
br label %24
59: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"\0AEnter string s1: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"Length of string: %d\0A\00"
@.str.3 = [21 x i8] c"\0A1) To copy a string\00"
@.str.4 = [24 x i8] c"\0A2) To reverse a string\00"
@.str.5 = [44 x i8] c"\0A3) To find whether it is palindrome or not\00"
@.str.6 = [31 x i8] c"\0A4) To concatenate two strings\00"
@.str.7 = [20 x i8] c"\0AEnter 1,2,3 or 4: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [22 x i8] c"Enter second string: \00"
@.str.10 = [16 x i8] c"\0AInvalid Choice\00"
@.str.11 = [34 x i8] c"\0AEnter 5 to continue, else exit: \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 5, i32* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %11
11: ; preds = %11, %0
%12 = phi i64 [ %16, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = add nuw i64 %12, 1
br i1 %15, label %17, label %11
17: ; preds = %11
%18 = trunc i64 %12 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %40
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%27 = load i32, i32* %3
switch i32 %27, label %38 [
i32 1, label %28
i32 2, label %30
i32 3, label %32
i32 4, label %34
]
28: ; preds = %20
%29 = call i32 @copy(i8* %5)
br label %40
30: ; preds = %20
%31 = call i32 @rev(i8* %5, i32 %18)
br label %40
32: ; preds = %20
%33 = call i32 @pal(i8* %5, i32 %18)
br label %40
34: ; preds = %20
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%37 = call i32 @concat(i8* %5, i8* %6, i32 %18)
br label %40
38: ; preds = %20
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %40
40: ; preds = %38, %34, %32, %30, %28
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 5
br i1 %44, label %20, label %45
45: ; preds = %40
ret i32 0
}