#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 EOF;
int /*<<< orphan*/ display_help();
int /*<<< orphan*/ display_version();
int getopt_long(int, char **, char const *, struct option const *, int *);
#define no_argument 128
int optind;
void process_options(int argc, char *argv[], const char **mtd_filename) {
  int error = 0;
  for (;;) {
    int option_index = 0;
    static const char *short_options = "hV";
    static const struct option long_options[] = {{"help", no_argument, 0, 'h'},
                                                 {
                                                     "version",
                                                     no_argument,
                                                     0,
                                                     'V',
                                                 },
                                                 {NULL, 0, 0, 0}};
    int c = getopt_long(argc, argv, short_options, long_options, &option_index);
    if (c == EOF)
      break;
    switch (c) {
    case 'h':
      display_help();
      break;
    case 'V':
      display_version();
      break;
    case '?':
      error = 1;
      break;
    }
  }
  if ((argc - optind) != 1 || error)
    display_help();
  *mtd_filename = argv[optind];
}


x86 assembly (clang, -O0):
<process_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2ed9(%rip),%rdx
lea    0x2c5a(%rip),%rcx
lea    -0x20(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%eax
jne    1189 <process_options+0x59>
jmp    11e3 <process_options+0xb3>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x3f,%eax
je     11d7 <process_options+0xa7>
jmp    119d <process_options+0x6d>
mov    -0x28(%rbp),%eax
sub    $0x56,%eax
je     11cb <process_options+0x9b>
jmp    11ae <process_options+0x7e>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
jne    11de <process_options+0xae>
jmp    11bf <process_options+0x8f>
mov    $0x0,%al
call   1050 <display_help@plt>
jmp    11de <process_options+0xae>
mov    $0x0,%al
call   1030 <display_version@plt>
jmp    11de <process_options+0xae>
movl   $0x1,-0x1c(%rbp)
jmp    114a <process_options+0x1a>
mov    -0x4(%rbp),%eax
mov    0x2deb(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
jne    1202 <process_options+0xd2>
cmpl   $0x0,-0x1c(%rbp)
je     1209 <process_options+0xd9>
mov    $0x0,%al
call   1050 <display_help@plt>
mov    -0x10(%rbp),%rax
mov    0x2dc4(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
lea    0xea9(%rip),%rdx
lea    0x2c62(%rip),%rcx
lea    0xc(%rsp),%r8
call   1040 <getopt_long@plt>
mov    0x2e71(%rip),%r14
movl   $0x0,0x8(%rsp)
cmp    (%r14),%eax
jne    11bb <process_options+0x8b>
mov    0x2e55(%rip),%r14
mov    (%r14),%eax
sub    %eax,%ebp
cmp    $0x1,%ebp
jne    1194 <process_options+0x64>
cmpl   $0x0,0x8(%rsp)
je     119e <process_options+0x6e>
xor    %eax,%eax
call   1050 <display_help@plt>
mov    (%r14),%eax
cltq
mov    (%rbx,%rax,8),%rax
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe3e(%rip),%r15
lea    0x2bf7(%rip),%r12
lea    0xc(%rsp),%r13
movl   $0x0,0x8(%rsp)
jmp    120b <process_options+0xdb>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <display_version@plt>
movl   $0x0,0xc(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1040 <getopt_long@plt>
cmp    (%r14),%eax
je     117c <process_options+0x4c>
cmp    $0x3f,%eax
je     1230 <process_options+0x100>
cmp    $0x56,%eax
je     11e0 <process_options+0xb0>
cmp    $0x68,%eax
jne    11e7 <process_options+0xb7>
xor    %eax,%eax
call   1050 <display_help@plt>
jmp    11e7 <process_options+0xb7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movl   $0x1,0x8(%rsp)
jmp    11e7 <process_options+0xb7>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@process_options.short_options = internal global i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)
@.str = [3 x i8] c"hV\00"
@process_options.long_options = internal constant [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 86 }, %struct.option zeroinitializer]
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [8 x i8] c"version\00"
@EOF = global i32 0
@optind = global i32 0
define void @process_options(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i32 0, i32* %7
br label %10
10: ; preds = %26, %3
store i32 0, i32* %8
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = load i8*, i8** @process_options.short_options
%14 = call i32 @getopt_long(i32 %11, i8** %12, i8* %13, %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @process_options.long_options, i64 0, i64 0), i32* %8)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %10
br label %27
19: ; preds = %10
%20 = load i32, i32* %9
switch i32 %20, label %26 [
i32 104, label %21
i32 86, label %23
i32 63, label %25
]
21: ; preds = %19
%22 = call i32 (...) @display_help()
br label %26
23: ; preds = %19
%24 = call i32 (...) @display_version()
br label %26
25: ; preds = %19
store i32 1, i32* %7
br label %26
26: ; preds = %19, %25, %23, %21
br label %10
27: ; preds = %18
%28 = load i32, i32* %4
%29 = load i32, i32* @optind
%30 = sub nsw i32 %28, %29
%31 = icmp ne i32 %30, 1
br i1 %31, label %35, label %32
32: ; preds = %27
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32, %27
%36 = call i32 (...) @display_help()
br label %37
37: ; preds = %35, %32
%38 = load i8**, i8*** %5
%39 = load i32, i32* @optind
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %6
store i8* %42, i8** %43
ret void
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [3 x i8] c"hV\00"
@process_options.long_options = internal constant [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 86 }, %struct.option zeroinitializer]
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [8 x i8] c"version\00"
@EOF = global i32 0
@optind = global i32 0
define void @process_options(i32 %0, i8** %1, i8** nocapture writeonly %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @process_options.long_options, i64 0, i64 0), i32* %4)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %22, label %9
9: ; preds = %3, %17
%10 = phi i32 [ %19, %17 ], [ %6, %3 ]
%11 = phi i32 [ %18, %17 ], [ 0, %3 ]
switch i32 %10, label %17 [
i32 104, label %12
i32 86, label %14
i32 63, label %16
]
12: ; preds = %9
%13 = call i32 (...) @display_help()
br label %17
14: ; preds = %9
%15 = call i32 (...) @display_version()
br label %17
16: ; preds = %9
br label %17
17: ; preds = %12, %14, %16, %9
%18 = phi i32 [ %11, %9 ], [ 1, %16 ], [ %11, %14 ], [ %11, %12 ]
store i32 0, i32* %4
%19 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @process_options.long_options, i64 0, i64 0), i32* %4)
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %9
22: ; preds = %17, %3
%23 = phi i32 [ 0, %3 ], [ %18, %17 ]
%24 = load i32, i32* @optind
%25 = sub nsw i32 %0, %24
%26 = icmp ne i32 %25, 1
%27 = icmp ne i32 %23, 0
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = call i32 (...) @display_help()
%31 = load i32, i32* @optind
br label %32
32: ; preds = %22, %29
%33 = phi i32 [ %24, %22 ], [ %31, %29 ]
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
store i8* %36, i8** %2
ret void
}