#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*/ call1();
int /*<<< orphan*/ call2();
int /*<<< orphan*/ call3();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  do {
    printf("slect 0 to exit\n");
    printf("slect 1 to display Hello\n");
    printf("slect 2 to calculate area\n ");
    printf("slect 3 to six-subject\n ");
    scanf("%d", &num);
    switch (num) {
    case 0:
      exit(0);
    case 1:
      call1();
      break;
    case 2:
      call2();
      break;
    case 3:
      call3();
      break;
    default:
      printf("error\n");
      break;
    }
  } while (num != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     11ff <main+0x9f>
mov    -0x10(%rbp),%rax
lea    0xe35(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %edi,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1050 <call1@plt>
jmp    120b <main+0xab>
mov    $0x0,%al
call   1030 <call2@plt>
jmp    120b <main+0xab>
mov    $0x0,%al
call   1070 <call3@plt>
jmp    120b <main+0xab>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
jmp    1210 <main+0xb0>
cmpl   $0x0,-0x8(%rbp)
jne    116f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed6(%rip),%r15
lea    0xe87(%rip),%r12
lea    0xe9c(%rip),%r13
lea    0xeae(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xe5d(%rip),%r14
jmp    11c3 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
je     1229 <main+0xb9>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     11b0 <main+0x40>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <call1@plt>
jmp    11bc <main+0x4c>
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <call2@plt>
jmp    11bc <main+0x4c>
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <call3@plt>
jmp    11bc <main+0x4c>
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 = [17 x i8] c"slect 0 to exit\0A\00"
@.str.1 = [26 x i8] c"slect 1 to display Hello\0A\00"
@.str.2 = [28 x i8] c"slect 2 to calculate area\0A \00"
@.str.3 = [25 x i8] c"slect 3 to six-subject\0A \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [7 x i8] c"error\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %21, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
switch i32 %9, label %18 [
i32 0, label %10
i32 1, label %12
i32 2, label %14
i32 3, label %16
]
10: ; preds = %3
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %3
%13 = call i32 (...) @call1()
br label %20
14: ; preds = %3
%15 = call i32 (...) @call2()
br label %20
16: ; preds = %3
%17 = call i32 (...) @call3()
br label %20
18: ; preds = %3
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14, %12
br label %21
21: ; preds = %20
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %3, label %24
24: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [28 x i8] c"slect 2 to calculate area\0A \00"
@.str.3 = [25 x i8] c"slect 3 to six-subject\0A \00"
@.str.4 = [3 x i8] c"%d\00"
@str = [16 x i8] c"slect 0 to exit\00"
@str.6 = [25 x i8] c"slect 1 to display Hello\00"
@str.7 = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %20, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
switch i32 %9, label %18 [
i32 0, label %10
i32 1, label %12
i32 2, label %14
i32 3, label %16
]
10: ; preds = %3
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %3
%13 = call i32 (...) @call1()
br label %20
14: ; preds = %3
%15 = call i32 (...) @call2()
br label %20
16: ; preds = %3
%17 = call i32 (...) @call3()
br label %20
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
br label %20
20: ; preds = %12, %14, %16, %18
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %3
23: ; preds = %20
ret i32 0
}