#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 getopt_long(int, char **, char const *, struct option const *,
                int /*<<< orphan*/);
int /*<<< orphan*/ usage(char const *);
void parse_options(int argc, char *argv[], int *daemon) {
  int next_option;
  const char *program_name = argv[0];
  const char *short_options = "dhp:l:v:";
  const struct option long_options[] = {{"help", 0, NULL, 'h'},
                                        {"verbosity", 0, NULL, 'v'},
                                        {"daemon", 0, NULL, 'd'},
                                        {0, 0, 0, 0}};
  if (daemon) {
    *daemon = 0;
  }
  while ((next_option =
              getopt_long(argc, argv, short_options, long_options, 0)) != -1) {
    switch (next_option) {
    case 'd':
      if (daemon)
        *daemon = 1;
      break;
    case 'h':
      usage(program_name);
      break;
    case '?':
      usage(program_name);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<parse_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    0xe93(%rip),%rax
mov    %rax,-0xb0(%rbp)
movl   $0x68,-0x98(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x90(%rbp)
movl   $0x76,-0x78(%rbp)
lea    0xe75(%rip),%rax
mov    %rax,-0x70(%rbp)
movl   $0x64,-0x58(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c3 <parse_options+0x93>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11c8 <parse_options+0x98>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    -0xb0(%rbp),%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1263 <parse_options+0x133>
mov    -0x1c(%rbp),%eax
mov    %eax,-0xb4(%rbp)
sub    $0x3f,%eax
je     1255 <parse_options+0x125>
jmp    1205 <parse_options+0xd5>
mov    -0xb4(%rbp),%eax
sub    $0x64,%eax
je     122d <parse_options+0xfd>
jmp    1219 <parse_options+0xe9>
mov    -0xb4(%rbp),%eax
sub    $0x68,%eax
je     1247 <parse_options+0x117>
jmp    125e <parse_options+0x12e>
cmpq   $0x0,-0x18(%rbp)
je     1242 <parse_options+0x112>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    125e <parse_options+0x12e>
mov    -0x28(%rbp),%rdi
call   1050 <usage@plt>
jmp    125e <parse_options+0x12e>
mov    -0x28(%rbp),%rdi
call   1050 <usage@plt>
jmp    11c8 <parse_options+0x98>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%r15
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
lea    0xe9c(%rip),%rax
mov    %rax,(%rsp)
movl   $0x68,0x18(%rsp)
lea    0xe8e(%rip),%rax
mov    %rax,0x20(%rsp)
movl   $0x76,0x38(%rsp)
lea    0xe84(%rip),%rax
mov    %rax,0x40(%rsp)
movl   $0x64,0x58(%rsp)
test   %rdx,%rdx
je     11ad <parse_options+0x8d>
movl   $0x0,(%r14)
lea    0xe4c(%rip),%r12
mov    %rsp,%r13
jmp    11cd <parse_options+0xad>
nopl   0x0(%rax)
cmp    $0x3f,%eax
jne    11fd <parse_options+0xdd>
mov    %r15,%rdi
call   1040 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0x63,%eax
jle    11c0 <parse_options+0xa0>
cmp    $0x68,%eax
je     11c5 <parse_options+0xa5>
cmp    $0x64,%eax
jne    11cd <parse_options+0xad>
test   %r14,%r14
je     11cd <parse_options+0xad>
movl   $0x1,(%r14)
jmp    11cd <parse_options+0xad>
cmp    $0xffffffff,%eax
jne    11cd <parse_options+0xad>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [9 x i8] c"dhp:l:v:\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [10 x i8] c"verbosity\00"
@.str.3 = [7 x i8] c"daemon\00"
define void @parse_options(i32 %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [4 x %struct.option]
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %8
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %9
%14 = bitcast [4 x %struct.option]* %10 to i8*
%15 = bitcast i8* %14 to [4 x %struct.option]*
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %15, i32 0, i32 0
%17 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 3
store i32 104, i32* %18
%19 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %15, i32 0, i32 1
%20 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 3
store i32 118, i32* %21
%22 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %15, i32 0, i32 2
%23 = getelementptr inbounds %struct.option, %struct.option* %22, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds %struct.option, %struct.option* %22, i32 0, i32 3
store i32 100, i32* %24
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %3
%28 = load i32*, i32** %6
store i32 0, i32* %28
br label %29
29: ; preds = %27, %3
br label %30
30: ; preds = %51, %29
%31 = load i32, i32* %4
%32 = load i8**, i8*** %5
%33 = load i8*, i8** %9
%34 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %10, i64 0, i64 0
%35 = call i32 @getopt_long(i32 %31, i8** %32, i8* %33, %struct.option* %34, i32 0)
store i32 %35, i32* %7
%36 = icmp ne i32 %35, -1
br i1 %36, label %37, label %52
37: ; preds = %30
%38 = load i32, i32* %7
switch i32 %38, label %51 [
i32 100, label %39
i32 104, label %45
i32 63, label %48
]
39: ; preds = %37
%40 = load i32*, i32** %6
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = load i32*, i32** %6
store i32 1, i32* %43
br label %44
44: ; preds = %42, %39
br label %51
45: ; preds = %37
%46 = load i8*, i8** %8
%47 = call i32 @usage(i8* %46)
br label %51
48: ; preds = %37
%49 = load i8*, i8** %8
%50 = call i32 @usage(i8* %49)
br label %51
51: ; preds = %37, %48, %45, %44
br label %30
52: ; preds = %30
ret void
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [9 x i8] c"dhp:l:v:\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [10 x i8] c"verbosity\00"
@.str.3 = [7 x i8] c"daemon\00"
define void @parse_options(i32 %0, i8** %1, i32* writeonly %2) {
%4 = alloca [4 x %struct.option]
%5 = load i8*, i8** %1
%6 = bitcast [4 x %struct.option]* %4 to i8*
%7 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0, i32 3
store i32 104, i32* %8
%9 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 1, i32 3
store i32 118, i32* %10
%11 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 2, i32 3
store i32 100, i32* %12
%13 = icmp eq i32* %2, null
br i1 %13, label %15, label %14
14: ; preds = %3
store i32 0, i32* %2
br label %15
15: ; preds = %14, %3
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0
br label %17
17: ; preds = %19, %15
%18 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.option* %16, i32 0)
switch i32 %18, label %19 [
i32 -1, label %26
i32 100, label %20
i32 104, label %22
i32 63, label %24
]
19: ; preds = %17, %20, %21, %24, %22
br label %17
20: ; preds = %17
br i1 %13, label %19, label %21
21: ; preds = %20
store i32 1, i32* %2
br label %19
22: ; preds = %17
%23 = call i32 @usage(i8* %5)
br label %19
24: ; preds = %17
%25 = call i32 @usage(i8* %5)
br label %19
26: ; preds = %17
ret void
}