#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 lookup(int, char **);
scalar_t__ strcmp(char *, char *);
int update(int, char **);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int r = -1;
  if (argc < 2)
    usage(NULL);
  if (strcmp(argv[1], "lookup") == 0)
    r = lookup(argc - 1, argv + 1);
  else if (strcmp(argv[1], "update") == 0)
    r = update(argc - 1, argv + 1);
  else
    usage("Invalid command");
  return r;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1170 <main+0x30>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a9 <main+0x69>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <lookup@plt>
mov    %eax,-0x14(%rbp)
jmp    11f3 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <main+0xa2>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1030 <update@plt>
mov    %eax,-0x14(%rbp)
jmp    11ee <main+0xae>
lea    0xe25(%rip),%rdi
call   1060 <usage@plt>
jmp    11f3 <main+0xb3>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jg     1154 <main+0x14>
xor    %edi,%edi
call   1060 <usage@plt>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
lea    0xe9d(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1199 <main+0x59>
mov    (%rbx),%rdi
lea    0xe90(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ac <main+0x6c>
lea    0xe86(%rip),%rdi
call   1060 <usage@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
add    $0xffffffff,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <lookup@plt>
add    $0xffffffff,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <update@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"lookup\00"
@.str.1 = [7 x i8] c"update\00"
@.str.2 = [16 x i8] c"Invalid command\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @usage(i8* null)
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = call i32 @lookup(i32 %19, i8** %21)
store i32 %22, i32* %6
br label %38
23: ; preds = %11
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 1
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = call i32 @update(i32 %31, i8** %33)
store i32 %34, i32* %6
br label %37
35: ; preds = %23
%36 = call i32 @usage(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %29
br label %38
38: ; preds = %37, %17
%39 = load i32, i32* %6
ret i32 %39
}

LLVM IR (-O2):
@.str = [7 x i8] c"lookup\00"
@.str.1 = [7 x i8] c"update\00"
@.str.2 = [16 x i8] c"Invalid command\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @usage(i8* null)
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = add nsw i32 %0, -1
%13 = tail call i32 @lookup(i32 %12, i8** %7)
br label %23
14: ; preds = %6
%15 = load i8*, i8** %7
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = add nsw i32 %0, -1
%20 = tail call i32 @update(i32 %19, i8** %7)
br label %23
21: ; preds = %14
%22 = tail call i32 @usage(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %18, %21, %11
%24 = phi i32 [ %13, %11 ], [ %20, %18 ], [ -1, %21 ]
ret i32 %24
}