#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 /*<<< orphan*/ CDB_ChangeIntEntry(char *, int);
int /*<<< orphan*/ CDB_ChangeStringEntry(char *, char *);
int /*<<< orphan*/ CDB_Save();
int /*<<< orphan*/ CDB_StartUp(int);
scalar_t__ CheckCmdSwitch(char *, int, char **);
char *GetCmdOpt(char *, int, char **);
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void main(int argc, char *argv[]) {
  char *arg_key;
  char *arg_data;
  int arg_value = 0;
  int mode = 0;
  arg_key = GetCmdOpt("-k", argc, argv);
  if (arg_key == NULL) {
    printf("you must give me a key.\n");
    exit(0);
  }
  arg_data = GetCmdOpt("-i", argc, argv);
  if (arg_data != NULL) {
    mode = 1;
    arg_value = atoi(arg_data);
  }
  arg_data = GetCmdOpt("-s", argc, argv);
  if (arg_data != NULL) {
    mode = 2;
  }
  if (mode == 0) {
    printf("no value given. either -i or -s\n");
    exit(0);
  }
  if (CheckCmdSwitch("-q", argc, argv)) {
    CDB_StartUp(0);
  } else {
    CDB_StartUp(1);
  }
  if (mode == 1) {
    CDB_ChangeIntEntry(arg_key, arg_value);
  }
  if (mode == 2) {
    CDB_ChangeStringEntry(arg_key, arg_data);
  }
  CDB_Save();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe45(%rip),%rdi
call   1030 <GetCmdOpt@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e2 <main+0x52>
lea    0xe2d(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe2c(%rip),%rdi
call   1030 <GetCmdOpt@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1217 <main+0x87>
movl   $0x1,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xdfa(%rip),%rdi
call   1030 <GetCmdOpt@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1240 <main+0xb0>
movl   $0x2,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    125d <main+0xcd>
lea    0xdd1(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xdd8(%rip),%rdi
call   1040 <CheckCmdSwitch@plt>
cmp    $0x0,%rax
je     1286 <main+0xf6>
xor    %edi,%edi
call   10a0 <CDB_StartUp@plt>
jmp    1290 <main+0x100>
mov    $0x1,%edi
call   10a0 <CDB_StartUp@plt>
cmpl   $0x1,-0x28(%rbp)
jne    12a6 <main+0x116>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <CDB_ChangeIntEntry@plt>
cmpl   $0x2,-0x28(%rbp)
jne    12bd <main+0x12d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <CDB_ChangeStringEntry@plt>
mov    $0x0,%al
call   1060 <CDB_Save@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xe59(%rip),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
call   1030 <GetCmdOpt@plt>
test   %rax,%rax
je     126d <main+0xdd>
mov    %rax,%r14
lea    0xe3f(%rip),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
call   1030 <GetCmdOpt@plt>
test   %rax,%rax
je     11e7 <main+0x57>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,0x4(%rsp)
mov    $0x1,%r15d
jmp    11f2 <main+0x62>
movl   $0x0,0x4(%rsp)
xor    %r15d,%r15d
lea    0xe2d(%rip),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
call   1030 <GetCmdOpt@plt>
test   %rax,%rax
mov    $0x2,%ebx
cmove  %r15d,%ebx
test   %ebx,%ebx
je     1276 <main+0xe6>
mov    %rax,%r12
lea    0xde9(%rip),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
call   1050 <CheckCmdSwitch@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10a0 <CDB_StartUp@plt>
cmp    $0x2,%ebx
je     124d <main+0xbd>
cmp    $0x1,%ebx
jne    1258 <main+0xc8>
mov    %r14,%rdi
mov    0x4(%rsp),%esi
call   1070 <CDB_ChangeIntEntry@plt>
jmp    1258 <main+0xc8>
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <CDB_ChangeStringEntry@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <CDB_Save@plt>
lea    0xdb5(%rip),%rdi
jmp    127d <main+0xed>
lea    0xd8c(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-k\00"
@.str.1 = [25 x i8] c"you must give me a key.\0A\00"
@.str.2 = [3 x i8] c"-i\00"
@.str.3 = [3 x i8] c"-s\00"
@.str.4 = [33 x i8] c"no value given. either -i or -s\0A\00"
@.str.5 = [3 x i8] c"-q\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i32, i32* %3
%10 = load i8**, i8*** %4
%11 = call i8* @GetCmdOpt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9, i8** %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = load i32, i32* %3
%19 = load i8**, i8*** %4
%20 = call i8* @GetCmdOpt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %18, i8** %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %17
store i32 1, i32* %8
%24 = load i8*, i8** %6
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %7
br label %26
26: ; preds = %23, %17
%27 = load i32, i32* %3
%28 = load i8**, i8*** %4
%29 = call i8* @GetCmdOpt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %27, i8** %28)
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 2, i32* %8
br label %33
33: ; preds = %32, %26
%34 = load i32, i32* %8
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @exit(i32 0)
unreachable
39: ; preds = %33
%40 = load i32, i32* %3
%41 = load i8**, i8*** %4
%42 = call i64 @CheckCmdSwitch(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %40, i8** %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @CDB_StartUp(i32 0)
br label %48
46: ; preds = %39
%47 = call i32 @CDB_StartUp(i32 1)
br label %48
48: ; preds = %46, %44
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i8*, i8** %5
%53 = load i32, i32* %7
%54 = call i32 @CDB_ChangeIntEntry(i8* %52, i32 %53)
br label %55
55: ; preds = %51, %48
%56 = load i32, i32* %8
%57 = icmp eq i32 %56, 2
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = load i8*, i8** %5
%60 = load i8*, i8** %6
%61 = call i32 @CDB_ChangeStringEntry(i8* %59, i8* %60)
br label %62
62: ; preds = %58, %55
%63 = call i32 (...) @CDB_Save()
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-k\00"
@.str.2 = [3 x i8] c"-i\00"
@.str.3 = [3 x i8] c"-s\00"
@.str.5 = [3 x i8] c"-q\00"
@str = [32 x i8] c"no value given. either -i or -s\00"
@str.6 = [24 x i8] c"you must give me a key.\00"
define void @main(i32 %0, i8** %1) {
%3 = tail call i8* @GetCmdOpt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0, i8** %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = tail call i8* @GetCmdOpt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %0, i8** %1)
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @atoi(i8* %9)
br label %13
13: ; preds = %11, %8
%14 = phi i32 [ %12, %11 ], [ 0, %8 ]
%15 = phi i32 [ 1, %11 ], [ 0, %8 ]
%16 = tail call i8* @GetCmdOpt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %0, i8** %1)
%17 = icmp eq i8* %16, null
%18 = select i1 %17, i32 %15, i32 2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %13
%24 = tail call i64 @CheckCmdSwitch(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %0, i8** %1)
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i32
%27 = tail call i32 @CDB_StartUp(i32 %26)
switch i32 %18, label %32 [
i32 1, label %28
i32 2, label %30
]
28: ; preds = %23
%29 = tail call i32 @CDB_ChangeIntEntry(i8* %3, i32 %14)
br label %32
30: ; preds = %23
%31 = tail call i32 @CDB_ChangeStringEntry(i8* %3, i8* %16)
br label %32
32: ; preds = %28, %23, %30
%33 = tail call i32 (...) @CDB_Save()
ret void
}