#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*/ cleanup();
int /*<<< orphan*/ getHistAllBashPids();
int /*<<< orphan*/ getHistSingleBashPid(char *);
int /*<<< orphan*/ help(char *);
int /*<<< orphan*/ init();
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  if (argc != 2) {
    usage(argv[0]);
  }
  char helpStr[] = "-help";
  char all[] = "-all";
  if (!strcmp(argv[1], helpStr)) {
    help(argv[0]);
  } else if (!strcmp(argv[1], all)) {
    init();
    getHistAllBashPids();
  } else {
    init();
    getHistSingleBashPid(argv[1]);
  }
  cleanup();
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     119c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    0xe5e(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe58(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    0xe50(%rip),%eax
mov    %eax,-0x1b(%rbp)
mov    0xe4b(%rip),%al
mov    %al,-0x17(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x16(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ed <main+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <help@plt>
jmp    1233 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1b(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    121a <main+0xaa>
mov    $0x0,%al
call   1060 <init@plt>
mov    $0x0,%al
call   1040 <getHistAllBashPids@plt>
jmp    122e <main+0xbe>
mov    $0x0,%al
call   1060 <init@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <getHistSingleBashPid@plt>
jmp    1233 <main+0xc3>
mov    $0x0,%al
call   1080 <cleanup@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
je     1184 <main+0x14>
mov    (%r14),%rdi
call   1070 <usage@plt>
mov    0x8(%r14),%rbx
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11c2 <main+0x52>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <init@plt>
test   %ebx,%ebx
je     11cc <main+0x5c>
mov    0x8(%r14),%rdi
call   1030 <getHistSingleBashPid@plt>
jmp    11d3 <main+0x63>
mov    (%r14),%rdi
call   1090 <help@plt>
jmp    11d3 <main+0x63>
xor    %eax,%eax
call   1040 <getHistAllBashPids@plt>
xor    %eax,%eax
call   1080 <cleanup@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.helpStr = [6 x i8] c"-help\00"
@__const.main.all = [5 x i8] c"-all\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i8]
%7 = alloca [5 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @usage(i8* %13)
br label %15
15: ; preds = %10, %2
%16 = bitcast [6 x i8]* %6 to i8*
%17 = bitcast [5 x i8]* %7 to i8*
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%22 = call i32 @strcmp(i8* %20, i8* %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %15
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @help(i8* %27)
br label %46
29: ; preds = %15
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%34 = call i32 @strcmp(i8* %32, i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %29
%37 = call i32 (...) @init()
%38 = call i32 (...) @getHistAllBashPids()
br label %45
39: ; preds = %29
%40 = call i32 (...) @init()
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 @getHistSingleBashPid(i8* %43)
br label %45
45: ; preds = %39, %36
br label %46
46: ; preds = %45, %24
%47 = call i32 (...) @cleanup()
ret i32 0
}

LLVM IR (-O2):
@__const.main.helpStr = [6 x i8] c"-help\00"
@__const.main.all = [5 x i8] c"-all\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @__const.main.helpStr, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %1
%14 = tail call i32 @help(i8* %13)
br label %24
15: ; preds = %7
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @__const.main.all, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
%18 = tail call i32 (...) @init()
br i1 %17, label %19, label %21
19: ; preds = %15
%20 = tail call i32 (...) @getHistAllBashPids()
br label %24
21: ; preds = %15
%22 = load i8*, i8** %8
%23 = tail call i32 @getHistSingleBashPid(i8* %22)
br label %24
24: ; preds = %19, %21, %12
%25 = tail call i32 (...) @cleanup()
ret i32 0
}