#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*/ abort();
int /*<<< orphan*/ create_fs(char *);
int /*<<< orphan*/ exit(int);
int getopt(int, char **, char *);
int /*<<< orphan*/ open_fs(char *);
char *optarg;
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int c;
  int create_flag = 0;
  int open_flag = 0;
  char *fname = NULL;
  while ((c = getopt(argc, argv, "cof:")) != -1) {
    switch (c) {
    case 'c':
      create_flag = 1;
      break;
    case 'o':
      open_flag = 1;
      break;
    case 'f':
      fname = optarg;
      break;
    default:
      abort();
    }
  }
  if (create_flag && open_flag) {
    printf("Can only open, or create new. Can't choose both!\n");
    exit(1);
  }
  if (fname == NULL) {
    printf("Please specify a filename with -f\n");
    exit(1);
  }
  if (create_flag) {
    create_fs(fname);
    exit(1);
  }
  if (open_flag) {
    open_fs(fname);
    exit(1);
  }
}


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)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe66(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1218 <main+0xb8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x63,%eax
je     11e1 <main+0x81>
jmp    11bf <main+0x5f>
mov    -0x2c(%rbp),%eax
sub    $0x66,%eax
je     11f9 <main+0x99>
jmp    11d0 <main+0x70>
mov    -0x2c(%rbp),%eax
sub    $0x6f,%eax
je     11ed <main+0x8d>
jmp    120c <main+0xac>
movl   $0x1,-0x18(%rbp)
jmp    1213 <main+0xb3>
movl   $0x1,-0x1c(%rbp)
jmp    1213 <main+0xb3>
mov    0x2df8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1213 <main+0xb3>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    118c <main+0x2c>
cmpl   $0x0,-0x18(%rbp)
je     1242 <main+0xe2>
cmpl   $0x0,-0x1c(%rbp)
je     1242 <main+0xe2>
lea    0xdd2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpq   $0x0,-0x28(%rbp)
jne    1263 <main+0x103>
lea    0xde3(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
je     1280 <main+0x120>
mov    -0x28(%rbp),%rdi
call   1060 <create_fs@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x1c(%rbp)
je     129d <main+0x13d>
mov    -0x28(%rbp),%rdi
call   1040 <open_fs@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%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
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xe83(%rip),%r15
mov    0x2e74(%rip),%r12
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    1194 <main+0x34>
nopl   0x0(%rax)
mov    (%r12),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    $0x66,%eax
je     1190 <main+0x30>
cmp    $0xffffffff,%eax
je     11c5 <main+0x65>
cmp    $0x63,%eax
je     11bd <main+0x5d>
cmp    $0x6f,%eax
jne    11f5 <main+0x95>
mov    $0x1,%r13d
jmp    1194 <main+0x34>
mov    $0x1,%al
mov    %rax,(%rsp)
jmp    1194 <main+0x34>
test   %r13d,%r13d
setne  %al
mov    (%rsp),%rcx
and    %cl,%al
cmp    $0x1,%al
je     11fc <main+0x9c>
test   %r14,%r14
je     1205 <main+0xa5>
test   $0x1,%cl
jne    121b <main+0xbb>
test   %r13d,%r13d
jne    122d <main+0xcd>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>
lea    0xe24(%rip),%rdi
jmp    120c <main+0xac>
lea    0xdf9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    %r14,%rdi
call   1060 <create_fs@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    %r14,%rdi
call   1050 <open_fs@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"cof:\00"
@optarg = global i8* null
@.str.1 = [50 x i8] c"Can only open, or create new. Can't choose both!\0A\00"
@.str.2 = [35 x i8] c"Please specify a filename with -f\0A\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 i8*
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 i8* null, i8** %9
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %24
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %21 [
i32 99, label %17
i32 111, label %18
i32 102, label %19
]
17: ; preds = %15
store i32 1, i32* %7
br label %23
18: ; preds = %15
store i32 1, i32* %8
br label %23
19: ; preds = %15
%20 = load i8*, i8** @optarg
store i8* %20, i8** %9
br label %23
21: ; preds = %15
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %19, %18, %17
br label %10
24: ; preds = %10
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i32, i32* %8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %27, %24
%34 = load i8*, i8** %9
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %33
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i8*, i8** %9
%44 = call i32 @create_fs(i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = load i32, i32* %8
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i8*, i8** %9
%51 = call i32 @open_fs(i8* %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %46
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [5 x i8] c"cof:\00"
@optarg = global i8* null
@str = [34 x i8] c"Please specify a filename with -f\00"
@str.3 = [49 x i8] c"Can only open, or create new. Can't choose both!\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %10, %2
%4 = phi i1 [ false, %2 ], [ true, %10 ]
%5 = phi i32 [ 0, %2 ], [ %8, %10 ]
%6 = phi i8* [ null, %2 ], [ %11, %10 ]
br label %7
7: ; preds = %10, %3
%8 = phi i32 [ %5, %3 ], [ 1, %10 ]
%9 = phi i8* [ %6, %3 ], [ %11, %10 ]
br label %10
10: ; preds = %7, %13
%11 = phi i8* [ %14, %13 ], [ %9, %7 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %15 [
i32 -1, label %17
i32 99, label %3
i32 111, label %7
i32 102, label %13
]
13: ; preds = %10
%14 = load i8*, i8** @optarg
br label %10
15: ; preds = %10
%16 = tail call i32 (...) @abort()
unreachable
17: ; preds = %10
%18 = icmp ne i32 %8, 0
%19 = select i1 %4, i1 %18, i1 false
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.3, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %17
%24 = icmp eq i8* %11, null
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %23
br i1 %4, label %29, label %32
29: ; preds = %28
%30 = tail call i32 @create_fs(i8* %11)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %28
br i1 %18, label %33, label %36
33: ; preds = %32
%34 = tail call i32 @open_fs(i8* %11)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %32
ret i32 0
}