#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ member_1;
};
typedef int /*<<< orphan*/ options;

/* Variables and functions */
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ load_and_simulate(char *);
#define no_argument 128
int optind;
int /*<<< orphan*/ usage(char *, struct option *, int);
int main(int argc, char *argv[]) {
  static struct option options[] = {{"help", no_argument, NULL, 'h'},
                                    {NULL, 0, NULL, 0}};
  int c, optidx = 0;
  while ((c = getopt_long(argc, argv, "h", options, &optidx)) != -1) {
    switch (c) {
    default:
    case 0:
      break;
    case 'h':
      usage(argv[0], options, sizeof(options) / sizeof(options[0]) - 1);
    }
  }
  if (argc != optind + 1) {
    usage(argv[0], options, sizeof(options) / sizeof(options[0]) - 1);
  }
  load_and_simulate(argv[optind]);
  return 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    0xeaa(%rip),%rdx
lea    0x2ede(%rip),%rcx
lea    -0x18(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11c2 <main+0x92>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     11a0 <main+0x70>
jmp    118a <main+0x5a>
mov    -0x1c(%rbp),%eax
sub    $0x68,%eax
je     11a5 <main+0x75>
jmp    119b <main+0x6b>
jmp    11a0 <main+0x70>
jmp    11bd <main+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0x2e8d(%rip),%rsi
mov    $0x1,%edx
call   1040 <usage@plt>
jmp    114d <main+0x1d>
mov    -0x8(%rbp),%eax
mov    0x2e1c(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     11f1 <main+0xc1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0x2e59(%rip),%rsi
mov    $0x1,%edx
call   1040 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2dec(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <load_and_simulate@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
lea    0xeb5(%rip),%r14
lea    0x2ee9(%rip),%r15
lea    0xc(%rsp),%r12
jmp    1170 <main+0x40>
xchg   %ax,%ax
mov    (%rbx),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1040 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1030 <getopt_long@plt>
cmp    $0x68,%eax
je     1160 <main+0x30>
cmp    $0xffffffff,%eax
jne    1170 <main+0x40>
mov    0x2e54(%rip),%r14
mov    (%r14),%eax
lea    0x1(%rax),%ecx
cmp    %ebp,%ecx
je     11b5 <main+0x85>
mov    (%rbx),%rdi
lea    0x2e98(%rip),%rsi
mov    $0x1,%edx
call   1040 <usage@plt>
mov    (%r14),%eax
cltq
mov    (%rbx,%rax,8),%rdi
call   1050 <load_and_simulate@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@main.options = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [2 x i8] c"h\00"
@optind = 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 = %22, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt_long(i32 %9, i8** %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32* %7)
store i32 %11, i32* %6
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %15 [
i32 0, label %16
i32 104, label %17
]
15: ; preds = %13
br label %16
16: ; preds = %13, %15
br label %22
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @usage(i8* %20, %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32 1)
br label %22
22: ; preds = %17, %16
br label %8
23: ; preds = %8
%24 = load i32, i32* %4
%25 = load i32, i32* @optind
%26 = add nsw i32 %25, 1
%27 = icmp ne i32 %24, %26
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @usage(i8* %31, %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32 1)
br label %33
33: ; preds = %28, %23
%34 = load i8**, i8*** %5
%35 = load i32, i32* @optind
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @load_and_simulate(i8* %38)
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@main.options = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [2 x i8] c"h\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %7, %2
%6 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32* %3)
switch i32 %6, label %7 [
i32 -1, label %11
i32 104, label %8
]
7: ; preds = %5, %8
br label %5
8: ; preds = %5
%9 = load i8*, i8** %1
%10 = call i32 @usage(i8* %9, %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32 1)
br label %7
11: ; preds = %5
%12 = load i32, i32* @optind
%13 = add nsw i32 %12, 1
%14 = icmp eq i32 %13, %0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i8*, i8** %1
%17 = call i32 @usage(i8* %16, %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32 1)
%18 = load i32, i32* @optind
br label %19
19: ; preds = %15, %11
%20 = phi i32 [ %18, %15 ], [ %12, %11 ]
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @load_and_simulate(i8* %23)
ret i32 0
}