#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 */
struct bplus_tree {
  int dummy;
};

/* Variables and functions */
#define EOF 128
int /*<<< orphan*/ bplus_tree_dump(struct bplus_tree *);
int /*<<< orphan*/ command_tips();
int getchar();
int /*<<< orphan*/ number_process(struct bplus_tree *, int);
int /*<<< orphan*/ printf(char *);
void command_process(struct bplus_tree *tree) {
  int c;
  printf("Please input command (Type 'h' for help): ");
  for (;;) {
    switch (c = getchar()) {
    case EOF:
      printf("\n");
    case 'q':
      return;
    case 'h':
      command_tips();
      break;
    case 'd':
      bplus_tree_dump(tree);
      break;
    case 'i':
    case 'r':
    case 's':
      if (number_process(tree, c) < 0) {
        return;
      }
    case '\n':
      printf("Please input command (Type 'h' for help): ");
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<command_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
sub    $0xa,%eax
je     123a <command_process+0xea>
jmp    1185 <command_process+0x35>
mov    -0x10(%rbp),%eax
sub    $0x64,%eax
je     120d <command_process+0xbd>
jmp    1196 <command_process+0x46>
mov    -0x10(%rbp),%eax
sub    $0x68,%eax
je     1201 <command_process+0xb1>
jmp    11a7 <command_process+0x57>
mov    -0x10(%rbp),%eax
sub    $0x69,%eax
je     121b <command_process+0xcb>
jmp    11b8 <command_process+0x68>
mov    -0x10(%rbp),%eax
sub    $0x71,%eax
je     11fc <command_process+0xac>
jmp    11c9 <command_process+0x79>
mov    -0x10(%rbp),%eax
add    $0xffffff8e,%eax
sub    $0x2,%eax
jb     121b <command_process+0xcb>
jmp    11dd <command_process+0x8d>
mov    -0x10(%rbp),%eax
sub    $0x80,%eax
jne    1246 <command_process+0xf6>
jmp    11f0 <command_process+0xa0>
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
jmp    1250 <command_process+0x100>
mov    $0x0,%al
call   1070 <command_tips@plt>
jmp    124b <command_process+0xfb>
mov    -0x8(%rbp),%rdi
call   1030 <bplus_tree_dump@plt>
jmp    124b <command_process+0xfb>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <number_process@plt>
cmp    $0x0,%eax
jge    1235 <command_process+0xe5>
jmp    1250 <command_process+0x100>
jmp    123a <command_process+0xea>
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
jmp    124b <command_process+0xfb>
jmp    1168 <command_process+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_process>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xf05(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
lea    0xe82(%rip),%rbx
jmp    1190 <command_process+0x30>
mov    %r15,%rdi
call   1030 <bplus_tree_dump@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
lea    -0x64(%rax),%ecx
cmp    $0x1c,%ecx
ja     11c0 <command_process+0x60>
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    %r15,%rdi
mov    %eax,%esi
call   1070 <number_process@plt>
test   %eax,%eax
jns    11c5 <command_process+0x65>
jmp    11d8 <command_process+0x78>
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%eax
jne    1190 <command_process+0x30>
mov    %r14,%rdi
call   1050 <printf@plt>
jmp    1190 <command_process+0x30>
xor    %eax,%eax
call   1080 <command_tips@plt>
jmp    1190 <command_process+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <putchar@plt>

LLVM IR (-O0):
%struct.bplus_tree = type { i32 }
@.str = [43 x i8] c"Please input command (Type 'h' for help): \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @command_process(%struct.bplus_tree* %0) {
%2 = alloca %struct.bplus_tree*
%3 = alloca i32
store %struct.bplus_tree* %0, %struct.bplus_tree** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %25, %1
%6 = call i32 (...) @getchar()
store i32 %6, i32* %3
switch i32 %6, label %24 [
i32 128, label %7
i32 113, label %9
i32 104, label %10
i32 100, label %12
i32 105, label %15
i32 114, label %15
i32 115, label %15
i32 10, label %22
]
7: ; preds = %5
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %5, %7
br label %26
10: ; preds = %5
%11 = call i32 (...) @command_tips()
br label %25
12: ; preds = %5
%13 = load %struct.bplus_tree*, %struct.bplus_tree** %2
%14 = call i32 @bplus_tree_dump(%struct.bplus_tree* %13)
br label %25
15: ; preds = %5, %5, %5
%16 = load %struct.bplus_tree*, %struct.bplus_tree** %2
%17 = load i32, i32* %3
%18 = call i32 @number_process(%struct.bplus_tree* %16, i32 %17)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %26
21: ; preds = %15
br label %22
22: ; preds = %5, %21
%23 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %5, %22
br label %25
25: ; preds = %24, %12, %10
br label %5
26: ; preds = %20, %9
ret void
}

LLVM IR (-O2):
%struct.bplus_tree = type { i32 }
@.str = [43 x i8] c"Please input command (Type 'h' for help): \00"
define void @command_process(%struct.bplus_tree* %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %16, %1
%4 = tail call i32 (...) @getchar()
switch i32 %4, label %16 [
i32 128, label %5
i32 113, label %17
i32 104, label %7
i32 100, label %9
i32 105, label %11
i32 114, label %11
i32 115, label %11
i32 10, label %14
]
5: ; preds = %3
%6 = tail call i32 @putchar(i32 10)
br label %17
7: ; preds = %3
%8 = tail call i32 (...) @command_tips()
br label %16
9: ; preds = %3
%10 = tail call i32 @bplus_tree_dump(%struct.bplus_tree* %0)
br label %16
11: ; preds = %3, %3, %3
%12 = tail call i32 @number_process(%struct.bplus_tree* %0, i32 %4)
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11, %3
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %3, %9, %7
br label %3
17: ; preds = %11, %3, %5
ret void
}