#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*/ fprintf(int /*<<< orphan*/, char *, int, char *, int);
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ no_argument;
char *optarg;
int /*<<< orphan*/ optional_argument;
int /*<<< orphan*/ required_argument;
int /*<<< orphan*/ stdout;
int main(int argc, char **args) {
  struct option opts[] = {{"aaa", required_argument, 0, 0},
                          {"bbb", no_argument, 0, 'b'},
                          {"ccc", optional_argument, 0, 'c'},
                          {"ddd", required_argument, 0, 'd'},
                          {0, 0, 0, 0}};
  int op = 0;
  int index = -1;
  while (0 <= (op = getopt_long(argc, args, "0:1", opts, &index))) {
    fprintf(stdout, "key %d, value: %s, index: %d\n", op, optarg, index);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xea9(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x88(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x80(%rbp)
add    $0x18,%rdi
lea    0xe7b(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x70(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x62,-0x68(%rbp)
add    $0x18,%rdi
lea    0xe56(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2e23(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x63,-0x50(%rbp)
add    $0x18,%rdi
lea    0xe31(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x64,-0x38(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0x0,-0x94(%rbp)
movl   $0xffffffff,-0x98(%rbp)
ff ff ff
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x90(%rbp),%rcx
lea    0xdde(%rip),%rdx
lea    -0x98(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,%ecx
mov    %ecx,-0x94(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jg     1281 <main+0x151>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    -0x94(%rbp),%edx
mov    0x2d92(%rip),%rax
mov    (%rax),%rcx
mov    -0x98(%rbp),%r8d
lea    0xd9d(%rip),%rsi
call   1050 <fprintf@plt>
jmp    121d <main+0xed>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xec3(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%al
mov    %al,0x18(%rsp)
movq   $0x0,0x1c(%rsp)
lea    0xea5(%rip),%rcx
mov    %rcx,0x28(%rsp)
mov    0x2e5d(%rip),%rcx
mov    (%rcx),%cl
mov    %cl,0x30(%rsp)
movabs $0x6200000000,%rcx
mov    %rcx,0x34(%rsp)
lea    0xe81(%rip),%rcx
mov    %rcx,0x40(%rsp)
mov    0x2e4d(%rip),%rcx
mov    (%rcx),%cl
mov    %cl,0x48(%rsp)
movabs $0x6300000000,%rcx
mov    %rcx,0x4c(%rsp)
lea    0xe5d(%rip),%rcx
mov    %rcx,0x58(%rsp)
mov    %al,0x60(%rsp)
movabs $0x6400000000,%rax
mov    %rax,0x64(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movq   $0x0,0x80(%rsp)
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xe26(%rip),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1030 <getopt_long@plt>
test   %eax,%eax
js     1259 <main+0x139>
lea    0xe10(%rip),%r14
lea    0xe05(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2d99(%rip),%rcx
mov    (%rcx),%edi
mov    0x2dc8(%rip),%rcx
mov    (%rcx),%rcx
mov    0xc(%rsp),%r8d
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <getopt_long@plt>
test   %eax,%eax
jns    1220 <main+0x100>
xor    %eax,%eax
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 = [4 x i8] c"aaa\00"
@required_argument = global i32 0
@.str.1 = [4 x i8] c"bbb\00"
@no_argument = global i32 0
@.str.2 = [4 x i8] c"ccc\00"
@optional_argument = global i32 0
@.str.3 = [4 x i8] c"ddd\00"
@.str.4 = [4 x i8] c"0:1\00"
@stdout = global i32 0
@.str.5 = [30 x i8] c"key %d, value: %s, index: %d\0A\00"
@optarg = global i8* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x %struct.option]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0
%10 = getelementptr inbounds %struct.option, %struct.option* %9, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds %struct.option, %struct.option* %9, i32 0, i32 1
%12 = load i32, i32* @required_argument
%13 = trunc i32 %12 to i8
store i8 %13, i8* %11
%14 = getelementptr inbounds %struct.option, %struct.option* %9, i32 0, i32 2
store i32 0, i32* %14
%15 = getelementptr inbounds %struct.option, %struct.option* %9, i32 0, i32 3
store i32 0, i32* %15
%16 = getelementptr inbounds %struct.option, %struct.option* %9, i64 1
%17 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 1
%19 = load i32, i32* @no_argument
%20 = trunc i32 %19 to i8
store i8 %20, i8* %18
%21 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 2
store i32 0, i32* %21
%22 = getelementptr inbounds %struct.option, %struct.option* %16, i32 0, i32 3
store i32 98, i32* %22
%23 = getelementptr inbounds %struct.option, %struct.option* %16, i64 1
%24 = getelementptr inbounds %struct.option, %struct.option* %23, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds %struct.option, %struct.option* %23, i32 0, i32 1
%26 = load i32, i32* @optional_argument
%27 = trunc i32 %26 to i8
store i8 %27, i8* %25
%28 = getelementptr inbounds %struct.option, %struct.option* %23, i32 0, i32 2
store i32 0, i32* %28
%29 = getelementptr inbounds %struct.option, %struct.option* %23, i32 0, i32 3
store i32 99, i32* %29
%30 = getelementptr inbounds %struct.option, %struct.option* %23, i64 1
%31 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %31
%32 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 1
%33 = load i32, i32* @required_argument
%34 = trunc i32 %33 to i8
store i8 %34, i8* %32
%35 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 2
store i32 0, i32* %35
%36 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 3
store i32 100, i32* %36
%37 = getelementptr inbounds %struct.option, %struct.option* %30, i64 1
%38 = bitcast %struct.option* %37 to i8*
store i32 0, i32* %7
store i32 -1, i32* %8
br label %39
39: ; preds = %45, %2
%40 = load i32, i32* %4
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0
%43 = call i32 @getopt_long(i32 %40, i8** %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %42, i32* %8)
store i32 %43, i32* %7
%44 = icmp sle i32 0, %43
br i1 %44, label %45, label %51
45: ; preds = %39
%46 = load i32, i32* @stdout
%47 = load i32, i32* %7
%48 = load i8*, i8** @optarg
%49 = load i32, i32* %8
%50 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %47, i8* %48, i32 %49)
br label %39
51: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [4 x i8] c"aaa\00"
@required_argument = global i32 0
@.str.1 = [4 x i8] c"bbb\00"
@no_argument = global i32 0
@.str.2 = [4 x i8] c"ccc\00"
@optional_argument = global i32 0
@.str.3 = [4 x i8] c"ddd\00"
@.str.4 = [4 x i8] c"0:1\00"
@stdout = global i32 0
@.str.5 = [30 x i8] c"key %d, value: %s, index: %d\0A\00"
@optarg = global i8* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [5 x %struct.option]
%4 = alloca i32
%5 = bitcast [5 x %struct.option]* %3 to i8*
%6 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0
%7 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0, i32 1
%9 = load i32, i32* @required_argument
%10 = trunc i32 %9 to i8
store i8 %10, i8* %8
%11 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0, i32 2
store i32 0, i32* %11
%12 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0, i32 3
store i32 0, i32* %12
%13 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 1, i32 1
%15 = load i32, i32* @no_argument
%16 = trunc i32 %15 to i8
store i8 %16, i8* %14
%17 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 1, i32 2
store i32 0, i32* %17
%18 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 1, i32 3
store i32 98, i32* %18
%19 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 2, i32 1
%21 = load i32, i32* @optional_argument
%22 = trunc i32 %21 to i8
store i8 %22, i8* %20
%23 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 2, i32 2
store i32 0, i32* %23
%24 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 2, i32 3
store i32 99, i32* %24
%25 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 3, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 3, i32 1
store i8 %10, i8* %26
%27 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 3, i32 2
store i32 0, i32* %27
%28 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 3, i32 3
store i32 100, i32* %28
%29 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 4
%30 = bitcast %struct.option* %29 to i8*
%31 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%32 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %6, i32* %4)
%33 = icmp sgt i32 %32, -1
br i1 %33, label %34, label %42
34: ; preds = %2, %34
%35 = phi i32 [ %40, %34 ], [ %32, %2 ]
%36 = load i32, i32* @stdout
%37 = load i8*, i8** @optarg
%38 = load i32, i32* %4
%39 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %35, i8* %37, i32 %38)
%40 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %6, i32* %4)
%41 = icmp sgt i32 %40, -1
br i1 %41, label %34, label %42
42: ; preds = %34, %2
ret i32 0
}