#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fun1();
int /*<<< orphan*/ fun2();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int ans = -1;
  do {
    ans = -1;
    system("cls");
    printf("*************\n");
    printf("* Main Menu *\n");
    printf("*************\n");
    printf("0-Exit\n");
    printf("1-Addition\n");
    printf("2-Subtraction\n");
    printf("Choose your answer (0,1,2):  ");
    scanf("%d", &ans);
    switch (ans) {
    case 0:
      exit(0);
    case 1:
      fun1();
      break;
    case 2:
      fun2();
      break;
    default:
      printf("Error! you must choose (0 or 1 or 2)!\n");
    }
  } while (ans != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    0xe7c(%rip),%rdi
call   1040 <system@plt>
lea    0xe74(%rip),%rdi
mov    %rdi,-0x18(%rbp)
call   1050 <printf@plt>
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <printf@plt>
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     1223 <main+0xc3>
jmp    1201 <main+0xa1>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     122a <main+0xca>
jmp    1212 <main+0xb2>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1236 <main+0xd6>
jmp    1242 <main+0xe2>
xor    %edi,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1060 <fun1@plt>
jmp    124e <main+0xee>
mov    $0x0,%al
call   1030 <fun2@plt>
jmp    124e <main+0xee>
lea    0xe1d(%rip),%rdi
call   1050 <printf@plt>
jmp    1253 <main+0xf3>
cmpl   $0x0,-0x8(%rbp)
jne    1176 <main+0x16>
xor    %eax,%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    0xeb1(%rip),%rbx
lea    0xebf(%rip),%r13
lea    0xec3(%rip),%rbp
lea    0xe6d(%rip),%r14
lea    0xe84(%rip),%r15
lea    0x4(%rsp),%r12
jmp    11c2 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <fun2@plt>
cmpl   $0x0,0x4(%rsp)
je     125c <main+0xec>
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xe2f(%rip),%rdi
call   1050 <system@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe48(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     1250 <main+0xe0>
cmp    $0x2,%eax
je     11b0 <main+0x40>
test   %eax,%eax
je     126d <main+0xfd>
lea    0xe27(%rip),%rdi
call   1040 <puts@plt>
jmp    11b7 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <fun1@plt>
jmp    11b7 <main+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [15 x i8] c"*************\0A\00"
@.str.2 = [15 x i8] c"* Main Menu *\0A\00"
@.str.3 = [8 x i8] c"0-Exit\0A\00"
@.str.4 = [12 x i8] c"1-Addition\0A\00"
@.str.5 = [15 x i8] c"2-Subtraction\0A\00"
@.str.6 = [30 x i8] c"Choose your answer (0,1,2): \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [39 x i8] c"Error! you must choose (0 or 1 or 2)!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
br label %3
3: ; preds = %23, %0
store i32 -1, i32* %2
%4 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 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* %2)
%13 = load i32, i32* %2
switch i32 %13, label %20 [
i32 0, label %14
i32 1, label %16
i32 2, label %18
]
14: ; preds = %3
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %3
%17 = call i32 (...) @fun1()
br label %22
18: ; preds = %3
%19 = call i32 (...) @fun2()
br label %22
20: ; preds = %3
%21 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %22
22: ; preds = %20, %18, %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 0
br i1 %25, label %3, label %26
26: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.6 = [30 x i8] c"Choose your answer (0,1,2): \00"
@.str.7 = [3 x i8] c"%d\00"
@str.9 = [14 x i8] c"* Main Menu *\00"
@str.10 = [14 x i8] c"*************\00"
@str.11 = [7 x i8] c"0-Exit\00"
@str.12 = [11 x i8] c"1-Addition\00"
@str.13 = [14 x i8] c"2-Subtraction\00"
@str.14 = [38 x i8] c"Error! you must choose (0 or 1 or 2)!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %22, %0
store i32 -1, i32* %1
%4 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.11, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.13, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 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 = load i32, i32* %1
switch i32 %13, label %20 [
i32 0, label %14
i32 1, label %16
i32 2, label %18
]
14: ; preds = %3
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %3
%17 = call i32 (...) @fun1()
br label %22
18: ; preds = %3
%19 = call i32 (...) @fun2()
br label %22
20: ; preds = %3
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.14, i64 0, i64 0))
br label %22
22: ; preds = %16, %18, %20
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %3
25: ; preds = %22
ret i32 0
}