#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;
  int member_1;
  char member_3;
  int /*<<< orphan*/ *member_2;
};

/* Variables and functions */
int atoi(int /*<<< orphan*/);
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ usage(char *);
void parse_args(int argc, char **argv, int *type, int *key, char **data) {
  int index;
  static struct option long_opts[] = {{"32", 0, NULL, 'a'},
                                      {"64", 0, NULL, 'b'},
                                      {"key", 1, NULL, 'k'},
                                      {"help", 0, NULL, 0}};
  while (1) {
    int c = getopt_long(argc, argv, "", long_opts, &index);
    if (c == -1)
      break;
    switch (c) {
    case 'a':
      *type = (1);
      break;
    case 'b':
      *type = (2);
      break;
    case 'k':
      *key = atoi(optarg);
      break;
    case 0:
    case '?':
    default:
      usage(argv[0]);
      break;
    }
  }
  if (optind + 1 == argc) {
    *data = argv[optind];
  } else {
    usage(argv[0]);
  }
  return;
}


x86 assembly (clang, -O0):
<parse_args>:
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)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdx
lea    0x2ee0(%rip),%rcx
lea    -0x2c(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    117b <parse_args+0x4b>
jmp    1221 <parse_args+0xf1>
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
test   %eax,%eax
je     120b <parse_args+0xdb>
jmp    118e <parse_args+0x5e>
mov    -0x34(%rbp),%eax
sub    $0x3f,%eax
je     120b <parse_args+0xdb>
jmp    119f <parse_args+0x6f>
mov    -0x34(%rbp),%eax
sub    $0x61,%eax
je     11d2 <parse_args+0xa2>
jmp    11b0 <parse_args+0x80>
mov    -0x34(%rbp),%eax
sub    $0x62,%eax
je     11e1 <parse_args+0xb1>
jmp    11c1 <parse_args+0x91>
mov    -0x34(%rbp),%eax
sub    $0x6b,%eax
je     11f0 <parse_args+0xc0>
jmp    1210 <parse_args+0xe0>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    121c <parse_args+0xec>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    121c <parse_args+0xec>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    121c <parse_args+0xec>
jmp    1210 <parse_args+0xe0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
jmp    114b <parse_args+0x1b>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x4(%rbp),%eax
jne    1254 <parse_args+0x124>
mov    -0x10(%rbp),%rax
mov    0x2d9f(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    1260 <parse_args+0x130>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeac(%rip),%r13
lea    0x2ee3(%rip),%r14
lea    0x14(%rsp),%r15
jmp    1178 <parse_args+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x2,(%r12)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <getopt_long@plt>
cmp    $0x61,%eax
jle    11c0 <parse_args+0x90>
cmp    $0x62,%eax
je     1170 <parse_args+0x40>
cmp    $0x6b,%eax
jne    11d1 <parse_args+0xa1>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <atoi@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
jmp    1178 <parse_args+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
jne    11cc <parse_args+0x9c>
movl   $0x1,(%r12)
jmp    1178 <parse_args+0x48>
cmp    $0xffffffff,%eax
je     11db <parse_args+0xab>
mov    (%rbx),%rdi
call   1040 <usage@plt>
jmp    1178 <parse_args+0x48>
mov    0x2dfe(%rip),%rax
movslq (%rax),%rax
lea    0x1(%rax),%ecx
cmp    %ebp,%ecx
jne    11f9 <parse_args+0xc9>
mov    (%rbx,%rax,8),%rax
mov    (%rsp),%rcx
mov    %rax,(%rcx)
jmp    1201 <parse_args+0xd1>
mov    (%rbx),%rdi
call   1040 <usage@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i32, i8, i32* }
@parse_args.long_opts = internal global [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 97 to i32*) }, %struct.option { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 98 to i32*) }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 107 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i32* null }]
@.str = [3 x i8] c"32\00"
@.str.1 = [3 x i8] c"64\00"
@.str.2 = [4 x i8] c"key\00"
@.str.3 = [5 x i8] c"help\00"
@.str.4 = [1 x i8] zeroinitializer
@optarg = global i32 0
@optind = global i32 0
define void @parse_args(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
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
br label %13
13: ; preds = %5, %36
%14 = load i32, i32* %6
%15 = load i8**, i8*** %7
%16 = call i32 @getopt_long(i32 %14, i8** %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @parse_args.long_opts, i64 0, i64 0), i32* %11)
store i32 %16, i32* %12
%17 = load i32, i32* %12
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %13
br label %37
20: ; preds = %13
%21 = load i32, i32* %12
switch i32 %21, label %31 [
i32 97, label %22
i32 98, label %24
i32 107, label %26
i32 0, label %30
i32 63, label %30
]
22: ; preds = %20
%23 = load i32*, i32** %8
store i32 1, i32* %23
br label %36
24: ; preds = %20
%25 = load i32*, i32** %8
store i32 2, i32* %25
br label %36
26: ; preds = %20
%27 = load i32, i32* @optarg
%28 = call i32 @atoi(i32 %27)
%29 = load i32*, i32** %9
store i32 %28, i32* %29
br label %36
30: ; preds = %20, %20
br label %31
31: ; preds = %20, %30
%32 = load i8**, i8*** %7
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @usage(i8* %34)
br label %36
36: ; preds = %31, %26, %24, %22
br label %13
37: ; preds = %19
%38 = load i32, i32* @optind
%39 = add nsw i32 %38, 1
%40 = load i32, i32* %6
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = load i8**, i8*** %7
%44 = load i32, i32* @optind
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = load i8**, i8*** %10
store i8* %47, i8** %48
br label %54
49: ; preds = %37
%50 = load i8**, i8*** %7
%51 = getelementptr inbounds i8*, i8** %50, i64 0
%52 = load i8*, i8** %51
%53 = call i32 @usage(i8* %52)
br label %54
54: ; preds = %49, %42
ret void
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i32* }
@parse_args.long_opts = internal global [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 97 to i32*) }, %struct.option { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 98 to i32*) }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 107 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i32* null }]
@.str = [3 x i8] c"32\00"
@.str.1 = [3 x i8] c"64\00"
@.str.2 = [4 x i8] c"key\00"
@.str.3 = [5 x i8] c"help\00"
@.str.4 = [1 x i8] zeroinitializer
@optarg = global i32 0
@optind = global i32 0
define void @parse_args(i32 %0, i8** %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i8** nocapture writeonly %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
br label %8
8: ; preds = %11, %5
%9 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @parse_args.long_opts, i64 0, i64 0), i32* %6)
switch i32 %9, label %16 [
i32 -1, label %19
i32 97, label %10
i32 98, label %12
i32 107, label %13
]
10: ; preds = %8
store i32 1, i32* %2
br label %11
11: ; preds = %10, %12, %13, %16
br label %8
12: ; preds = %8
store i32 2, i32* %2
br label %11
13: ; preds = %8
%14 = load i32, i32* @optarg
%15 = call i32 @atoi(i32 %14)
store i32 %15, i32* %3
br label %11
16: ; preds = %8
%17 = load i8*, i8** %1
%18 = call i32 @usage(i8* %17)
br label %11
19: ; preds = %8
%20 = load i32, i32* @optind
%21 = add nsw i32 %20, 1
%22 = icmp eq i32 %21, %0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = sext i32 %20 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
store i8* %26, i8** %4
br label %30
27: ; preds = %19
%28 = load i8*, i8** %1
%29 = call i32 @usage(i8* %28)
br label %30
30: ; preds = %27, %23
ret void
}