#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*/ editSheet(char *);
int /*<<< orphan*/ errx(int, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ listSheet(char *);
int /*<<< orphan*/ readSheet(char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int opt;
  int hflag = 0, eflag = 0, lflag = 0;
  if (argc == 1)
    listSheet("/home/user/.peek/");
  while ((opt = getopt(argc, argv, "he:")) != -1) {
    switch (opt) {
    case 'h':
      hflag = 1;
      break;
    case 'e':
      eflag = 1;
      break;
    default:
      errx(1, "see %s -h", argv[0]);
    }
  }
  if (hflag)
    usage();
  if (eflag)
    editSheet(argv[2]);
  if (argc == 2 && hflag == 0 && eflag == 0 && lflag == 0)
    readSheet(argv[1]);
  return 0;
}


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)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11a1 <main+0x41>
lea    0xe64(%rip),%rdi
call   1040 <listSheet@plt>
jmp    11a6 <main+0x46>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe5e(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     121f <main+0xbf>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x65,%eax
je     11f6 <main+0x96>
jmp    11d9 <main+0x79>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
jne    1202 <main+0xa2>
jmp    11ea <main+0x8a>
movl   $0x1,-0x18(%rbp)
jmp    121a <main+0xba>
movl   $0x1,-0x1c(%rbp)
jmp    121a <main+0xba>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    $0x1,%edi
lea    0xe01(%rip),%rsi
call   1050 <errx@plt>
jmp    11a6 <main+0x46>
cmpl   $0x0,-0x18(%rbp)
je     1230 <main+0xd0>
mov    $0x0,%al
call   1060 <usage@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1247 <main+0xe7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <editSheet@plt>
cmpl   $0x2,-0x8(%rbp)
jne    127c <main+0x11c>
cmpl   $0x0,-0x18(%rbp)
jne    127c <main+0x11c>
cmpl   $0x0,-0x1c(%rbp)
jne    127c <main+0x11c>
cmpl   $0x0,-0x20(%rbp)
jne    127c <main+0x11c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <readSheet@plt>
xor    %eax,%eax
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,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jne    1181 <main+0x21>
lea    0xe84(%rip),%rdi
call   1040 <listSheet@plt>
xor    %r12d,%r12d
mov    $0x1,%r13b
lea    0xe84(%rip),%r14
lea    0xe81(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     11db <main+0x7b>
cmp    $0x65,%eax
je     11ce <main+0x6e>
cmp    $0x68,%eax
je     11d3 <main+0x73>
mov    (%rbx),%rdx
mov    $0x1,%edi
mov    %r15,%rsi
call   1050 <errx@plt>
jmp    11a0 <main+0x40>
xor    %r13d,%r13d
jmp    11a0 <main+0x40>
mov    $0x1,%r12d
jmp    11a0 <main+0x40>
test   %r12d,%r12d
je     11e7 <main+0x87>
xor    %eax,%eax
call   1060 <usage@plt>
test   $0x1,%r13b
je     1202 <main+0xa2>
cmp    $0x2,%ebp
jne    120b <main+0xab>
test   %r12d,%r12d
jne    120b <main+0xab>
mov    0x8(%rbx),%rdi
call   1030 <readSheet@plt>
jmp    120b <main+0xab>
mov    0x10(%rbx),%rdi
call   1080 <editSheet@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"/home/user/.peek/\00"
@.str.1 = [4 x i8] c"he:\00"
@.str.2 = [10 x i8] c"see %s -h\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @listSheet(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
br label %15
15: ; preds = %29, %14
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %6
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %30
20: ; preds = %15
%21 = load i32, i32* %6
switch i32 %21, label %24 [
i32 104, label %22
i32 101, label %23
]
22: ; preds = %20
store i32 1, i32* %7
br label %29
23: ; preds = %20
store i32 1, i32* %8
br label %29
24: ; preds = %20
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @errx(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %24, %23, %22
br label %15
30: ; preds = %15
%31 = load i32, i32* %7
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (...) @usage()
br label %35
35: ; preds = %33, %30
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @editSheet(i8* %41)
br label %43
43: ; preds = %38, %35
%44 = load i32, i32* %4
%45 = icmp eq i32 %44, 2
br i1 %45, label %46, label %60
46: ; preds = %43
%47 = load i32, i32* %7
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %60
49: ; preds = %46
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %49
%53 = load i32, i32* %9
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 @readSheet(i8* %58)
br label %60
60: ; preds = %55, %52, %49, %46, %43
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"/home/user/.peek/\00"
@.str.1 = [4 x i8] c"he:\00"
@.str.2 = [10 x i8] c"see %s -h\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @listSheet(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
br label %7
7: ; preds = %12, %6
%8 = phi i1 [ true, %6 ], [ false, %12 ]
%9 = phi i32 [ 0, %6 ], [ %11, %12 ]
br label %10
10: ; preds = %12, %7
%11 = phi i32 [ %9, %7 ], [ 1, %12 ]
br label %12
12: ; preds = %10, %14
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
switch i32 %13, label %14 [
i32 -1, label %17
i32 104, label %10
i32 101, label %7
]
14: ; preds = %12
%15 = load i8*, i8** %1
%16 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %12
17: ; preds = %12
%18 = icmp eq i32 %11, 0
br i1 %18, label %21, label %19
19: ; preds = %17
%20 = tail call i32 (...) @usage()
br label %21
21: ; preds = %19, %17
br i1 %8, label %26, label %22
22: ; preds = %21
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32 @editSheet(i8* %24)
br label %33
26: ; preds = %21
%27 = icmp eq i32 %0, 2
%28 = select i1 %27, i1 %18, i1 false
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = getelementptr inbounds i8*, i8** %1, i64 1
%31 = load i8*, i8** %30
%32 = tail call i32 @readSheet(i8* %31)
br label %33
33: ; preds = %22, %29, %26
ret i32 0
}