#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;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int *);
int /*<<< orphan*/ exit(int);
int getopt_long(int, char *const *, char *, struct option *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ no_argument;
int optind;
int /*<<< orphan*/ print_usage(char *const, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void parse_args(int argc, char *const argv[], int *verbosity, int *extract) {
  int opt;
  struct option longopts[] = {{"help", no_argument, NULL, 'h'},
                              {"verbose", no_argument, NULL, 'v'},
                              {"extract", no_argument, NULL, 'e'},
                              {NULL, 0, NULL, 0}};
  assert(verbosity);
  assert(extract);
  *verbosity = 0;
  *extract = 0;
  while ((opt = getopt_long(argc, argv, "hve", longopts, NULL)) != -1) {
    switch (opt) {
    case 'v':
      (*verbosity)++;
      break;
    case 'h':
      print_usage(argv[0], stdout);
      exit(0);
      break;
    case 'e':
      *extract = 1;
      break;
    default:
      print_usage(argv[0], stderr);
      exit(1);
      break;
    }
  }
  if (optind >= argc) {
    print_usage(argv[0], stderr);
    exit(1);
  }
  return;
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xe88(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %al,-0xa8(%rbp)
movq   $0x0,-0xa0(%rbp)
movl   $0x68,-0x98(%rbp)
add    $0x20,%rdi
lea    0xe57(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x88(%rbp)
movq   $0x0,-0x80(%rbp)
movl   $0x76,-0x78(%rbp)
add    $0x20,%rdi
lea    0xe2f(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0x2de7(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x68(%rbp)
movq   $0x0,-0x60(%rbp)
movl   $0x65,-0x58(%rbp)
add    $0x20,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0xb0(%rbp),%rcx
lea    0xdcd(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     12fc <parse_args+0x1ac>
mov    -0x24(%rbp),%eax
mov    %eax,-0xb4(%rbp)
sub    $0x65,%eax
je     12c9 <parse_args+0x179>
jmp    1275 <parse_args+0x125>
mov    -0xb4(%rbp),%eax
sub    $0x68,%eax
je     12ad <parse_args+0x15d>
jmp    1289 <parse_args+0x139>
mov    -0xb4(%rbp),%eax
sub    $0x76,%eax
jne    12d8 <parse_args+0x188>
jmp    129d <parse_args+0x14d>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    12f7 <parse_args+0x1a7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2d0d(%rip),%rax
mov    (%rax),%esi
call   1070 <print_usage@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    12f7 <parse_args+0x1a7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2cf2(%rip),%rax
mov    (%rax),%esi
call   1070 <print_usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1233 <parse_args+0xe3>
mov    0x2ce5(%rip),%rax
mov    (%rax),%eax
cmp    -0x4(%rbp),%eax
jl     132d <parse_args+0x1dd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
call   1070 <print_usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe9d(%rip),%rax
mov    %rax,(%rsp)
mov    0x2e62(%rip),%rax
mov    (%rax),%al
mov    %al,0x8(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x68,0x18(%rsp)
lea    0xe79(%rip),%rcx
mov    %rcx,0x20(%rsp)
mov    %al,0x28(%rsp)
movq   $0x0,0x30(%rsp)
movl   $0x76,0x38(%rsp)
lea    0xe60(%rip),%rcx
mov    %rcx,0x40(%rsp)
mov    %al,0x48(%rsp)
movq   $0x0,0x50(%rsp)
movl   $0x65,0x58(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
mov    %rdx,%rdi
call   1040 <assert@plt>
mov    %r14,%rdi
call   1040 <assert@plt>
movl   $0x0,(%r15)
movl   $0x0,(%r14)
lea    0xe1c(%rip),%r12
mov    %rsp,%r13
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0x67,%eax
jg     1230 <parse_args+0xf0>
cmp    $0x65,%eax
jne    123b <parse_args+0xfb>
movl   $0x1,(%r14)
jmp    1200 <parse_args+0xc0>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x76,%eax
jne    125d <parse_args+0x11d>
addl   $0x1,(%r15)
jmp    1200 <parse_args+0xc0>
cmp    $0xffffffff,%eax
jne    127a <parse_args+0x13a>
mov    0x2da1(%rip),%rax
cmp    %ebp,(%rax)
jge    127a <parse_args+0x13a>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x68,%eax
jne    127a <parse_args+0x13a>
mov    (%rbx),%rdi
mov    0x2d5c(%rip),%rax
mov    (%rax),%esi
call   1060 <print_usage@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    (%rbx),%rdi
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
call   1060 <print_usage@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [8 x i8] c"extract\00"
@.str.3 = [4 x i8] c"hve\00"
@stdout = global i32 0
@stderr = global i32 0
@optind = global i32 0
define void @parse_args(i32 %0, i8** %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [4 x %struct.option]
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%11 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %10, i64 0, i64 0
%12 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 1
%14 = load i32, i32* @no_argument
%15 = trunc i32 %14 to i8
store i8 %15, i8* %13
%16 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 2
store i32* null, i32** %16
%17 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 3
store i32 104, i32* %17
%18 = getelementptr inbounds %struct.option, %struct.option* %11, i64 1
%19 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 1
%21 = load i32, i32* @no_argument
%22 = trunc i32 %21 to i8
store i8 %22, i8* %20
%23 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 2
store i32* null, i32** %23
%24 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 3
store i32 118, i32* %24
%25 = getelementptr inbounds %struct.option, %struct.option* %18, i64 1
%26 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %26
%27 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 1
%28 = load i32, i32* @no_argument
%29 = trunc i32 %28 to i8
store i8 %29, i8* %27
%30 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 2
store i32* null, i32** %30
%31 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 3
store i32 101, i32* %31
%32 = getelementptr inbounds %struct.option, %struct.option* %25, i64 1
%33 = bitcast %struct.option* %32 to i8*
%34 = load i32*, i32** %7
%35 = call i32 @assert(i32* %34)
%36 = load i32*, i32** %8
%37 = call i32 @assert(i32* %36)
%38 = load i32*, i32** %7
store i32 0, i32* %38
%39 = load i32*, i32** %8
store i32 0, i32* %39
br label %40
40: ; preds = %68, %4
%41 = load i32, i32* %5
%42 = load i8**, i8*** %6
%43 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %10, i64 0, i64 0
%44 = call i32 @getopt_long(i32 %41, i8** %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %struct.option* %43, i32* null)
store i32 %44, i32* %9
%45 = icmp ne i32 %44, -1
br i1 %45, label %46, label %69
46: ; preds = %40
%47 = load i32, i32* %9
switch i32 %47, label %61 [
i32 118, label %48
i32 104, label %52
i32 101, label %59
]
48: ; preds = %46
%49 = load i32*, i32** %7
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
br label %68
52: ; preds = %46
%53 = load i8**, i8*** %6
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = load i32, i32* @stdout
%57 = call i32 @print_usage(i8* %55, i32 %56)
%58 = call i32 @exit(i32 0)
unreachable
59: ; preds = %46
%60 = load i32*, i32** %8
store i32 1, i32* %60
br label %68
61: ; preds = %46
%62 = load i8**, i8*** %6
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = load i32, i32* @stderr
%66 = call i32 @print_usage(i8* %64, i32 %65)
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %59, %48
br label %40
69: ; preds = %40
%70 = load i32, i32* @optind
%71 = load i32, i32* %5
%72 = icmp sge i32 %70, %71
br i1 %72, label %73, label %80
73: ; preds = %69
%74 = load i8**, i8*** %6
%75 = getelementptr inbounds i8*, i8** %74, i64 0
%76 = load i8*, i8** %75
%77 = load i32, i32* @stderr
%78 = call i32 @print_usage(i8* %76, i32 %77)
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %69
ret void
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [8 x i8] c"extract\00"
@.str.3 = [4 x i8] c"hve\00"
@stdout = global i32 0
@stderr = global i32 0
@optind = global i32 0
define void @parse_args(i32 %0, i8** %1, i32* %2, i32* %3) {
%5 = alloca [4 x %struct.option]
%6 = bitcast [4 x %struct.option]* %5 to i8*
%7 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0
%8 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 1
%10 = load i32, i32* @no_argument
%11 = trunc i32 %10 to i8
store i8 %11, i8* %9
%12 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 2
store i32* null, i32** %12
%13 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 3
store i32 104, i32* %13
%14 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 1
store i8 %11, i8* %15
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 2
store i32* null, i32** %16
%17 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 3
store i32 118, i32* %17
%18 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 1
store i8 %11, i8* %19
%20 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 2
store i32* null, i32** %20
%21 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 3
store i32 101, i32* %21
%22 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 3
%23 = bitcast %struct.option* %22 to i8*
%24 = tail call i32 @assert(i32* %2)
%25 = tail call i32 @assert(i32* %3)
store i32 0, i32* %2
store i32 0, i32* %3
br label %26
26: ; preds = %37, %4
%27 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %struct.option* %7, i32* null)
switch i32 %27, label %38 [
i32 -1, label %43
i32 118, label %28
i32 104, label %31
i32 101, label %36
]
28: ; preds = %26
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %37
31: ; preds = %26
%32 = load i8*, i8** %1
%33 = load i32, i32* @stdout
%34 = call i32 @print_usage(i8* %32, i32 %33)
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %26
store i32 1, i32* %3
br label %37
37: ; preds = %36, %28
br label %26
38: ; preds = %26
%39 = load i8*, i8** %1
%40 = load i32, i32* @stderr
%41 = call i32 @print_usage(i8* %39, i32 %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %26
%44 = load i32, i32* @optind
%45 = icmp slt i32 %44, %0
br i1 %45, label %51, label %46
46: ; preds = %43
%47 = load i8*, i8** %1
%48 = load i32, i32* @stderr
%49 = call i32 @print_usage(i8* %47, i32 %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %43
ret void
}