#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ select_function(int, int *);
int /*<<< orphan*/ selection_menu();
int main(void) {
  int flag = 1, choice;
  selection_menu();
  while (flag) {
    printf("please select the function:");
    scanf("%d", &choice);
    select_function(choice, &flag);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1050 <selection_menu@plt>
cmpl   $0x0,-0x8(%rbp)
je     1194 <main+0x54>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1040 <select_function@plt>
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x1,(%rsp)
xor    %eax,%eax
call   1050 <selection_menu@plt>
lea    0xea3(%rip),%r14
lea    0xeb8(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
call   1040 <select_function@plt>
cmpl   $0x0,(%rsp)
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"please select the function:\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%4 = call i32 (...) @selection_menu()
br label %5
5: ; preds = %8, %0
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = call i32 @select_function(i32 %11, i32* %2)
br label %5
13: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"please select the function:\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @selection_menu()
br label %6
6: ; preds = %0, %6
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = call i32 @select_function(i32 %9, i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %6
13: ; preds = %6
ret i32 0
}