#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*/ clearstdin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ input_record();
int /*<<< orphan*/ make_dummy_record();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printfile();
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ search(char *);
int run(int choice) {
  if (choice == 1) {
    make_dummy_record();
    printf("New Database created...\n");
    printf("Please select operation\n");
    scanf("%d", &choice);
    clearstdin();
    run(choice);
  } else if (choice == 2) {
    input_record();
    printf("Please select operation\n");
    scanf("%d", &choice);
    clearstdin();
    run(choice);
  } else if (choice == 3) {
    char *searchN;
    printf("Please enter a name to search ...........\n");
    scanf("%s", searchN);
    clearstdin();
    search(searchN);
    printf("Please select operation\n");
    scanf("%d", &choice);
    clearstdin();
    run(choice);
  } else if (choice == 4) {
    printfile();
    printf("Please select operation\n");
    scanf("%d", &choice);
    clearstdin();
    run(choice);
  } else if (choice == 5) {
    exit(0);
  } else {
    printf("Please select a valid choice\n");
    scanf("%d", &choice);
    clearstdin();
    run(choice);
  }
  return -1;
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    11ea <run+0x5a>
mov    $0x0,%al
call   1080 <make_dummy_record@plt>
lea    0xe4d(%rip),%rdi
call   1060 <printf@plt>
lea    0xe5a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe67(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    $0x0,%al
call   10b0 <clearstdin@plt>
mov    -0x4(%rbp),%edi
call   1050 <run@plt>
jmp    132c <run+0x19c>
cmpl   $0x2,-0x4(%rbp)
jne    122d <run+0x9d>
mov    $0x0,%al
call   1040 <input_record@plt>
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
lea    0xe24(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    $0x0,%al
call   10b0 <clearstdin@plt>
mov    -0x4(%rbp),%edi
call   1050 <run@plt>
jmp    1327 <run+0x197>
cmpl   $0x3,-0x4(%rbp)
jne    1297 <run+0x107>
lea    0xdf7(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    $0x0,%al
call   10b0 <clearstdin@plt>
mov    -0x10(%rbp),%rdi
call   1070 <search@plt>
lea    0xdad(%rip),%rdi
call   1060 <printf@plt>
lea    0xdba(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    $0x0,%al
call   10b0 <clearstdin@plt>
mov    -0x4(%rbp),%edi
call   1050 <run@plt>
jmp    1322 <run+0x192>
cmpl   $0x4,-0x4(%rbp)
jne    12da <run+0x14a>
mov    $0x0,%al
call   1030 <printfile@plt>
lea    0xd6a(%rip),%rdi
call   1060 <printf@plt>
lea    0xd77(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    $0x0,%al
call   10b0 <clearstdin@plt>
mov    -0x4(%rbp),%edi
call   1050 <run@plt>
jmp    131d <run+0x18d>
cmpl   $0x5,-0x4(%rbp)
jne    12eb <run+0x15b>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xd71(%rip),%rdi
call   1060 <printf@plt>
lea    0xd34(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    $0x0,%al
call   10b0 <clearstdin@plt>
mov    -0x4(%rbp),%edi
call   1050 <run@plt>
jmp    131d <run+0x18d>
jmp    1322 <run+0x192>
jmp    1327 <run+0x197>
jmp    132c <run+0x19c>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rax
mov    %edi,0x4(%rsp)
add    $0xffffffff,%edi
cmp    $0x4,%edi
ja     11f3 <run+0x63>
lea    0xe5c(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1080 <make_dummy_record@plt>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
jmp    1203 <run+0x73>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %eax,%eax
call   10b0 <clearstdin@plt>
call   1070 <search@plt>
jmp    1203 <run+0x73>
xor    %eax,%eax
call   1030 <printfile@plt>
jmp    1203 <run+0x73>
lea    0xe20(%rip),%rdi
jmp    120a <run+0x7a>
xor    %eax,%eax
call   1050 <input_record@plt>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
lea    0xdfe(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %eax,%eax
call   10b0 <clearstdin@plt>
mov    0x4(%rsp),%edi
call   1060 <run@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"New Database created...\0A\00"
@.str.1 = [25 x i8] c"Please select operation\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [43 x i8] c"Please enter a name to search ...........\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [30 x i8] c"Please select a valid choice\0A\00"
define i32 @run(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = call i32 (...) @make_dummy_record()
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%11 = call i32 (...) @clearstdin()
%12 = load i32, i32* %2
%13 = call i32 @run(i32 %12)
br label %64
14: ; preds = %1
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = call i32 (...) @input_record()
%19 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%21 = call i32 (...) @clearstdin()
%22 = load i32, i32* %2
%23 = call i32 @run(i32 %22)
br label %63
24: ; preds = %14
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8*, i8** %3
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = call i32 (...) @clearstdin()
%32 = load i8*, i8** %3
%33 = call i32 @search(i8* %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%36 = call i32 (...) @clearstdin()
%37 = load i32, i32* %2
%38 = call i32 @run(i32 %37)
br label %62
39: ; preds = %24
%40 = load i32, i32* %2
%41 = icmp eq i32 %40, 4
br i1 %41, label %42, label %49
42: ; preds = %39
%43 = call i32 (...) @printfile()
%44 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%46 = call i32 (...) @clearstdin()
%47 = load i32, i32* %2
%48 = call i32 @run(i32 %47)
br label %61
49: ; preds = %39
%50 = load i32, i32* %2
%51 = icmp eq i32 %50, 5
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @exit(i32 0)
unreachable
54: ; preds = %49
%55 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%57 = call i32 (...) @clearstdin()
%58 = load i32, i32* %2
%59 = call i32 @run(i32 %58)
br label %60
60: ; preds = %54
br label %61
61: ; preds = %60, %42
br label %62
62: ; preds = %61, %27
br label %63
63: ; preds = %62, %17
br label %64
64: ; preds = %63, %6
ret i32 -1
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%s\00"
@str = [29 x i8] c"Please select a valid choice\00"
@str.7 = [42 x i8] c"Please enter a name to search ...........\00"
@str.10 = [24 x i8] c"New Database created...\00"
@str.11 = [24 x i8] c"Please select operation\00"
define i32 @run(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
switch i32 %0, label %17 [
i32 1, label %3
i32 2, label %6
i32 3, label %8
i32 4, label %13
i32 5, label %15
]
3: ; preds = %1
%4 = tail call i32 (...) @make_dummy_record()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0))
br label %17
6: ; preds = %1
%7 = tail call i32 (...) @input_record()
br label %17
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.7, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* undef)
%11 = tail call i32 (...) @clearstdin()
%12 = tail call i32 @search(i8* undef)
br label %17
13: ; preds = %1
%14 = tail call i32 (...) @printfile()
br label %17
15: ; preds = %1
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %1, %6, %13, %8, %3
%18 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0), %6 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0), %13 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0), %8 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0), %3 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), %1 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) %18)
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%21 = call i32 (...) @clearstdin()
%22 = load i32, i32* %2
%23 = call i32 @run(i32 %22)
ret i32 -1
}