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


x86 assembly (clang, -O0):
<fun2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
movl   $0xffffffff,-0x4(%rbp)
lea    0xe83(%rip),%rdi
call   1040 <system@plt>
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
test   %eax,%eax
je     120f <fun2+0xaf>
jmp    11ed <fun2+0x8d>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
je     1216 <fun2+0xb6>
jmp    11fe <fun2+0x9e>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1222 <fun2+0xc2>
jmp    122e <fun2+0xce>
mov    $0x0,%al
call   1070 <main@plt>
mov    $0x0,%al
call   1060 <fun3@plt>
jmp    123a <fun2+0xda>
mov    $0x0,%al
call   1030 <fun4@plt>
jmp    123a <fun2+0xda>
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
jmp    123f <fun2+0xdf>
cmpl   $0x0,-0x4(%rbp)
jne    116f <fun2+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeb6(%rip),%r13
lea    0xec3(%rip),%rbx
lea    0xec7(%rip),%rbp
lea    0xe6d(%rip),%r14
lea    0xe84(%rip),%r15
lea    0x4(%rsp),%r12
jmp    11c9 <fun2+0x59>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <main@plt>
xor    %eax,%eax
call   1070 <fun3@plt>
cmpl   $0x0,0x4(%rsp)
je     125c <fun2+0xec>
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xe28(%rip),%rdi
call   1050 <system@plt>
lea    0xe41(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3e(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%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   1090 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1250 <fun2+0xe0>
cmp    $0x1,%eax
je     11b7 <fun2+0x47>
test   %eax,%eax
je     11b0 <fun2+0x40>
lea    0xe28(%rip),%rdi
call   1040 <puts@plt>
jmp    11be <fun2+0x4e>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <fun4@plt>
jmp    11be <fun2+0x4e>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [10 x i8] c"Sub Menu\0A\00"
@.str.2 = [11 x i8] c"=========\0A\00"
@.str.3 = [21 x i8] c"0-Exit to Main Menu\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 void @fun2() {
%1 = alloca i32
store i32 -1, i32* %1
br label %2
2: ; preds = %21, %0
store i32 -1, i32* %1
%3 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %18 [
i32 0, label %12
i32 1, label %14
i32 2, label %16
]
12: ; preds = %2
%13 = call i32 (...) @main()
br label %14
14: ; preds = %2, %12
%15 = call i32 (...) @fun3()
br label %20
16: ; preds = %2
%17 = call i32 (...) @fun4()
br label %20
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14
br label %21
21: ; preds = %20
%22 = load i32, i32* %1
%23 = icmp ne i32 %22, 0
br i1 %23, label %2, label %24
24: ; preds = %21
ret void
}

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