#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*/ isPalindrome(int);
int no_of_digits(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ puts(char *);
int reverse(int);
int /*<<< orphan*/ reverse_original(int *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice, no;
  int i = 1;
  while (i == 1) {
    puts("\nEnter a number:");
    scanf("%d", &no);
    puts("Enter 1 to print the no of digits,2 to reverse the no using pass by "
         "value,3 to reverse no using pass by reference and 4 to check if "
         "entered no is pallindrome or not");
    puts("Enter a menu indice:");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("The no of digits in %d is %d \n", no, no_of_digits(no));
      break;
    case 2: {
      printf("The original no is: %d \n", no);
      printf("The reversed no is %d", reverse(no));
      break;
    }
    case 3: {
      printf("The original no is %d \n", no);
      reverse_original(&no);
      printf("The reversed no is %d", no);
      break;
    }
    case 0: {
      puts("Program terminates");
      i = 2;
      break;
    }
    case 4:
      isPalindrome(no);
      break;
    default:
      puts("Im sorry I dont understand you:");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    12b4 <main+0x144>
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf87(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xf07(%rip),%rdi
call   1040 <puts@plt>
mov    -0x20(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     12a3 <main+0x133>
mov    -0x18(%rbp),%rax
lea    0xe0f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <no_of_digits@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12af <main+0x13f>
mov    -0xc(%rbp),%esi
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1030 <reverse@plt>
mov    %eax,%esi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12af <main+0x13f>
mov    -0xc(%rbp),%esi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xc(%rbp),%rdi
call   1060 <reverse_original@plt>
mov    -0xc(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12af <main+0x13f>
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
movl   $0x2,-0x10(%rbp)
jmp    12af <main+0x13f>
mov    -0xc(%rbp),%edi
call   1080 <isPalindrome@plt>
jmp    12af <main+0x13f>
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
jmp    1186 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe92(%rip),%rbp
lea    0xfa1(%rip),%r13
mov    %rsp,%r15
lea    0xe92(%rip),%rbx
lea    0xf30(%rip),%r14
lea    0x4(%rsp),%r12
jmp    11b0 <main+0x40>
mov    (%rsp),%edi
call   1080 <isPalindrome@plt>
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x4,%rax
ja     1235 <main+0xc5>
lea    0xe11(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r12,%r13
mov    %r15,%r12
mov    %r14,%r15
mov    (%rsp),%r14d
mov    %r14d,%edi
call   1070 <no_of_digits@plt>
lea    0xecb(%rip),%rdi
mov    %r14d,%esi
mov    %r15,%r14
mov    %r12,%r15
mov    %r13,%r12
lea    0xf03(%rip),%r13
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b0 <main+0x40>
lea    0xf1c(%rip),%rdi
call   1040 <puts@plt>
jmp    11b0 <main+0x40>
mov    (%rsp),%esi
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%edi
call   1030 <reverse@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
jmp    128d <main+0x11d>
mov    (%rsp),%esi
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1060 <reverse_original@plt>
mov    (%rsp),%esi
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b0 <main+0x40>
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0AEnter a number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [165 x i8] c"Enter 1 to print the no of digits,2 to reverse the no using pass by value,3 to reverse no using pass by reference and 4 to check if entered no is pallindrome or not\00"
@.str.3 = [21 x i8] c"Enter a menu indice:\00"
@.str.4 = [31 x i8] c"The no of digits in %d is %d \0A\00"
@.str.5 = [25 x i8] c"The original no is: %d \0A\00"
@.str.6 = [22 x i8] c"The reversed no is %d\00"
@.str.7 = [24 x i8] c"The original no is %d \0A\00"
@.str.8 = [19 x i8] c"Program terminates\00"
@.str.9 = [32 x i8] c"Im sorry I dont understand you:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
br label %5
5: ; preds = %39, %0
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %40
8: ; preds = %5
%9 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 @puts(i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
switch i32 %14, label %37 [
i32 1, label %15
i32 2, label %20
i32 3, label %26
i32 0, label %32
i32 4, label %34
]
15: ; preds = %8
%16 = load i32, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @no_of_digits(i32 %17)
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 %18)
br label %39
20: ; preds = %8
%21 = load i32, i32* %3
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %3
%24 = call i32 @reverse(i32 %23)
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %24)
br label %39
26: ; preds = %8
%27 = load i32, i32* %3
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %27)
%29 = call i32 @reverse_original(i32* %3)
%30 = load i32, i32* %3
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %30)
br label %39
32: ; preds = %8
%33 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
store i32 2, i32* %4
br label %39
34: ; preds = %8
%35 = load i32, i32* %3
%36 = call i32 @isPalindrome(i32 %35)
br label %39
37: ; preds = %8
%38 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %39
39: ; preds = %37, %34, %32, %26, %20, %15
br label %5
40: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0AEnter a number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [165 x i8] c"Enter 1 to print the no of digits,2 to reverse the no using pass by value,3 to reverse no using pass by reference and 4 to check if entered no is pallindrome or not\00"
@.str.3 = [21 x i8] c"Enter a menu indice:\00"
@.str.4 = [31 x i8] c"The no of digits in %d is %d \0A\00"
@.str.5 = [25 x i8] c"The original no is: %d \0A\00"
@.str.6 = [22 x i8] c"The reversed no is %d\00"
@.str.7 = [24 x i8] c"The original no is %d \0A\00"
@.str.8 = [19 x i8] c"Program terminates\00"
@.str.9 = [32 x i8] c"Im sorry I dont understand you:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %33, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([165 x i8], [165 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %31 [
i32 1, label %12
i32 2, label %16
i32 3, label %22
i32 0, label %34
i32 4, label %28
]
12: ; preds = %5
%13 = load i32, i32* %2
%14 = call i32 @no_of_digits(i32 %13)
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 %14)
br label %33
16: ; preds = %5
%17 = load i32, i32* %2
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = call i32 @reverse(i32 %19)
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %20)
br label %33
22: ; preds = %5
%23 = load i32, i32* %2
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %23)
%25 = call i32 @reverse_original(i32* %2)
%26 = load i32, i32* %2
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %26)
br label %33
28: ; preds = %5
%29 = load i32, i32* %2
%30 = call i32 @isPalindrome(i32 %29)
br label %33
31: ; preds = %5
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %33
33: ; preds = %31, %28, %22, %16, %12
br label %5
34: ; preds = %5
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}