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

/* Variables and functions */
int getopt_long(int, char **, char const *, struct option *, int *);
int /*<<< orphan*/ no_argument;
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ required_argument;
int main(int argc, char **argv) {
  const char *optstring = "n:v";
  int c = 0;
  int deb = 0;
  int index = 0;
  struct option opts[] = {{"username", required_argument, NULL, 'n'},
                          {"version", no_argument, NULL, 'v'},
                          {"debug", no_argument, &deb, 1},
                          {0, 0, 0, 0}};
  while ((c = getopt_long(argc, argv, optstring, opts, &index)) != -1) {
    switch (c) {
    case 'n':
      printf("username is %s\n", optarg);
      break;
    case 'v':
      printf("version is 0.0.1\n");
      break;
    case 0:
      printf("debug is %d\n", deb);
      break;
    case '?':
      printf("?\n");
      break;
    default:
      printf("c is %d\n", c);
      break;
    }
  }
  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    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe8d(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0x2e5b(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x88(%rbp)
movb   $0x0,-0x80(%rbp)
movl   $0x6e,-0x7c(%rbp)
add    $0x18,%rdi
lea    0xe68(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0x2e20(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x70(%rbp)
movb   $0x0,-0x68(%rbp)
movl   $0x76,-0x64(%rbp)
add    $0x18,%rdi
lea    0xe48(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2df8(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x58(%rbp)
lea    -0x20(%rbp),%rax
mov    %al,-0x50(%rbp)
movl   $0x1,-0x4c(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x90(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     12e5 <main+0x1b5>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x94(%rbp)
test   %eax,%eax
je     12a6 <main+0x176>
jmp    123a <main+0x10a>
mov    -0x94(%rbp),%eax
sub    $0x3f,%eax
je     12bc <main+0x18c>
jmp    124e <main+0x11e>
mov    -0x94(%rbp),%eax
sub    $0x6e,%eax
je     1276 <main+0x146>
jmp    1262 <main+0x132>
mov    -0x94(%rbp),%eax
sub    $0x76,%eax
je     1293 <main+0x163>
jmp    12cf <main+0x19f>
mov    0x2d7b(%rip),%rax
mov    (%rax),%rsi
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e0 <main+0x1b0>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e0 <main+0x1b0>
mov    -0x20(%rbp),%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e0 <main+0x1b0>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e0 <main+0x1b0>
mov    -0x1c(%rbp),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fd <main+0xcd>
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    $0x78,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xeaa(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0x2e7a(%rip),%rax
movslq (%rax),%rax
mov    %rax,0x18(%rsp)
movb   $0x0,0x20(%rsp)
movl   $0x6e,0x24(%rsp)
lea    0xe8b(%rip),%rax
mov    %rax,0x28(%rsp)
mov    0x2e42(%rip),%rax
movslq (%rax),%rax
mov    %rax,0x30(%rsp)
movb   $0x0,0x38(%rsp)
movl   $0x76,0x3c(%rsp)
lea    0xe6b(%rip),%rcx
mov    %rcx,0x40(%rsp)
mov    %rax,0x48(%rsp)
lea    0x8(%rsp),%rax
mov    %al,0x50(%rsp)
movl   $0x1,0x54(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x58(%rsp)
movq   $0x0,0x68(%rsp)
lea    0xe23(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xe2d(%rip),%r13
jmp    1209 <main+0xd9>
cmp    $0xffffffff,%eax
je     127b <main+0x14b>
lea    0xe38(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1040 <getopt_long@plt>
cmp    $0x6d,%eax
jg     1240 <main+0x110>
test   %eax,%eax
je     1260 <main+0x130>
cmp    $0x3f,%eax
jne    11f0 <main+0xc0>
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
jmp    1209 <main+0xd9>
nopl   0x0(%rax,%rax,1)
cmp    $0x76,%eax
je     126d <main+0x13d>
cmp    $0x6e,%eax
jne    11f9 <main+0xc9>
mov    0x2da7(%rip),%rax
mov    (%rax),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1209 <main+0xd9>
mov    0x8(%rsp),%esi
lea    0xdc0(%rip),%rdi
jmp    1202 <main+0xd2>
lea    0xdcf(%rip),%rdi
call   1030 <puts@plt>
jmp    1209 <main+0xd9>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i32*, i8, i32 }
@.str = [4 x i8] c"n:v\00"
@.str.1 = [9 x i8] c"username\00"
@required_argument = global i32 0
@.str.2 = [8 x i8] c"version\00"
@no_argument = global i32 0
@.str.3 = [6 x i8] c"debug\00"
@.str.4 = [16 x i8] c"username is %s\0A\00"
@optarg = global i8* null
@.str.5 = [18 x i8] c"version is 0.0.1\0A\00"
@.str.6 = [13 x i8] c"debug is %d\0A\00"
@.str.7 = [3 x i8] c"?\0A\00"
@.str.8 = [9 x i8] c"c is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [4 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%11 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %10, i64 0, i64 0
%12 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 1
%14 = load i32, i32* @required_argument
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %13
%17 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 2
store i8 0, i8* %17
%18 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 3
store i32 110, i32* %18
%19 = getelementptr inbounds %struct.option, %struct.option* %11, i64 1
%20 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 1
%22 = load i32, i32* @no_argument
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i32*
store i32* %24, i32** %21
%25 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 2
store i8 0, i8* %25
%26 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 3
store i32 118, i32* %26
%27 = getelementptr inbounds %struct.option, %struct.option* %19, i64 1
%28 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %28
%29 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 1
%30 = load i32, i32* @no_argument
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
store i32* %32, i32** %29
%33 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 2
%34 = ptrtoint i32* %8 to i8
store i8 %34, i8* %33
%35 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 3
store i32 1, i32* %35
%36 = getelementptr inbounds %struct.option, %struct.option* %27, i64 1
%37 = bitcast %struct.option* %36 to i8*
br label %38
38: ; preds = %60, %2
%39 = load i32, i32* %4
%40 = load i8**, i8*** %5
%41 = load i8*, i8** %6
%42 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %10, i64 0, i64 0
%43 = call i32 @getopt_long(i32 %39, i8** %40, i8* %41, %struct.option* %42, i32* %9)
store i32 %43, i32* %7
%44 = icmp ne i32 %43, -1
br i1 %44, label %45, label %61
45: ; preds = %38
%46 = load i32, i32* %7
switch i32 %46, label %57 [
i32 110, label %47
i32 118, label %50
i32 0, label %52
i32 63, label %55
]
47: ; preds = %45
%48 = load i8*, i8** @optarg
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %48)
br label %60
50: ; preds = %45
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %60
52: ; preds = %45
%53 = load i32, i32* %8
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %53)
br label %60
55: ; preds = %45
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %60
57: ; preds = %45
%58 = load i32, i32* %7
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %57, %55, %52, %50, %47
br label %38
61: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i32*, i8, i32 }
@.str = [4 x i8] c"n:v\00"
@.str.1 = [9 x i8] c"username\00"
@required_argument = global i32 0
@.str.2 = [8 x i8] c"version\00"
@no_argument = global i32 0
@.str.3 = [6 x i8] c"debug\00"
@.str.4 = [16 x i8] c"username is %s\0A\00"
@optarg = global i8* null
@.str.6 = [13 x i8] c"debug is %d\0A\00"
@.str.8 = [9 x i8] c"c is %d\0A\00"
@str = [2 x i8] c"?\00"
@str.9 = [17 x i8] c"version is 0.0.1\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x %struct.option]
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast [4 x %struct.option]* %5 to i8*
%9 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0
%10 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 1
%12 = load i32, i32* @required_argument
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %11
%15 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 2
store i8 0, i8* %15
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 0, i32 3
store i32 110, i32* %16
%17 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 1
%19 = load i32, i32* @no_argument
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
store i32* %21, i32** %18
%22 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 2
store i8 0, i8* %22
%23 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 1, i32 3
store i32 118, i32* %23
%24 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 1
store i32* %21, i32** %25
%26 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 2
%27 = ptrtoint i32* %3 to i64
%28 = trunc i64 %27 to i8
store i8 %28, i8* %26
%29 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 2, i32 3
store i32 1, i32* %29
%30 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %5, i64 0, i64 3
%31 = bitcast %struct.option* %30 to i8*
br label %32
32: ; preds = %46, %2
%33 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %struct.option* %9, i32* %4)
switch i32 %33, label %44 [
i32 -1, label %47
i32 110, label %34
i32 118, label %37
i32 0, label %39
i32 63, label %42
]
34: ; preds = %32
%35 = load i8*, i8** @optarg
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %35)
br label %46
37: ; preds = %32
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
br label %46
39: ; preds = %32
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %40)
br label %46
42: ; preds = %32
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %46
44: ; preds = %32
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %33)
br label %46
46: ; preds = %44, %42, %39, %37, %34
br label %32
47: ; preds = %32
ret i32 0
}