int f_calculate(i) {
  i = 0;
  int a_num;
  printf("ENTER NEW SELECTION : ");
  scanf("%d", &a_num);
  system("cls");
  if (a_num == 1) {
    first_f();
  } else if (a_num == 2) {
    second_f();
  } else if (a_num == 3) {
    third_f();
  } else if (a_num == 4) {
    fourth_f();
  } else if (a_num == 5) {
    fifth_f();
  } else if (a_num == 6) {
    sixth_f();
  } else if (a_num == 7) {
    int show = 0;
    eighth_f(show);
  } else if (a_num == 8) {
    int show = 1;
    eighth_f(show);
  } else if (a_num == 0) {
    printf("Thanks for using this program\n");
    printf("EAP / exercise 1 / theme 4\n");
    i = -1;
  } else {
    printf("\n");
  }
  clear_s();
  return i;
}


x86 assembly (clang, -O0):
<f_calculate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x4(%rbp)
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe40(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   10d0 <scanf@plt>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1060 <system@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1206 <f_calculate+0x56>
mov    $0x0,%al
call   10c0 <first_f@plt>
jmp    131c <f_calculate+0x16c>
cmpl   $0x2,-0x8(%rbp)
jne    121c <f_calculate+0x6c>
mov    $0x0,%al
call   10b0 <second_f@plt>
jmp    1317 <f_calculate+0x167>
cmpl   $0x3,-0x8(%rbp)
jne    1232 <f_calculate+0x82>
mov    $0x0,%al
call   1080 <third_f@plt>
jmp    1312 <f_calculate+0x162>
cmpl   $0x4,-0x8(%rbp)
jne    1248 <f_calculate+0x98>
mov    $0x0,%al
call   1090 <fourth_f@plt>
jmp    130d <f_calculate+0x15d>
cmpl   $0x5,-0x8(%rbp)
jne    125e <f_calculate+0xae>
mov    $0x0,%al
call   1050 <fifth_f@plt>
jmp    1308 <f_calculate+0x158>
cmpl   $0x6,-0x8(%rbp)
jne    1274 <f_calculate+0xc4>
mov    $0x0,%al
call   10a0 <sixth_f@plt>
jmp    1303 <f_calculate+0x153>
cmpl   $0x7,-0x8(%rbp)
jne    1294 <f_calculate+0xe4>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1030 <eighth_f@plt>
jmp    12fe <f_calculate+0x14e>
cmpl   $0x8,-0x8(%rbp)
jne    12b4 <f_calculate+0x104>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x0,%al
call   1030 <eighth_f@plt>
jmp    12f9 <f_calculate+0x149>
cmpl   $0x0,-0x8(%rbp)
jne    12e6 <f_calculate+0x136>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f4 <f_calculate+0x144>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12f9 <f_calculate+0x149>
jmp    12fe <f_calculate+0x14e>
jmp    1303 <f_calculate+0x153>
jmp    1308 <f_calculate+0x158>
jmp    130d <f_calculate+0x15d>
jmp    1312 <f_calculate+0x162>
jmp    1317 <f_calculate+0x167>
jmp    131c <f_calculate+0x16c>
mov    $0x0,%al
call   1040 <clear_s@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_calculate>:
push   %rbx
sub    $0x10,%rsp
lea    0xe48(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe4f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   10f0 <scanf@plt>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1080 <system@plt>
mov    0xc(%rsp),%eax
cmp    $0x8,%rax
ja     123f <f_calculate+0x6f>
lea    0xde9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe1b(%rip),%rdi
call   1060 <puts@plt>
lea    0xe2d(%rip),%rdi
call   1060 <puts@plt>
mov    $0xffffffff,%ebx
jmp    12a1 <f_calculate+0xd1>
mov    $0xa,%edi
call   1050 <putchar@plt>
jmp    12a1 <f_calculate+0xd1>
xor    %ebx,%ebx
xor    %eax,%eax
call   10e0 <first_f@plt>
jmp    12a1 <f_calculate+0xd1>
xor    %ebx,%ebx
xor    %eax,%eax
call   10d0 <second_f@plt>
jmp    12a1 <f_calculate+0xd1>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <third_f@plt>
jmp    12a1 <f_calculate+0xd1>
xor    %ebx,%ebx
xor    %eax,%eax
call   10b0 <fourth_f@plt>
jmp    12a1 <f_calculate+0xd1>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fifth_f@plt>
jmp    12a1 <f_calculate+0xd1>
xor    %ebx,%ebx
xor    %eax,%eax
call   10c0 <sixth_f@plt>
jmp    12a1 <f_calculate+0xd1>
xor    %ebx,%ebx
xor    %edi,%edi
jmp    129a <f_calculate+0xca>
xor    %ebx,%ebx
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <eighth_f@plt>
xor    %eax,%eax
call   1040 <clear_s@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"ENTER NEW SELECTION : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [31 x i8] c"Thanks for using this program\0A\00"
@.str.4 = [28 x i8] c"EAP / exercise 1 / theme 4\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @f_calculate(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 (...) @first_f()
br label %66
13: ; preds = %1
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (...) @second_f()
br label %65
18: ; preds = %13
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 3
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (...) @third_f()
br label %64
23: ; preds = %18
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 4
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (...) @fourth_f()
br label %63
28: ; preds = %23
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 5
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (...) @fifth_f()
br label %62
33: ; preds = %28
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 6
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (...) @sixth_f()
br label %61
38: ; preds = %33
%39 = load i32, i32* %3
%40 = icmp eq i32 %39, 7
br i1 %40, label %41, label %44
41: ; preds = %38
store i32 0, i32* %4
%42 = load i32, i32* %4
%43 = call i32 (i32, ...) bitcast (i32 (...)* @eighth_f to i32 (i32, ...)*)(i32 %42)
br label %60
44: ; preds = %38
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 8
br i1 %46, label %47, label %50
47: ; preds = %44
store i32 1, i32* %5
%48 = load i32, i32* %5
%49 = call i32 (i32, ...) bitcast (i32 (...)* @eighth_f to i32 (i32, ...)*)(i32 %48)
br label %59
50: ; preds = %44
%51 = load i32, i32* %3
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %2
br label %58
56: ; preds = %50
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
br label %59
59: ; preds = %58, %47
br label %60
60: ; preds = %59, %41
br label %61
61: ; preds = %60, %36
br label %62
62: ; preds = %61, %31
br label %63
63: ; preds = %62, %26
br label %64
64: ; preds = %63, %21
br label %65
65: ; preds = %64, %16
br label %66
66: ; preds = %65, %11
%67 = call i32 (...) @clear_s()
%68 = load i32, i32* %2
ret i32 %68
}

LLVM IR (-O2):
@.str = [23 x i8] c"ENTER NEW SELECTION : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"cls\00"
@str = [30 x i8] c"Thanks for using this program\00"
@str.6 = [27 x i8] c"EAP / exercise 1 / theme 4\00"
define i32 @f_calculate(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %2
switch i32 %7, label %27 [
i32 1, label %8
i32 2, label %10
i32 3, label %12
i32 4, label %14
i32 5, label %16
i32 6, label %18
i32 7, label %20
i32 8, label %22
i32 0, label %24
]
8: ; preds = %1
%9 = call i32 (...) @first_f()
br label %29
10: ; preds = %1
%11 = call i32 (...) @second_f()
br label %29
12: ; preds = %1
%13 = call i32 (...) @third_f()
br label %29
14: ; preds = %1
%15 = call i32 (...) @fourth_f()
br label %29
16: ; preds = %1
%17 = call i32 (...) @fifth_f()
br label %29
18: ; preds = %1
%19 = call i32 (...) @sixth_f()
br label %29
20: ; preds = %1
%21 = call i32 (i32, ...) bitcast (i32 (...)* @eighth_f to i32 (i32, ...)*)(i32 0)
br label %29
22: ; preds = %1
%23 = call i32 (i32, ...) bitcast (i32 (...)* @eighth_f to i32 (i32, ...)*)(i32 1)
br label %29
24: ; preds = %1
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
br label %29
27: ; preds = %1
%28 = call i32 @putchar(i32 10)
br label %29
29: ; preds = %10, %14, %18, %22, %27, %24, %20, %16, %12, %8
%30 = phi i32 [ 0, %8 ], [ 0, %10 ], [ 0, %12 ], [ 0, %14 ], [ 0, %16 ], [ 0, %18 ], [ 0, %20 ], [ 0, %22 ], [ -1, %24 ], [ 0, %27 ]
%31 = call i32 (...) @clear_s()
ret i32 %30
}