#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 autotools {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ command_add();
int /*<<< orphan*/ command_release();
int /*<<< orphan*/ command_search();
int /*<<< orphan*/ command_show();
int /*<<< orphan*/ get();
char getchar();
int /*<<< orphan*/ help();
int kbd() {
  struct autotools *at;
  char a = getchar();
  int cmd = a - '0';
  switch (cmd) {
  case 3:
    get();
    command_add();
    break;
  case 1:
    command_show();
    break;
  case 2:
    command_search();
    break;
  case 4:
    command_release();
    break;
  default:
    help();
    break;
  }
  getchar();
  return 1;
}


x86 assembly (clang, -O0):
<kbd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11ec <kbd+0x7c>
mov    -0x18(%rbp),%rax
lea    0xe54(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <get@plt>
mov    $0x0,%al
call   1060 <command_add@plt>
jmp    11f3 <kbd+0x83>
mov    $0x0,%al
call   1080 <command_show@plt>
jmp    11f3 <kbd+0x83>
mov    $0x0,%al
call   1040 <command_search@plt>
jmp    11f3 <kbd+0x83>
mov    $0x0,%al
call   1030 <command_release@plt>
jmp    11f3 <kbd+0x83>
mov    $0x0,%al
call   1090 <help@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kbd>:
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffcf,%eax
cmp    $0x3,%eax
ja     119c <kbd+0x2c>
lea    0xe76(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1080 <command_show@plt>
jmp    11c5 <kbd+0x55>
xor    %eax,%eax
call   1090 <help@plt>
jmp    11c5 <kbd+0x55>
xor    %eax,%eax
call   1040 <command_search@plt>
jmp    11c5 <kbd+0x55>
xor    %eax,%eax
call   1070 <get@plt>
xor    %eax,%eax
call   1060 <command_add@plt>
jmp    11c5 <kbd+0x55>
xor    %eax,%eax
call   1030 <command_release@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.autotools = type { i32 }
define i32 @kbd() {
%1 = alloca %struct.autotools*
%2 = alloca i8
%3 = alloca i32
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = sub nsw i32 %6, 48
store i32 %7, i32* %3
%8 = load i32, i32* %3
switch i32 %8, label %18 [
i32 3, label %9
i32 1, label %12
i32 2, label %14
i32 4, label %16
]
9: ; preds = %0
%10 = call i32 (...) @get()
%11 = call i32 (...) @command_add()
br label %20
12: ; preds = %0
%13 = call i32 (...) @command_show()
br label %20
14: ; preds = %0
%15 = call i32 (...) @command_search()
br label %20
16: ; preds = %0
%17 = call i32 (...) @command_release()
br label %20
18: ; preds = %0
%19 = call i32 (...) @help()
br label %20
20: ; preds = %18, %16, %14, %12, %9
%21 = call signext i8 (...) @getchar()
ret i32 1
}

LLVM IR (-O2):
%struct.autotools = type { i32 }
define i32 @kbd() {
%1 = tail call signext i8 (...) @getchar()
%2 = sext i8 %1 to i32
switch i32 %2, label %12 [
i32 51, label %3
i32 49, label %6
i32 50, label %8
i32 52, label %10
]
3: ; preds = %0
%4 = tail call i32 (...) @get()
%5 = tail call i32 (...) @command_add()
br label %14
6: ; preds = %0
%7 = tail call i32 (...) @command_show()
br label %14
8: ; preds = %0
%9 = tail call i32 (...) @command_search()
br label %14
10: ; preds = %0
%11 = tail call i32 (...) @command_release()
br label %14
12: ; preds = %0
%13 = tail call i32 (...) @help()
br label %14
14: ; preds = %12, %10, %8, %6, %3
%15 = tail call signext i8 (...) @getchar()
ret i32 1
}