#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 */
char getchar();
int /*<<< orphan*/ insert();
int /*<<< orphan*/ print();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ search();
int /*<<< orphan*/ update();
int main(void) {
  char code;
  for (;;) {
    printf("Enter operation code: ");
    scanf(" %c", &code);
    while (getchar() != '\n') {
    }
    switch (code) {
    case 'i':
      insert();
      break;
    case 's':
      search();
      break;
    case 'u':
      update();
      break;
    case 'p':
      print();
      break;
    case 'q':
      return 0;
    default:
      printf("Illegal code\n");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11b3 <main+0x43>
jmp    119b <main+0x2b>
movsbl -0x5(%rbp),%eax
add    $0xffffff97,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xc,%eax
ja     1215 <main+0xa5>
mov    -0x10(%rbp),%rax
lea    0xe2c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <insert@plt>
jmp    1221 <main+0xb1>
mov    $0x0,%al
call   1050 <search@plt>
jmp    1221 <main+0xb1>
mov    $0x0,%al
call   1030 <update@plt>
jmp    1221 <main+0xb1>
mov    $0x0,%al
call   1060 <print@plt>
jmp    1221 <main+0xb1>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
jmp    117f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%r14
lea    0xea0(%rip),%r15
lea    0xf(%rsp),%r13
lea    0xe98(%rip),%r12
lea    0xe42(%rip),%rbx
jmp    11da <main+0x4a>
mov    %r12,%rdi
call   1050 <puts@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
nopl   (%rax)
xor    %eax,%eax
call   1090 <getchar@plt>
cmp    $0xa,%al
jne    11f0 <main+0x60>
movsbl 0xf(%rsp),%eax
add    $0xffffff97,%eax
cmp    $0xc,%eax
ja     11c0 <main+0x30>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   10b0 <insert@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1080 <print@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1070 <search@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1030 <update@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter operation code: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [14 x i8] c"Illegal code\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %25, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %6
6: ; preds = %10, %3
%7 = call signext i8 (...) @getchar()
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
switch i32 %13, label %23 [
i32 105, label %14
i32 115, label %16
i32 117, label %18
i32 112, label %20
i32 113, label %22
]
14: ; preds = %11
%15 = call i32 (...) @insert()
br label %25
16: ; preds = %11
%17 = call i32 (...) @search()
br label %25
18: ; preds = %11
%19 = call i32 (...) @update()
br label %25
20: ; preds = %11
%21 = call i32 (...) @print()
br label %25
22: ; preds = %11
ret i32 0
23: ; preds = %11
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %20, %18, %16, %14
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %3
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter operation code: \00"
@.str.1 = [4 x i8] c" %c\00"
@str = [13 x i8] c"Illegal code\00"
define i32 @main() {
%1 = alloca i8
br label %2
2: ; preds = %22, %0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %5
5: ; preds = %5, %2
%6 = call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %8, label %5
8: ; preds = %5
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
switch i32 %10, label %20 [
i32 105, label %11
i32 115, label %13
i32 117, label %15
i32 112, label %17
i32 113, label %19
]
11: ; preds = %8
%12 = call i32 (...) @insert()
br label %22
13: ; preds = %8
%14 = call i32 (...) @search()
br label %22
15: ; preds = %8
%16 = call i32 (...) @update()
br label %22
17: ; preds = %8
%18 = call i32 (...) @print()
br label %22
19: ; preds = %8
ret i32 0
20: ; preds = %8
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %17, %15, %13, %11
%23 = call i32 @putchar(i32 10)
br label %2
}