#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*/ argvfile(int, char **, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ file_open(int /*<<< orphan*/);
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ shell();
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int opt;
  int p = 0;
  while ((opt = getopt(argc, argv, "hip")) != -1) {
    switch (opt) {
    case 'h':
      printf("Usage: ./hq9fp [-h(print this help)] [-i(launch shell)] "
             "[-p(source from filename)] [FILE...]");
      exit(0);
    case 'i':
      shell();
      exit(0);
    case 'p':
      if (optind == argc) {
        printf("Usage: ./hq9fp [-h(print this help)] [-i(launch shell)] "
               "[-p(source from filename)] [FILE...]");
      } else {
        p = 1;
        argvfile(argc, argv, p);
      }
      exit(0);
    }
  }
  if (optind == argc) {
    file_open(stdin);
  } else {
    argvfile(argc, argv, p);
  }
  exit(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)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1238 <main+0xd8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x68,%eax
je     11d2 <main+0x72>
jmp    11b0 <main+0x50>
mov    -0x1c(%rbp),%eax
sub    $0x69,%eax
je     11e5 <main+0x85>
jmp    11c1 <main+0x61>
mov    -0x1c(%rbp),%eax
sub    $0x70,%eax
je     11f3 <main+0x93>
jmp    1233 <main+0xd3>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1080 <shell@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    1216 <main+0xb6>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
jmp    122c <main+0xcc>
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1050 <argvfile@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    117d <main+0x1d>
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    125d <main+0xfd>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
call   1030 <file_open@plt>
jmp    126c <main+0x10c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1050 <argvfile@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe90(%rip),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
cmp    $0x68,%eax
jg     1190 <main+0x30>
cmp    $0xffffffff,%eax
je     11b8 <main+0x58>
cmp    $0x68,%eax
jne    1170 <main+0x10>
jmp    11a5 <main+0x45>
xchg   %ax,%ax
cmp    $0x69,%eax
je     11d8 <main+0x78>
cmp    $0x70,%eax
jne    1170 <main+0x10>
mov    0x2e3f(%rip),%rax
cmp    %ebp,(%rax)
jne    11e6 <main+0x86>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2e21(%rip),%rax
cmp    %ebp,(%rax)
jne    11f2 <main+0x92>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1030 <file_open@plt>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
call   1080 <shell@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
jmp    11f9 <main+0x99>
mov    %ebp,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1050 <argvfile@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"hip\00"
@.str.1 = [93 x i8] c"Usage: ./hq9fp [-h(print this help)] [-i(launch shell)] [-p(source from filename)] [FILE...]\00"
@optind = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %34, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %35
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %34 [
i32 104, label %15
i32 105, label %18
i32 112, label %21
]
15: ; preds = %13
%16 = call i32 @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %13
%19 = call i32 (...) @shell()
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %13
%22 = load i32, i32* @optind
%23 = load i32, i32* %4
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0))
br label %32
27: ; preds = %21
store i32 1, i32* %7
%28 = load i32, i32* %4
%29 = load i8**, i8*** %5
%30 = load i32, i32* %7
%31 = call i32 @argvfile(i32 %28, i8** %29, i32 %30)
br label %32
32: ; preds = %27, %25
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %13
br label %8
35: ; preds = %8
%36 = load i32, i32* @optind
%37 = load i32, i32* %4
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* @stdin
%41 = call i32 @file_open(i32 %40)
br label %47
42: ; preds = %35
%43 = load i32, i32* %4
%44 = load i8**, i8*** %5
%45 = load i32, i32* %7
%46 = call i32 @argvfile(i32 %43, i8** %44, i32 %45)
br label %47
47: ; preds = %42, %39
%48 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [4 x i8] c"hip\00"
@.str.1 = [93 x i8] c"Usage: ./hq9fp [-h(print this help)] [-i(launch shell)] [-p(source from filename)] [FILE...]\00"
@optind = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %3 [
i32 -1, label %20
i32 104, label %5
i32 105, label %8
i32 112, label %11
]
5: ; preds = %3
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %3
%9 = tail call i32 (...) @shell()
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %3
%12 = load i32, i32* @optind
%13 = icmp eq i32 %12, %0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %11
%17 = tail call i32 @argvfile(i32 %0, i8** %1, i32 1)
br label %18
18: ; preds = %16, %14
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %3
%21 = load i32, i32* @optind
%22 = icmp eq i32 %21, %0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @stdin
%25 = tail call i32 @file_open(i32 %24)
br label %28
26: ; preds = %20
%27 = tail call i32 @argvfile(i32 %0, i8** %1, i32 0)
br label %28
28: ; preds = %26, %23
%29 = tail call i32 @exit(i32 0)
unreachable
}