#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*/ append_note(char *, char *);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ list_notes();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
scalar_t__ strstr(char *, char *);
int /*<<< orphan*/ write_note(char *, char *);
int main(int argc, char *argv[]) {
  int i;
  char file[100], opt = '\0';
  for (i = 1; i < argc && opt == '\0'; i++)
    if (argv[i][0] == '-' && argv[i][1])
      opt = argv[i][1];
  if (argc == 1) {
    write_note(file, NULL);
    return 0;
  }
  if (!opt) {
    if (argc > 2)
      printf("***Ignoring extra arguments.");
    if (strstr(argv[1], " ")) {
      append_note(file, argv[1]);
    } else if (argv[1][0] != '-') {
      write_note(file, argv[1]);
    } else
      die("Empty option flag.");
  } else {
    switch (opt) {
    case 'l':
      if (argv[2]) {
        printf("Running option \'-%c\'. ", opt);
        puts("Ignoring other arguments.");
      }
      list_notes();
      break;
    case 'v':
      if (argv[2])
        puts("***Ignoring extra arguments.");
      printf("%s, (c) %s Ryan Donnelly\n", "rnote-0.5", "2016");
      break;
    default:
      die("Not a valid option.");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x81(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x82(%rbp)
jge    11be <main+0x4e>
movsbl -0x81(%rbp),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x82(%rbp)
mov    -0x82(%rbp),%al
test   $0x1,%al
jne    11d1 <main+0x61>
jmp    122a <main+0xba>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1217 <main+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1217 <main+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x1(%rax),%al
mov    %al,-0x81(%rbp)
jmp    121c <main+0xac>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1197 <main+0x27>
cmpl   $0x1,-0x8(%rbp)
jne    124d <main+0xdd>
lea    -0x80(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <write_note@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <main+0x235>
cmpb   $0x0,-0x81(%rbp)
jne    12e6 <main+0x176>
cmpl   $0x2,-0x8(%rbp)
jle    1272 <main+0x102>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc4(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     12a6 <main+0x136>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1070 <append_note@plt>
jmp    12e1 <main+0x171>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     12d0 <main+0x160>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <write_note@plt>
jmp    12dc <main+0x16c>
lea    0xd46(%rip),%rdi
call   1080 <die@plt>
jmp    12e1 <main+0x171>
jmp    139e <main+0x22e>
movsbl -0x81(%rbp),%eax
mov    %eax,-0x88(%rbp)
sub    $0x6c,%eax
je     1315 <main+0x1a5>
jmp    1301 <main+0x191>
mov    -0x88(%rbp),%eax
sub    $0x76,%eax
je     1351 <main+0x1e1>
jmp    138d <main+0x21d>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1345 <main+0x1d5>
movsbl -0x81(%rbp),%esi
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd07(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1060 <list_notes@plt>
jmp    1399 <main+0x229>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     136c <main+0x1fc>
lea    0xc99(%rip),%rdi
call   1040 <puts@plt>
lea    0xcee(%rip),%rdi
lea    0xd01(%rip),%rsi
lea    0xd04(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1399 <main+0x229>
lea    0xcf6(%rip),%rdi
call   1080 <die@plt>
jmp    139e <main+0x22e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     120f <main+0x9f>
mov    %edi,%eax
mov    $0x2,%edx
nopl   0x0(%rax,%rax,1)
mov    -0x8(%rbx,%rdx,8),%rcx
cmpb   $0x2d,(%rcx)
jne    11b0 <main+0x40>
movzbl 0x1(%rcx),%ecx
cmp    %rax,%rdx
jb     11b7 <main+0x47>
jmp    11bf <main+0x4f>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ecx,%ecx
cmp    %rax,%rdx
jae    11bf <main+0x4f>
add    $0x1,%rdx
test   %cl,%cl
je     1190 <main+0x20>
cmp    $0x1,%edi
je     1214 <main+0xa4>
test   %cl,%cl
je     1223 <main+0xb3>
movsbl %cl,%eax
cmp    $0x76,%eax
je     1271 <main+0x101>
cmp    $0x6c,%eax
jne    12a2 <main+0x132>
cmpq   $0x0,0x10(%rbx)
je     1203 <main+0x93>
lea    0xe45(%rip),%rdi
mov    $0x6c,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <list_notes@plt>
jmp    12ae <main+0x13e>
cmp    $0x1,%edi
jne    1236 <main+0xc6>
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <write_note@plt>
jmp    12ae <main+0x13e>
cmp    $0x3,%edi
jl     1236 <main+0xc6>
lea    0xdd1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe04(%rip),%rsi
call   1090 <strstr@plt>
mov    0x8(%rbx),%rsi
test   %rax,%rax
je     1259 <main+0xe9>
mov    %rsp,%rdi
call   1070 <append_note@plt>
jmp    12ae <main+0x13e>
cmpb   $0x2d,(%rsi)
jne    1267 <main+0xf7>
lea    0xdb8(%rip),%rdi
jmp    12a9 <main+0x139>
mov    %rsp,%rdi
call   1030 <write_note@plt>
jmp    12ae <main+0x13e>
cmpq   $0x0,0x10(%rbx)
je     1284 <main+0x114>
lea    0xd81(%rip),%rdi
call   1040 <puts@plt>
lea    0xdd6(%rip),%rdi
lea    0xde9(%rip),%rsi
lea    0xdec(%rip),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12ae <main+0x13e>
lea    0xde1(%rip),%rdi
call   1080 <die@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"***Ignoring extra arguments.\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [19 x i8] c"Empty option flag.\00"
@.str.3 = [23 x i8] c"Running option '-%c'. \00"
@.str.4 = [26 x i8] c"Ignoring other arguments.\00"
@.str.5 = [26 x i8] c"%s, (c) %s Ryan Donnelly\0A\00"
@.str.6 = [10 x i8] c"rnote-0.5\00"
@.str.7 = [5 x i8] c"2016\00"
@.str.8 = [20 x i8] c"Not a valid option.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %8
store i32 1, i32* %6
br label %9
9: ; preds = %48, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8, i8* %8
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br label %17
17: ; preds = %13, %9
%18 = phi i1 [ false, %9 ], [ %16, %13 ]
br i1 %18, label %19, label %51
19: ; preds = %17
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 45
br i1 %28, label %29, label %47
29: ; preds = %19
%30 = load i8**, i8*** %5
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %29
%40 = load i8**, i8*** %5
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i8, i8* %45
store i8 %46, i8* %8
br label %47
47: ; preds = %39, %29, %19
br label %48
48: ; preds = %47
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %9
51: ; preds = %17
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 1
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%56 = call i32 @write_note(i8* %55, i8* null)
store i32 0, i32* %3
br label %123
57: ; preds = %51
%58 = load i8, i8* %8
%59 = icmp ne i8 %58, 0
br i1 %59, label %95, label %60
60: ; preds = %57
%61 = load i32, i32* %4
%62 = icmp sgt i32 %61, 2
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %65
65: ; preds = %63, %60
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i64 @strstr(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %65
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 1
%75 = load i8*, i8** %74
%76 = call i32 @append_note(i8* %72, i8* %75)
br label %94
77: ; preds = %65
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = getelementptr inbounds i8, i8* %80, i64 0
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp ne i32 %83, 45
br i1 %84, label %85, label %91
85: ; preds = %77
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 1
%89 = load i8*, i8** %88
%90 = call i32 @write_note(i8* %86, i8* %89)
br label %93
91: ; preds = %77
%92 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %93
93: ; preds = %91, %85
br label %94
94: ; preds = %93, %71
br label %122
95: ; preds = %57
%96 = load i8, i8* %8
%97 = sext i8 %96 to i32
switch i32 %97, label %119 [
i32 108, label %98
i32 118, label %110
]
98: ; preds = %95
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 2
%101 = load i8*, i8** %100
%102 = icmp ne i8* %101, null
br i1 %102, label %103, label %108
103: ; preds = %98
%104 = load i8, i8* %8
%105 = sext i8 %104 to i32
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %105)
%107 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %108
108: ; preds = %103, %98
%109 = call i32 (...) @list_notes()
br label %121
110: ; preds = %95
%111 = load i8**, i8*** %5
%112 = getelementptr inbounds i8*, i8** %111, i64 2
%113 = load i8*, i8** %112
%114 = icmp ne i8* %113, null
br i1 %114, label %115, label %117
115: ; preds = %110
%116 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %117
117: ; preds = %115, %110
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %121
119: ; preds = %95
%120 = call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %121
121: ; preds = %119, %117, %108
br label %122
122: ; preds = %121, %94
store i32 0, i32* %3
br label %123
123: ; preds = %122, %54
%124 = load i32, i32* %3
ret i32 %124
}

LLVM IR (-O2):
@.str = [29 x i8] c"***Ignoring extra arguments.\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [19 x i8] c"Empty option flag.\00"
@.str.3 = [23 x i8] c"Running option '-%c'. \00"
@.str.4 = [26 x i8] c"Ignoring other arguments.\00"
@.str.5 = [26 x i8] c"%s, (c) %s Ryan Donnelly\0A\00"
@.str.6 = [10 x i8] c"rnote-0.5\00"
@.str.7 = [5 x i8] c"2016\00"
@.str.8 = [20 x i8] c"Not a valid option.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %26
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %17
%9 = phi i64 [ 1, %6 ], [ %19, %17 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = load i8, i8* %15
br label %17
17: ; preds = %14, %8
%18 = phi i8 [ 0, %8 ], [ %16, %14 ]
%19 = add nuw nsw i64 %9, 1
%20 = icmp ult i64 %19, %7
%21 = icmp eq i8 %18, 0
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %8, label %23
23: ; preds = %17
%24 = sext i8 %18 to i32
%25 = icmp eq i32 %0, 1
br i1 %25, label %28, label %30
26: ; preds = %2
%27 = icmp eq i32 %0, 1
br i1 %27, label %28, label %35
28: ; preds = %26, %23
%29 = call i32 @write_note(i8* %4, i8* null)
br label %70
30: ; preds = %23
br i1 %21, label %31, label %50
31: ; preds = %30
%32 = icmp sgt i32 %0, 2
br i1 %32, label %33, label %35
33: ; preds = %31
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %26, %33, %31
%36 = getelementptr inbounds i8*, i8** %1, i64 1
%37 = load i8*, i8** %36
%38 = tail call i64 @strstr(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
%40 = load i8*, i8** %36
br i1 %39, label %43, label %41
41: ; preds = %35
%42 = call i32 @append_note(i8* %4, i8* %40)
br label %70
43: ; preds = %35
%44 = load i8, i8* %40
%45 = icmp eq i8 %44, 45
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 @write_note(i8* %4, i8* %40)
br label %70
48: ; preds = %43
%49 = tail call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %70
50: ; preds = %30
switch i32 %24, label %68 [
i32 108, label %51
i32 118, label %60
]
51: ; preds = %50
%52 = getelementptr inbounds i8*, i8** %1, i64 2
%53 = load i8*, i8** %52
%54 = icmp eq i8* %53, null
br i1 %54, label %58, label %55
55: ; preds = %51
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 108)
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %55, %51
%59 = tail call i32 (...) @list_notes()
br label %70
60: ; preds = %50
%61 = getelementptr inbounds i8*, i8** %1, i64 2
%62 = load i8*, i8** %61
%63 = icmp eq i8* %62, null
br i1 %63, label %66, label %64
64: ; preds = %60
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %66
66: ; preds = %64, %60
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %70
68: ; preds = %50
%69 = tail call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %70
70: ; preds = %46, %48, %41, %68, %66, %58, %28
ret i32 0
}