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

/* Variables and functions */
int /*<<< orphan*/ abort();
int getopt_long(int, char **, char const *const, struct option const *,
                int /*<<< orphan*/ *);
char *optarg;
int /*<<< orphan*/ print_usage(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sscanf(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void parse_options(int argc, char *argv[], uint32_t *location,
                   const char **output_filename, int *raw, int *sign,
                   int *verbose) {
  int next_option;
  const char *const short_options = "ho:rs:v";
  const struct option long_options[] = {
      {"help", 0, NULL, 'h'}, {"output", 1, NULL, 'o'},  {"raw", 0, NULL, 'r'},
      {"sign", 1, NULL, 's'}, {"verbose", 1, NULL, 'v'}, {NULL, 0, NULL, 0}};
  do {
    next_option = getopt_long(argc, argv, short_options, long_options, NULL);
    switch (next_option) {
    case 'h':
      print_usage(argv[0], stdout, 0);
      break;
    case 'o':
      *output_filename = optarg;
      break;
    case 'r':
      *raw = 1;
      break;
    case 's':
      *sign = 1;
      sscanf(optarg, "%x", location);
      break;
    case 'v':
      *verbose = 1;
      break;
    case '?':
      print_usage(argv[0], stderr, 1);
      break;
    case -1:
      break;
    default:
      abort();
      break;
    }
  } while (next_option != -1);
}


x86 assembly (clang, -O0):
<parse_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    -0xd0(%rbp),%rdi
lea    0x2be1(%rip),%rsi
mov    $0x90,%edx
call   1050 <memcpy@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe59(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0xd0(%rbp),%rcx
call   1040 <getopt_long@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0xd4(%rbp)
sub    $0xffffffff,%eax
je     12e2 <parse_options+0x192>
jmp    11d2 <parse_options+0x82>
mov    -0xd4(%rbp),%eax
sub    $0x3f,%eax
je     12c3 <parse_options+0x173>
jmp    11e6 <parse_options+0x96>
mov    -0xd4(%rbp),%eax
sub    $0x68,%eax
je     124a <parse_options+0xfa>
jmp    11fa <parse_options+0xaa>
mov    -0xd4(%rbp),%eax
sub    $0x6f,%eax
je     1266 <parse_options+0x116>
jmp    120e <parse_options+0xbe>
mov    -0xd4(%rbp),%eax
sub    $0x72,%eax
je     127c <parse_options+0x12c>
jmp    1222 <parse_options+0xd2>
mov    -0xd4(%rbp),%eax
sub    $0x73,%eax
je     128b <parse_options+0x13b>
jmp    1236 <parse_options+0xe6>
mov    -0xd4(%rbp),%eax
sub    $0x76,%eax
je     12b4 <parse_options+0x164>
jmp    12e7 <parse_options+0x197>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <print_usage@plt>
jmp    12ee <parse_options+0x19e>
mov    0x2d83(%rip),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    12ee <parse_options+0x19e>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    12ee <parse_options+0x19e>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
mov    0x2d54(%rip),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd7b(%rip),%rsi
call   1060 <sscanf@plt>
jmp    12ee <parse_options+0x19e>
mov    0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    12ee <parse_options+0x19e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2cff(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
call   1070 <print_usage@plt>
jmp    12ee <parse_options+0x19e>
jmp    12ee <parse_options+0x19e>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    12f3 <parse_options+0x1a3>
cmpl   $0xffffffff,-0x34(%rbp)
jne    1199 <parse_options+0x49>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x2bf0(%rip),%rsi
lea    0x20(%rsp),%r14
mov    $0x90,%edx
mov    %r14,%rdi
call   1050 <memcpy@plt>
lea    0xf47(%rip),%r15
lea    0xe60(%rip),%r12
mov    0x2e49(%rip),%r13
jmp    11c0 <parse_options+0x70>
mov    (%rbx),%rdi
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
call   1070 <print_usage@plt>
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x37,%ecx
ja     1248 <parse_options+0xf8>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    (%rbx),%rdi
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <print_usage@plt>
jmp    11c0 <parse_options+0x70>
mov    0x0(%r13),%rax
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
jmp    11c0 <parse_options+0x70>
mov    0x10(%rsp),%rax
movl   $0x1,(%rax)
jmp    11c0 <parse_options+0x70>
mov    0x18(%rsp),%rax
movl   $0x1,(%rax)
mov    0x0(%r13),%rdi
lea    0xedb(%rip),%rsi
mov    (%rsp),%rdx
call   1060 <sscanf@plt>
jmp    11c0 <parse_options+0x70>
mov    0xf0(%rsp),%rax
movl   $0x1,(%rax)
jmp    11c0 <parse_options+0x70>
cmp    $0xffffffff,%eax
jne    125f <parse_options+0x10f>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i8, i32* }
@.str = [8 x i8] c"ho:rs:v\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [7 x i8] c"output\00"
@.str.3 = [4 x i8] c"raw\00"
@.str.4 = [5 x i8] c"sign\00"
@.str.5 = [8 x i8] c"verbose\00"
@__const.parse_options.long_options = [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 104 to i32*) }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 111 to i32*) }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 114 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 115 to i32*) }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 118 to i32*) }, %struct.option zeroinitializer]
@stdout = global i32 0
@optarg = global i8* null
@.str.6 = [3 x i8] c"%x\00"
@stderr = global i32 0
define void @parse_options(i32 %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i8**
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca [6 x %struct.option]
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i32* %2, i32** %10
store i8** %3, i8*** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %16
%18 = bitcast [6 x %struct.option]* %17 to i8*
br label %19
19: ; preds = %53, %7
%20 = load i32, i32* %8
%21 = load i8**, i8*** %9
%22 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %17, i64 0, i64 0
%23 = call i32 @getopt_long(i32 %20, i8** %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), %struct.option* %22, i32* null)
store i32 %23, i32* %15
%24 = load i32, i32* %15
switch i32 %24, label %50 [
i32 104, label %25
i32 111, label %31
i32 114, label %34
i32 115, label %36
i32 118, label %41
i32 63, label %43
i32 -1, label %49
]
25: ; preds = %19
%26 = load i8**, i8*** %9
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = load i32, i32* @stdout
%30 = call i32 @print_usage(i8* %28, i32 %29, i32 0)
br label %52
31: ; preds = %19
%32 = load i8*, i8** @optarg
%33 = load i8**, i8*** %11
store i8* %32, i8** %33
br label %52
34: ; preds = %19
%35 = load i32*, i32** %12
store i32 1, i32* %35
br label %52
36: ; preds = %19
%37 = load i32*, i32** %13
store i32 1, i32* %37
%38 = load i8*, i8** @optarg
%39 = load i32*, i32** %10
%40 = call i32 @sscanf(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %39)
br label %52
41: ; preds = %19
%42 = load i32*, i32** %14
store i32 1, i32* %42
br label %52
43: ; preds = %19
%44 = load i8**, i8*** %9
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i32, i32* @stderr
%48 = call i32 @print_usage(i8* %46, i32 %47, i32 1)
br label %52
49: ; preds = %19
br label %52
50: ; preds = %19
%51 = call i32 (...) @abort()
unreachable
52: ; preds = %49, %43, %41, %36, %34, %31, %25
br label %53
53: ; preds = %52
%54 = load i32, i32* %15
%55 = icmp ne i32 %54, -1
br i1 %55, label %19, label %56
56: ; preds = %53
ret void
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i32* }
@.str = [8 x i8] c"ho:rs:v\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [7 x i8] c"output\00"
@.str.3 = [4 x i8] c"raw\00"
@.str.4 = [5 x i8] c"sign\00"
@.str.5 = [8 x i8] c"verbose\00"
@__const.parse_options.long_options = [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 104 to i32*) }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 111 to i32*) }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 114 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 115 to i32*) }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 118 to i32*) }, %struct.option zeroinitializer]
@stdout = global i32 0
@optarg = global i8* null
@.str.6 = [3 x i8] c"%x\00"
@stderr = global i32 0
define void @parse_options(i32 %0, i8** %1, i32* %2, i8** nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6) {
%8 = alloca [6 x %struct.option]
%9 = bitcast [6 x %struct.option]* %8 to i8*
%10 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %8, i64 0, i64 0
br label %11
11: ; preds = %17, %7
%12 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %struct.option* %10, i32* null)
switch i32 %12, label %29 [
i32 104, label %13
i32 111, label %18
i32 114, label %20
i32 115, label %21
i32 118, label %24
i32 63, label %25
i32 -1, label %31
]
13: ; preds = %11
%14 = load i8*, i8** %1
%15 = load i32, i32* @stdout
%16 = call i32 @print_usage(i8* %14, i32 %15, i32 0)
br label %17
17: ; preds = %13, %18, %20, %21, %24, %25
br label %11
18: ; preds = %11
%19 = load i8*, i8** @optarg
store i8* %19, i8** %3
br label %17
20: ; preds = %11
store i32 1, i32* %4
br label %17
21: ; preds = %11
store i32 1, i32* %5
%22 = load i8*, i8** @optarg
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
br label %17
24: ; preds = %11
store i32 1, i32* %6
br label %17
25: ; preds = %11
%26 = load i8*, i8** %1
%27 = load i32, i32* @stderr
%28 = call i32 @print_usage(i8* %26, i32 %27, i32 1)
br label %17
29: ; preds = %11
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %11
ret void
}