#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*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
int program_file(char *);
int read_to_file(char *);
int /*<<< orphan*/ show_usage();
int /*<<< orphan*/ strcmp(char *, char *);
int verify_file(char *);
int main(int argc, char *argv[]) {
  if (argc < 2 || argc > 3) {
    show_usage();
    exit(1);
  }
  if (argc == 3) {
    if (!strcmp(argv[1], "--verify")) {
      exit(verify_file(argv[2]));
    }
    if (!strcmp(argv[1], "--program")) {
      exit(program_file(argv[2]));
    }
    if (!strcmp(argv[1], "--read")) {
      exit(read_to_file(argv[2]));
    }
    printf("Unknown option %s\n", argv[1]);
    show_usage();
    exit(1);
  }
  if (argc == 2) {
    exit(program_file(argv[1]));
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     119a <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jle    11ab <main+0x3b>
mov    $0x0,%al
call   1070 <show_usage@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    126d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <verify_file@plt>
mov    %eax,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe14(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1217 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <program_file@plt>
mov    %eax,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xded(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1248 <main+0xd8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <read_to_file@plt>
mov    %eax,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdc3(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <show_usage@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    128b <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <program_file@plt>
mov    %eax,%edi
call   1090 <exit@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    -0x4(%rdi),%eax
cmp    $0xfffffffd,%eax
ja     118d <main+0x1d>
xor    %eax,%eax
call   1070 <show_usage@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %rsi,%rbx
mov    0x8(%rsi),%r14
cmp    $0x3,%edi
jne    11bc <main+0x4c>
lea    0xe60(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11cb <main+0x5b>
mov    0x10(%rbx),%rdi
call   1030 <verify_file@plt>
mov    %eax,%edi
call   1090 <exit@plt>
mov    %r14,%rdi
call   1080 <program_file@plt>
mov    %eax,%edi
call   1090 <exit@plt>
lea    0xe37(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11e4 <main+0x74>
mov    0x10(%rbx),%rdi
jmp    11bf <main+0x4f>
lea    0xe28(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1207 <main+0x97>
mov    0x10(%rbx),%rdi
call   1040 <read_to_file@plt>
mov    %eax,%edi
call   1090 <exit@plt>
lea    0xe0c(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
jmp    117c <main+0xc>

LLVM IR (-O0):
@.str = [9 x i8] c"--verify\00"
@.str.1 = [10 x i8] c"--program\00"
@.str.2 = [7 x i8] c"--read\00"
@.str.3 = [19 x i8] c"Unknown option %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %8, %2
%12 = call i32 (...) @show_usage()
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %8
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %60
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @verify_file(i8* %26)
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %17
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @program_file(i8* %38)
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %29
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %53, label %47
47: ; preds = %41
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @read_to_file(i8* %50)
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %41
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = call i32 (...) @show_usage()
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %14
%61 = load i32, i32* %4
%62 = icmp eq i32 %61, 2
br i1 %62, label %63, label %69
63: ; preds = %60
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call i32 @program_file(i8* %66)
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %60
ret i32 1
}

LLVM IR (-O2):
@.str = [9 x i8] c"--verify\00"
@.str.1 = [10 x i8] c"--program\00"
@.str.2 = [7 x i8] c"--read\00"
@.str.3 = [19 x i8] c"Unknown option %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -4
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 (...) @show_usage()
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = icmp eq i32 %0, 3
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
br i1 %9, label %12, label %40
12: ; preds = %8
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @verify_file(i8* %17)
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %12
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @program_file(i8* %25)
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %20
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32 @read_to_file(i8* %33)
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %28
%37 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%38 = tail call i32 (...) @show_usage()
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %8
%41 = tail call i32 @program_file(i8* %11)
%42 = tail call i32 @exit(i32 %41)
unreachable
}