#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*/ const member_1;
};

/* Variables and functions */
int getopt_long(int, char **, char *, struct option *, int *);
#define no_argument 129
int /*<<< orphan*/ optarg;
#define required_argument 128
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int discovery_options(int argc, char **argv, int *show_help, int *show_version,
                      char *input) {
  int ret = 0;
  static struct option long_options[] = {{"help", no_argument, 0, 'h'},
                                         {"version", no_argument, 0, 'v'},
                                         {"arga", required_argument, 0, 'a'},
                                         {"argb", required_argument, 0, 'b'},
                                         {0, 0, 0, 0}};
  int opt = 0;
  int option_index = 0;
  while ((opt = getopt_long(argc, argv, "hva:b:", long_options,
                            &option_index)) != -1) {
    switch (opt) {
    case 'h':
      *show_help = 1;
      break;
    case 'v':
      *show_version = 1;
      break;
    case 'a':
      strcpy(input, optarg);
      break;
    case 'b':
      strcpy(input, optarg);
      break;
    default:
      *show_help = 1;
      break;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<discovery_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf11(%rip),%rdx
lea    0x2edb(%rip),%rcx
lea    -0x34(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
je     11fe <discovery_options+0xde>
mov    -0x30(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x15,%eax
ja     11ef <discovery_options+0xcf>
mov    -0x40(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11f9 <discovery_options+0xd9>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    11f9 <discovery_options+0xd9>
mov    -0x28(%rbp),%rdi
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
jmp    11f9 <discovery_options+0xd9>
mov    -0x28(%rbp),%rdi
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
jmp    11f9 <discovery_options+0xd9>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1150 <discovery_options+0x30>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<discovery_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
lea    0xf1e(%rip),%r13
lea    0x2ee8(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xe9c(%rip),%r12
jmp    1176 <discovery_options+0x56>
cmp    $0xffffffff,%eax
je     11bc <discovery_options+0x9c>
mov    0x18(%rsp),%rax
movl   $0x1,(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <getopt_long@plt>
lea    -0x61(%rax),%ecx
cmp    $0x15,%ecx
ja     1166 <discovery_options+0x46>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
mov    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
jmp    1176 <discovery_options+0x56>
mov    0x20(%rsp),%rax
movl   $0x1,(%rax)
jmp    1176 <discovery_options+0x56>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@discovery_options.long_options = internal global [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 98 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [5 x i8] c"arga\00"
@.str.3 = [5 x i8] c"argb\00"
@.str.4 = [7 x i8] c"hva:b:\00"
@optarg = global i32 0
define i32 @discovery_options(i32 %0, i8** %1, i32* %2, i32* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i8* %4, i8** %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
br label %14
14: ; preds = %35, %5
%15 = load i32, i32* %6
%16 = load i8**, i8*** %7
%17 = call i32 @getopt_long(i32 %15, i8** %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([5 x %struct.option], [5 x %struct.option]* @discovery_options.long_options, i64 0, i64 0), i32* %13)
store i32 %17, i32* %12
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %36
19: ; preds = %14
%20 = load i32, i32* %12
switch i32 %20, label %33 [
i32 104, label %21
i32 118, label %23
i32 97, label %25
i32 98, label %29
]
21: ; preds = %19
%22 = load i32*, i32** %8
store i32 1, i32* %22
br label %35
23: ; preds = %19
%24 = load i32*, i32** %9
store i32 1, i32* %24
br label %35
25: ; preds = %19
%26 = load i8*, i8** %10
%27 = load i32, i32* @optarg
%28 = call i32 @strcpy(i8* %26, i32 %27)
br label %35
29: ; preds = %19
%30 = load i8*, i8** %10
%31 = load i32, i32* @optarg
%32 = call i32 @strcpy(i8* %30, i32 %31)
br label %35
33: ; preds = %19
%34 = load i32*, i32** %8
store i32 1, i32* %34
br label %35
35: ; preds = %33, %29, %25, %23, %21
br label %14
36: ; preds = %14
%37 = load i32, i32* %11
ret i32 %37
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@discovery_options.long_options = internal global [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32 0, i32 118 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 97 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 98 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [5 x i8] c"arga\00"
@.str.3 = [5 x i8] c"argb\00"
@.str.4 = [7 x i8] c"hva:b:\00"
@optarg = global i32 0
define i32 @discovery_options(i32 %0, i8** %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i8* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
store i32 0, i32* %6
br label %8
8: ; preds = %19, %5
%9 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([5 x %struct.option], [5 x %struct.option]* @discovery_options.long_options, i64 0, i64 0), i32* %6)
switch i32 %9, label %18 [
i32 -1, label %20
i32 104, label %10
i32 118, label %11
i32 97, label %12
i32 98, label %15
]
10: ; preds = %8
store i32 1, i32* %2
br label %19
11: ; preds = %8
store i32 1, i32* %3
br label %19
12: ; preds = %8
%13 = load i32, i32* @optarg
%14 = call i32 @strcpy(i8* %4, i32 %13)
br label %19
15: ; preds = %8
%16 = load i32, i32* @optarg
%17 = call i32 @strcpy(i8* %4, i32 %16)
br label %19
18: ; preds = %8
store i32 1, i32* %2
br label %19
19: ; preds = %18, %15, %12, %11, %10
br label %8
20: ; preds = %8
ret i32 0
}