#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_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ database_initialize(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ stderr;
int command_mode(int argc, char *argv[]) {
  int c;
  int result = EXIT_SUCCESS;
  char *prog_name = argv[0];
  extern char *optarg;
  extern int optind, opterr, optopt;
  while ((c = getopt(argc, argv, ":i")) != -1) {
    switch (c) {
    case 'i':
      if (!database_initialize(1)) {
        result = EXIT_FAILURE;
        fprintf(stderr, "Failed to initialize database\n");
      }
      break;
    case ':':
    case '?':
    default:
      fprintf(stderr, "Usage: %s [-i]\n", prog_name);
      result = EXIT_FAILURE;
      break;
    }
  }
  return (result);
}


x86 assembly (clang, -O0):
<command_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9c(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1217 <command_mode+0xe7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3a,%eax
je     11e6 <command_mode+0xb6>
jmp    1189 <command_mode+0x59>
mov    -0x24(%rbp),%eax
sub    $0x3f,%eax
je     11e6 <command_mode+0xb6>
jmp    119a <command_mode+0x6a>
mov    -0x24(%rbp),%eax
sub    $0x69,%eax
jne    11eb <command_mode+0xbb>
jmp    11ab <command_mode+0x7b>
mov    $0x1,%edi
call   1040 <database_initialize@plt>
cmp    $0x0,%eax
jne    11e1 <command_mode+0xb1>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1212 <command_mode+0xe2>
jmp    11eb <command_mode+0xbb>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <command_mode+0x26>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_mode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e89(%rip),%rax
mov    (%rax),%r12d
mov    (%rsi),%r14
lea    0xeac(%rip),%r15
mov    0x2e85(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x69,%eax
jne    119e <command_mode+0x6e>
mov    $0x1,%edi
call   1040 <database_initialize@plt>
test   %eax,%eax
jne    1160 <command_mode+0x30>
mov    0x2e51(%rip),%rax
mov    (%rax),%r12d
mov    0x0(%r13),%edi
lea    0xe6e(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1160 <command_mode+0x30>
cmp    $0xffffffff,%eax
je     11c4 <command_mode+0x94>
mov    0x0(%r13),%edi
lea    0xe74(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%r12d
jmp    1160 <command_mode+0x30>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [3 x i8] c":i\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"Failed to initialize database\0A\00"
@.str.2 = [16 x i8] c"Usage: %s [-i]\0A\00"
define i32 @command_mode(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* @EXIT_SUCCESS
store i32 %8, i32* %6
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
store i8* %11, i8** %7
br label %12
12: ; preds = %33, %2
%13 = load i32, i32* %3
%14 = load i8**, i8*** %4
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %5
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %34
17: ; preds = %12
%18 = load i32, i32* %5
switch i32 %18, label %28 [
i32 105, label %19
i32 58, label %27
i32 63, label %27
]
19: ; preds = %17
%20 = call i32 @database_initialize(i32 1)
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %6
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %22, %19
br label %33
27: ; preds = %17, %17
br label %28
28: ; preds = %17, %27
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %7
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
store i32 %32, i32* %6
br label %33
33: ; preds = %28, %26
br label %12
34: ; preds = %12
%35 = load i32, i32* %6
ret i32 %35
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [3 x i8] c":i\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"Failed to initialize database\0A\00"
@.str.2 = [16 x i8] c"Usage: %s [-i]\0A\00"
define i32 @command_mode(i32 %0, i8** %1) {
%3 = load i32, i32* @EXIT_SUCCESS
%4 = load i8*, i8** %1
br label %5
5: ; preds = %16, %2
%6 = phi i32 [ %3, %2 ], [ %17, %16 ]
br label %7
7: ; preds = %5, %9
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %18 [
i32 -1, label %22
i32 105, label %9
]
9: ; preds = %7
%10 = tail call i32 @database_initialize(i32 1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %7
12: ; preds = %9
%13 = load i32, i32* @EXIT_FAILURE
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %12, %18
%17 = phi i32 [ %21, %18 ], [ %13, %12 ]
br label %5
18: ; preds = %7
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%21 = load i32, i32* @EXIT_FAILURE
br label %16
22: ; preds = %7
ret i32 %6
}