#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ palindrome(char *);
int /*<<< orphan*/ prime(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ sum(int);
int main() {
  int n;
  char string[100], option;
  do {
    printf("\n\nPlease Choose the following option:\n");
    printf("a) Check whether given string is palindrome or not\n");
    printf("b) Find all the prime numbers from 100 to 200\n");
    printf("c) Sum of n natural numbers\n");
    printf("d) Exit from program\n");
    printf("Enter option: ");
    scanf("%c", &option);
    switch (option) {
    case 'a':
      printf("Enter string: ");
      scanf("%s", string);
      palindrome(string);
      break;
    case 'b':
      prime(100, 200);
      break;
    case 'c':
      printf("Enter number: ");
      scanf("%d", &n);
      sum(n);
    case 'd':
      break;
    default:
      printf("Please enter correct option\n");
    }
    fflush(stdin);
  } while (option != 'd');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf18(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1b(%rip),%rdi
xor    %eax,%eax
lea    -0x71(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x71(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x80(%rbp)
sub    $0x3,%eax
ja     1261 <main+0x101>
mov    -0x80(%rbp),%rax
lea    0xe13(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <palindrome@plt>
jmp    126d <main+0x10d>
mov    $0x64,%edi
mov    $0xc8,%esi
call   1080 <prime@plt>
jmp    126d <main+0x10d>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1050 <sum@plt>
jmp    126d <main+0x10d>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
movsbl -0x71(%rbp),%eax
cmp    $0x64,%eax
jne    1172 <main+0x12>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe8b(%rip),%r14
lea    0xe93(%rip),%r12
lea    0xb(%rsp),%r13
mov    0x2e50(%rip),%r15
lea    0xe61(%rip),%rbp
jmp    11d3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax)
mov    (%r15),%edi
call   1070 <fflush@plt>
cmpb   $0x64,0xb(%rsp)
je     12bd <main+0x14d>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
movsbl 0xb(%rsp),%eax
add    $0xffffff9f,%eax
cmp    $0x3,%eax
ja     11b0 <main+0x40>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
lea    0xddf(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <palindrome@plt>
jmp    11c0 <main+0x50>
xchg   %ax,%ax
mov    $0x64,%edi
mov    $0xc8,%esi
call   1090 <prime@plt>
jmp    11c0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xd9d(%rip),%rdi
call   1040 <printf@plt>
lea    0xda0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
call   1060 <sum@plt>
jmp    11c0 <main+0x50>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"\0A\0APlease Choose the following option:\0A\00"
@.str.1 = [52 x i8] c"a) Check whether given string is palindrome or not\0A\00"
@.str.2 = [47 x i8] c"b) Find all the prime numbers from 100 to 200\0A\00"
@.str.3 = [29 x i8] c"c) Sum of n natural numbers\0A\00"
@.str.4 = [22 x i8] c"d) Exit from program\0A\00"
@.str.5 = [15 x i8] c"Enter option: \00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [15 x i8] c"Enter string: \00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [15 x i8] c"Enter number: \00"
@.str.10 = [3 x i8] c"%d\00"
@.str.11 = [29 x i8] c"Please enter correct option\0A\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i8
store i32 0, i32* %1
br label %5
5: ; preds = %34, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
switch i32 %14, label %29 [
i32 97, label %15
i32 98, label %21
i32 99, label %23
i32 100, label %28
]
15: ; preds = %5
%16 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 @palindrome(i8* %19)
br label %31
21: ; preds = %5
%22 = call i32 @prime(i32 100, i32 200)
br label %31
23: ; preds = %5
%24 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %2)
%26 = load i32, i32* %2
%27 = call i32 @sum(i32 %26)
br label %28
28: ; preds = %5, %23
br label %31
29: ; preds = %5
%30 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
br label %31
31: ; preds = %29, %28, %21, %15
%32 = load i32, i32* @stdin
%33 = call i32 @fflush(i32 %32)
br label %34
34: ; preds = %31
%35 = load i8, i8* %4
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 100
br i1 %37, label %5, label %38
38: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [15 x i8] c"Enter option: \00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [15 x i8] c"Enter string: \00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [15 x i8] c"Enter number: \00"
@.str.10 = [3 x i8] c"%d\00"
@stdin = global i32 0
@str = [38 x i8] c"\0A\0APlease Choose the following option:\00"
@str.12 = [51 x i8] c"a) Check whether given string is palindrome or not\00"
@str.13 = [46 x i8] c"b) Find all the prime numbers from 100 to 200\00"
@str.14 = [28 x i8] c"c) Sum of n natural numbers\00"
@str.15 = [21 x i8] c"d) Exit from program\00"
@str.16 = [28 x i8] c"Please enter correct option\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
br label %6
6: ; preds = %29, %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.13, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.14, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.15, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
switch i32 %15, label %27 [
i32 97, label %16
i32 98, label %20
i32 99, label %22
i32 100, label %29
]
16: ; preds = %6
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %5)
%19 = call i32 @palindrome(i8* %5)
br label %29
20: ; preds = %6
%21 = call i32 @prime(i32 100, i32 200)
br label %29
22: ; preds = %6
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %1)
%25 = load i32, i32* %1
%26 = call i32 @sum(i32 %25)
br label %29
27: ; preds = %6
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.16, i64 0, i64 0))
br label %29
29: ; preds = %27, %22, %6, %20, %16
%30 = load i32, i32* @stdin
%31 = call i32 @fflush(i32 %30)
%32 = load i8, i8* %3
%33 = icmp eq i8 %32, 100
br i1 %33, label %34, label %6
34: ; preds = %29
ret i32 0
}