#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 cntDigits(int);
int cntOddDigits(int);
int /*<<< orphan*/ printf(char *, ...);
int revDigits(int);
int /*<<< orphan*/ scanf(char *, ...);
int sumOfDigits(int);
main() {
  int data, flag = 0, s, r, c, d;
  char choice;
  while (1) {
    printf("MENU: \ni:> Input integer\n");
    printf("s:> Sum of digit\n");
    printf("r:> reverse digit\n");
    printf("c:> count digit\n");
    printf("o:> no. of odd digits\n");
    printf("q:> quit\n");
    scanf("%c", &choice);
    if (choice == 'i') {
      flag = 1;
    Input:
      printf("Enter number: \n");
      scanf("%d", &data);
    }
    printf("enter choice :\n");
    scanf(" %c", &choice);
    if (flag = 0) {
      printf("No data supplied");
      goto Input;
    }
    if (choice == 's') {
      s = sumOfDigits(data);
      printf("The sum of digits is: %d\n", s);
    } else if (choice == 'r') {
      r = revDigits(data);
      printf("Reversed digits is: %d\n", r);
    } else if (choice == 'c') {
      c = cntDigits(data);
      printf("Digit count is: %d\n", c);
    } else if (choice == 'o') {
      d = cntOddDigits(data);
      printf("No. of odd digits is: %d\n", d);
    } else if (choice == 'q') {
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x1d(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x69,%eax
jne    1210 <main+0xb0>
movl   $0x1,-0xc(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    -0x1d(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    1246 <main+0xe6>
jmp    1259 <main+0xf9>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f0 <main+0x90>
movsbl -0x1d(%rbp),%eax
cmp    $0x73,%eax
jne    1287 <main+0x127>
mov    -0x8(%rbp),%edi
call   1030 <sumOfDigits@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    133a <main+0x1da>
movsbl -0x1d(%rbp),%eax
cmp    $0x72,%eax
jne    12b5 <main+0x155>
mov    -0x8(%rbp),%edi
call   1080 <revDigits@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1335 <main+0x1d5>
movsbl -0x1d(%rbp),%eax
cmp    $0x63,%eax
jne    12e3 <main+0x183>
mov    -0x8(%rbp),%edi
call   1040 <cntDigits@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1330 <main+0x1d0>
movsbl -0x1d(%rbp),%eax
cmp    $0x6f,%eax
jne    1311 <main+0x1b1>
mov    -0x8(%rbp),%edi
call   1060 <cntOddDigits@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    132b <main+0x1cb>
movsbl -0x1d(%rbp),%eax
cmp    $0x71,%eax
jne    1326 <main+0x1c6>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    132b <main+0x1cb>
jmp    1330 <main+0x1d0>
jmp    1335 <main+0x1d5>
jmp    133a <main+0x1da>
jmp    1176 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf8b(%rip),%rbp
lea    0xebf(%rip),%r14
lea    0x3(%rsp),%r15
lea    0xf81(%rip),%r12
lea    0xeab(%rip),%r13
lea    0xe5d(%rip),%rbx
jmp    11be <main+0x4e>
mov    0x4(%rsp),%edi
call   1040 <sumOfDigits@plt>
lea    0xe96(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmpb   $0x69,0x3(%rsp)
jne    1235 <main+0xc5>
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1b(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
movzbl 0x3(%rsp),%eax
add    $0x9d,%al
cmp    $0x10,%al
ja     11be <main+0x4e>
movzbl %al,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    0x4(%rsp),%edi
call   1050 <cntDigits@plt>
lea    0xe08(%rip),%rdi
jmp    11b5 <main+0x45>
mov    0x4(%rsp),%edi
call   1070 <cntOddDigits@plt>
lea    0xe07(%rip),%rdi
jmp    11b5 <main+0x45>
mov    0x4(%rsp),%edi
call   1090 <revDigits@plt>
lea    0xdc6(%rip),%rdi
jmp    11b5 <main+0x45>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"MENU: \0Ai:> Input integer\0A\00"
@.str.1 = [18 x i8] c"s:> Sum of digit\0A\00"
@.str.2 = [19 x i8] c"r:> reverse digit\0A\00"
@.str.3 = [17 x i8] c"c:> count digit\0A\00"
@.str.4 = [23 x i8] c"o:> no. of odd digits\0A\00"
@.str.5 = [10 x i8] c"q:> quit\0A\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [16 x i8] c"Enter number: \0A\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [16 x i8] c"enter choice :\0A\00"
@.str.10 = [4 x i8] c" %c\00"
@.str.11 = [17 x i8] c"No data supplied\00"
@.str.12 = [26 x i8] c"The sum of digits is: %d\0A\00"
@.str.13 = [24 x i8] c"Reversed digits is: %d\0A\00"
@.str.14 = [20 x i8] c"Digit count is: %d\0A\00"
@.str.15 = [26 x i8] c"No. of odd digits is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %3
br label %9
9: ; preds = %0, %74
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%17 = load i8, i8* %8
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 105
br i1 %19, label %20, label %24
20: ; preds = %9
store i32 1, i32* %3
br label %21
21: ; preds = %27, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
br label %24
24: ; preds = %21, %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %8)
store i32 0, i32* %3
br i1 false, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
br label %21
29: ; preds = %24
%30 = load i8, i8* %8
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 115
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i32, i32* %2
%35 = call i32 @sumOfDigits(i32 %34)
store i32 %35, i32* %4
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0), i32 %36)
br label %74
38: ; preds = %29
%39 = load i8, i8* %8
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 114
br i1 %41, label %42, label %47
42: ; preds = %38
%43 = load i32, i32* %2
%44 = call i32 @revDigits(i32 %43)
store i32 %44, i32* %5
%45 = load i32, i32* %5
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i32 %45)
br label %73
47: ; preds = %38
%48 = load i8, i8* %8
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 99
br i1 %50, label %51, label %56
51: ; preds = %47
%52 = load i32, i32* %2
%53 = call i32 @cntDigits(i32 %52)
store i32 %53, i32* %6
%54 = load i32, i32* %6
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i32 %54)
br label %72
56: ; preds = %47
%57 = load i8, i8* %8
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 111
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = load i32, i32* %2
%62 = call i32 @cntOddDigits(i32 %61)
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i32 %63)
br label %71
65: ; preds = %56
%66 = load i8, i8* %8
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 113
br i1 %68, label %69, label %70
69: ; preds = %65
ret i32 0
70: ; preds = %65
br label %71
71: ; preds = %70, %60
br label %72
72: ; preds = %71, %51
br label %73
73: ; preds = %72, %42
br label %74
74: ; preds = %73, %33
br label %9
}

LLVM IR (-O2):
@.str.6 = [3 x i8] c"%c\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.10 = [4 x i8] c" %c\00"
@.str.12 = [26 x i8] c"The sum of digits is: %d\0A\00"
@.str.13 = [24 x i8] c"Reversed digits is: %d\0A\00"
@.str.14 = [20 x i8] c"Digit count is: %d\0A\00"
@.str.15 = [26 x i8] c"No. of odd digits is: %d\0A\00"
@str = [25 x i8] c"MENU: \0Ai:> Input integer\00"
@str.16 = [17 x i8] c"s:> Sum of digit\00"
@str.17 = [18 x i8] c"r:> reverse digit\00"
@str.18 = [16 x i8] c"c:> count digit\00"
@str.19 = [22 x i8] c"o:> no. of odd digits\00"
@str.20 = [9 x i8] c"q:> quit\00"
@str.21 = [15 x i8] c"enter choice :\00"
@str.22 = [15 x i8] c"Enter number: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
br label %4
4: ; preds = %21, %0
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.17, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.18, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.19, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.20, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%12 = load i8, i8* %2
%13 = icmp eq i8 %12, 105
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.22, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
br label %17
17: ; preds = %14, %4
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.21, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %2)
%20 = load i8, i8* %2
switch i8 %20, label %21 [
i8 115, label %22
i8 114, label %26
i8 99, label %30
i8 111, label %34
i8 113, label %38
]
21: ; preds = %17, %26, %34, %30, %22
br label %4
22: ; preds = %17
%23 = load i32, i32* %1
%24 = call i32 @sumOfDigits(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0), i32 %24)
br label %21
26: ; preds = %17
%27 = load i32, i32* %1
%28 = call i32 @revDigits(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i32 %28)
br label %21
30: ; preds = %17
%31 = load i32, i32* %1
%32 = call i32 @cntDigits(i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i32 %32)
br label %21
34: ; preds = %17
%35 = load i32, i32* %1
%36 = call i32 @cntOddDigits(i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i32 %36)
br label %21
38: ; preds = %17
ret i32 0
}