#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 EXIT_SUCCESS;
int /*<<< orphan*/ query_main(char const *, int, char const *const *);
int /*<<< orphan*/ range_main(char const *, int, char const *const *);
int /*<<< orphan*/ register_main(char const *, int, char const *const *);
int /*<<< orphan*/ store_main(char const *, int, char const *const *);
int /*<<< orphan*/ strcmp(char *, char const *);
int /*<<< orphan*/ usage(char const *);
int main(int argc, const char *const *argv) {
  const char *exename = argv[0];
  const char *command;
  int command_argc;
  const char *const *command_argv;
  if (argc < 2)
    usage(exename);
  command = argv[1];
  command_argc = argc - 2;
  command_argv = argv + 2;
  if (!strcmp("help", command))
    usage(exename);
  if (!strcmp("register", command))
    register_main(exename, command_argc, command_argv);
  else if (!strcmp("store", command))
    store_main(exename, command_argc, command_argv);
  else if (!strcmp("query", command))
    query_main(exename, command_argc, command_argv);
  else if (!strcmp("range", command))
    range_main(exename, command_argc, command_argv);
  else
    usage(exename);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1194 <main+0x34>
mov    -0x18(%rbp),%rdi
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11d7 <main+0x77>
mov    -0x18(%rbp),%rdi
call   1050 <usage@plt>
mov    -0x20(%rbp),%rsi
lea    0xe23(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1205 <main+0xa5>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1070 <register_main@plt>
jmp    12a7 <main+0x147>
mov    -0x20(%rbp),%rsi
lea    0xdfe(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1233 <main+0xd3>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1060 <store_main@plt>
jmp    12a2 <main+0x142>
mov    -0x20(%rbp),%rsi
lea    0xdd6(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1261 <main+0x101>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1040 <query_main@plt>
jmp    129d <main+0x13d>
mov    -0x20(%rbp),%rsi
lea    0xdae(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    128f <main+0x12f>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1080 <range_main@plt>
jmp    1298 <main+0x138>
mov    -0x18(%rbp),%rdi
call   1050 <usage@plt>
jmp    129d <main+0x13d>
jmp    12a2 <main+0x142>
jmp    12a7 <main+0x147>
mov    0x2d32(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
mov    (%rsi),%r14
cmp    $0x1,%edi
jg     117d <main+0x1d>
mov    %r14,%rdi
call   1050 <usage@plt>
mov    0x8(%rbx),%rbp
lea    0xe78(%rip),%rdi
mov    %rbp,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    119c <main+0x3c>
mov    %r14,%rdi
call   1050 <usage@plt>
add    $0xfffffffe,%r15d
add    $0x10,%rbx
lea    0xe5a(%rip),%rdi
mov    %rbp,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11fa <main+0x9a>
lea    0xe50(%rip),%rdi
mov    %rbp,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     120a <main+0xaa>
lea    0xe43(%rip),%rdi
mov    %rbp,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     121a <main+0xba>
lea    0xe36(%rip),%rdi
mov    %rbp,%rsi
call   1030 <strcmp@plt>
mov    %r14,%rdi
test   %eax,%eax
je     122a <main+0xca>
call   1050 <usage@plt>
jmp    1235 <main+0xd5>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1070 <register_main@plt>
jmp    1235 <main+0xd5>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1060 <store_main@plt>
jmp    1235 <main+0xd5>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1040 <query_main@plt>
jmp    1235 <main+0xd5>
mov    %r15d,%esi
mov    %rbx,%rdx
call   1080 <range_main@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [9 x i8] c"register\00"
@.str.2 = [6 x i8] c"store\00"
@.str.3 = [6 x i8] c"query\00"
@.str.4 = [6 x i8] c"range\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i8*, i8** %6
%17 = call i32 @usage(i8* %16)
br label %18
18: ; preds = %15, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %7
%22 = load i32, i32* %4
%23 = sub nsw i32 %22, 2
store i32 %23, i32* %8
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
store i8** %25, i8*** %9
%26 = load i8*, i8** %7
%27 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %18
%30 = load i8*, i8** %6
%31 = call i32 @usage(i8* %30)
br label %32
32: ; preds = %29, %18
%33 = load i8*, i8** %7
%34 = call i32 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %32
%37 = load i8*, i8** %6
%38 = load i32, i32* %8
%39 = load i8**, i8*** %9
%40 = call i32 @register_main(i8* %37, i32 %38, i8** %39)
br label %74
41: ; preds = %32
%42 = load i8*, i8** %7
%43 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %50, label %45
45: ; preds = %41
%46 = load i8*, i8** %6
%47 = load i32, i32* %8
%48 = load i8**, i8*** %9
%49 = call i32 @store_main(i8* %46, i32 %47, i8** %48)
br label %73
50: ; preds = %41
%51 = load i8*, i8** %7
%52 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %59, label %54
54: ; preds = %50
%55 = load i8*, i8** %6
%56 = load i32, i32* %8
%57 = load i8**, i8*** %9
%58 = call i32 @query_main(i8* %55, i32 %56, i8** %57)
br label %72
59: ; preds = %50
%60 = load i8*, i8** %7
%61 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %68, label %63
63: ; preds = %59
%64 = load i8*, i8** %6
%65 = load i32, i32* %8
%66 = load i8**, i8*** %9
%67 = call i32 @range_main(i8* %64, i32 %65, i8** %66)
br label %71
68: ; preds = %59
%69 = load i8*, i8** %6
%70 = call i32 @usage(i8* %69)
br label %71
71: ; preds = %68, %63
br label %72
72: ; preds = %71, %54
br label %73
73: ; preds = %72, %45
br label %74
74: ; preds = %73, %36
%75 = load i32, i32* @EXIT_SUCCESS
ret i32 %75
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [9 x i8] c"register\00"
@.str.2 = [6 x i8] c"store\00"
@.str.3 = [6 x i8] c"query\00"
@.str.4 = [6 x i8] c"range\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @usage(i8* %3)
br label %7
7: ; preds = %5, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = add nsw i32 %0, -2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %9)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @usage(i8* %3)
br label %16
16: ; preds = %14, %7
%17 = tail call i32 @strcmp(i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %9)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @register_main(i8* %3, i32 %10, i8** %11)
br label %38
21: ; preds = %16
%22 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %9)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @store_main(i8* %3, i32 %10, i8** %11)
br label %38
26: ; preds = %21
%27 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %9)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @query_main(i8* %3, i32 %10, i8** %11)
br label %38
31: ; preds = %26
%32 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %9)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = tail call i32 @range_main(i8* %3, i32 %10, i8** %11)
br label %38
36: ; preds = %31
%37 = tail call i32 @usage(i8* %3)
br label %38
38: ; preds = %24, %34, %36, %29, %19
%39 = load i32, i32* @EXIT_SUCCESS
ret i32 %39
}