#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*/ EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    die("Usage: proj17 <dbfile> <action> [action params]");
  }
  char *fileName = argv[1];
  char action = argv[2][0];
  int id = 0;
  if (argc > 3) {
    id = atoi(argv[3]);
  }
  if (id >= 100) {
    die("There are not that many records.");
  }
  switch (action) {
  case 'c':
    break;
  case 'g':
    break;
  case 's':
    break;
  case 'd':
    break;
  case 'l':
    break;
  default:
    die("Invalid action: c=create, g=get, s=set, d=del, l=list");
    break;
  }
  exit(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)
cmpl   $0x3,-0x8(%rbp)
jge    115c <main+0x2c>
lea    0xeed(%rip),%rdi
call   1030 <die@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    1196 <main+0x66>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x64,-0x20(%rbp)
jl     11ac <main+0x7c>
lea    0xecd(%rip),%rdi
call   1030 <die@plt>
movsbl -0x19(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x10,%eax
ja     11ef <main+0xbf>
mov    -0x28(%rbp),%rax
lea    0xe33(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11fb <main+0xcb>
jmp    11fb <main+0xcb>
jmp    11fb <main+0xcb>
jmp    11fb <main+0xcb>
jmp    11fb <main+0xcb>
lea    0xe9f(%rip),%rdi
call   1030 <die@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     1150 <main+0x20>
lea    0xebe(%rip),%rdi
call   1030 <die@plt>
mov    0x10(%rbx),%rax
mov    (%rax),%bpl
jmp    1176 <main+0x46>
mov    0x10(%rbx),%rax
mov    (%rax),%bpl
cmp    $0x3,%edi
je     1176 <main+0x46>
mov    0x18(%rbx),%rdi
call   1040 <atoi@plt>
cmp    $0x64,%eax
jl     1176 <main+0x46>
lea    0xebf(%rip),%rdi
call   1030 <die@plt>
movsbl %bpl,%eax
add    $0xffffff9d,%eax
cmp    $0x10,%eax
ja     119a <main+0x6a>
mov    $0x10213,%ecx
bt     %eax,%ecx
jae    119a <main+0x6a>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xeb0(%rip),%rdi
call   1030 <die@plt>
jmp    118c <main+0x5c>

LLVM IR (-O0):
@.str = [48 x i8] c"Usage: proj17 <dbfile> <action> [action params]\00"
@.str.1 = [33 x i8] c"There are not that many records.\00"
@.str.2 = [54 x i8] c"Invalid action: c=create, g=get, s=set, d=del, l=list\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @die(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
store i8 %21, i8* %7
store i32 0, i32* %8
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 3
br i1 %23, label %24, label %29
24: ; preds = %13
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %8
br label %29
29: ; preds = %24, %13
%30 = load i32, i32* %8
%31 = icmp sge i32 %30, 100
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @die(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = load i8, i8* %7
%36 = sext i8 %35 to i32
switch i32 %36, label %42 [
i32 99, label %37
i32 103, label %38
i32 115, label %39
i32 100, label %40
i32 108, label %41
]
37: ; preds = %34
br label %44
38: ; preds = %34
br label %44
39: ; preds = %34
br label %44
40: ; preds = %34
br label %44
41: ; preds = %34
br label %44
42: ; preds = %34
%43 = call i32 @die(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %41, %40, %39, %38, %37
%45 = load i32, i32* @EXIT_SUCCESS
%46 = call i32 @exit(i32 %45)
unreachable
}

LLVM IR (-O2):
@.str = [48 x i8] c"Usage: proj17 <dbfile> <action> [action params]\00"
@.str.1 = [33 x i8] c"There are not that many records.\00"
@.str.2 = [54 x i8] c"Invalid action: c=create, g=get, s=set, d=del, l=list\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = tail call i32 @die(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = load i8, i8* %7
br label %21
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i32 %0, 3
br i1 %13, label %21, label %14
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = icmp sgt i32 %17, 99
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @die(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %4, %9, %19, %14
%22 = phi i8 [ %8, %4 ], [ %12, %9 ], [ %12, %19 ], [ %12, %14 ]
%23 = sext i8 %22 to i32
switch i32 %23, label %24 [
i32 99, label %26
i32 103, label %26
i32 115, label %26
i32 100, label %26
i32 108, label %26
]
24: ; preds = %21
%25 = tail call i32 @die(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %21, %21, %21, %21, %21
%27 = load i32, i32* @EXIT_SUCCESS
%28 = tail call i32 @exit(i32 %27)
unreachable
}