#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 getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
char *optarg;
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int opt;
  struct option longopts[] = {{"initialize", 0, NULL, 'i'},
                              {"file", 1, NULL, 'f'},
                              {"list", 0, NULL, 'l'},
                              {"restart", 0, NULL, 'r'},
                              {0, 0, 0, 0}};
  while ((opt = getopt_long(argc, argv, ":if:lr", longopts, NULL)) != -1) {
    switch (opt) {
    case 'i':
    case 'l':
    case 'r':
      printf("option: %c\n", opt);
      break;
    case 'f':
      printf("filename: %s\n", optarg);
      break;
    case ':':
      printf("option needs a value\n");
      break;
    case '?':
      printf("unknown option: %c\n", optopt);
      break;
    }
  }
  for (; optind < argc; optind++)
    printf("argument: %s\n", argv[optind]);
  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    0x2c39(%rip),%rsi
mov    $0x78,%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x90(%rbp),%rcx
lea    0xf8b(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     121d <main+0xed>
mov    -0x14(%rbp),%eax
add    $0xffffffc6,%eax
mov    %eax,%ecx
mov    %rcx,-0x98(%rbp)
sub    $0x38,%eax
ja     1218 <main+0xe8>
mov    -0x98(%rbp),%rax
lea    0xe4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%esi
lea    0xf6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
mov    0x2e20(%rip),%rax
mov    (%rax),%rsi
lea    0xf26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
lea    0xf21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1218 <main+0xe8>
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
lea    0xf1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1161 <main+0x31>
jmp    1222 <main+0xf2>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    126e <main+0x13e>
mov    -0x10(%rbp),%rax
mov    0x2d99(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2d71(%rip),%rax
mov    %ecx,(%rax)
jmp    1222 <main+0xf2>
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
mov    0x2cb6(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0x2c9a(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0x2c7e(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2c62(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c46(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2c2a(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c0e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2bf2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xf58(%rip),%r14
mov    %rsp,%r15
lea    0xe4d(%rip),%r12
lea    0xf64(%rip),%r13
jmp    11cc <main+0x9c>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
lea    -0x3a(%rax),%ecx
cmp    $0x38,%ecx
ja     122a <main+0xfa>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
lea    0xf41(%rip),%rdi
call   1030 <puts@plt>
jmp    11cc <main+0x9c>
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
lea    0xf08(%rip),%rdi
jmp    11c5 <main+0x95>
mov    0x2de1(%rip),%rax
mov    (%rax),%rsi
lea    0xee7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cc <main+0x9c>
cmp    $0xffffffff,%eax
jne    11cc <main+0x9c>
mov    0x2da2(%rip),%r15
mov    (%r15),%eax
cmp    %ebp,%eax
jge    126d <main+0x13d>
lea    0xee6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltq
mov    (%rbx,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%eax
add    $0x1,%eax
mov    %eax,(%r15)
cmp    %ebp,%eax
jl     1250 <main+0x120>
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 = [11 x i8] c"initialize\00"
@.str.1 = [5 x i8] c"file\00"
@.str.2 = [5 x i8] c"list\00"
@.str.3 = [8 x i8] c"restart\00"
@__const.main.longopts = [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 105 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 102 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 108 to i32*) }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 114 to i32*) }, %struct.option zeroinitializer]
@.str.4 = [7 x i8] c":if:lr\00"
@.str.5 = [12 x i8] c"option: %c\0A\00"
@.str.6 = [14 x i8] c"filename: %s\0A\00"
@optarg = global i8* null
@.str.7 = [22 x i8] c"option needs a value\0A\00"
@.str.8 = [20 x i8] c"unknown option: %c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.9 = [14 x i8] c"argument: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [5 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [5 x %struct.option]* %7 to i8*
br label %9
9: ; preds = %28, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %7, i64 0, i64 0
%13 = call i32 @getopt_long(i32 %10, i8** %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %struct.option* %12, i32* null)
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %29
15: ; preds = %9
%16 = load i32, i32* %6
switch i32 %16, label %28 [
i32 105, label %17
i32 108, label %17
i32 114, label %17
i32 102, label %20
i32 58, label %23
i32 63, label %25
]
17: ; preds = %15, %15, %15
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %18)
br label %28
20: ; preds = %15
%21 = load i8*, i8** @optarg
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %21)
br label %28
23: ; preds = %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %28
25: ; preds = %15
%26 = load i32, i32* @optopt
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %15, %25, %23, %20, %17
br label %9
29: ; preds = %9
br label %30
30: ; preds = %41, %29
%31 = load i32, i32* @optind
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %44
34: ; preds = %30
%35 = load i8**, i8*** %5
%36 = load i32, i32* @optind
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %34
%42 = load i32, i32* @optind
%43 = add nsw i32 %42, 1
store i32 %43, i32* @optind
br label %30
44: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i32* }
@.str = [11 x i8] c"initialize\00"
@.str.1 = [5 x i8] c"file\00"
@.str.2 = [5 x i8] c"list\00"
@.str.3 = [8 x i8] c"restart\00"
@__const.main.longopts = [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 105 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 0, i32* inttoptr (i64 102 to i32*) }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 108 to i32*) }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 114 to i32*) }, %struct.option zeroinitializer]
@.str.4 = [7 x i8] c":if:lr\00"
@.str.5 = [12 x i8] c"option: %c\0A\00"
@.str.6 = [14 x i8] c"filename: %s\0A\00"
@optarg = global i8* null
@.str.8 = [20 x i8] c"unknown option: %c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.9 = [14 x i8] c"argument: %s\0A\00"
@str = [21 x i8] c"option needs a value\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [5 x %struct.option]
%4 = bitcast [5 x %struct.option]* %3 to i8*
%5 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0
br label %6
6: ; preds = %8, %2
%7 = 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* %5, i32* null)
switch i32 %7, label %8 [
i32 -1, label %9
i32 105, label %12
i32 108, label %12
i32 114, label %12
i32 102, label %14
i32 58, label %17
i32 63, label %19
]
8: ; preds = %6, %19, %17, %14, %12
br label %6
9: ; preds = %6
%10 = load i32, i32* @optind
%11 = icmp slt i32 %10, %0
br i1 %11, label %22, label %31
12: ; preds = %6, %6, %6
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %7)
br label %8
14: ; preds = %6
%15 = load i8*, i8** @optarg
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %15)
br label %8
17: ; preds = %6
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %8
19: ; preds = %6
%20 = load i32, i32* @optopt
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %20)
br label %8
22: ; preds = %9, %22
%23 = phi i32 [ %29, %22 ], [ %10, %9 ]
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @optind
%29 = add nsw i32 %28, 1
store i32 %29, i32* @optind
%30 = icmp slt i32 %29, %0
br i1 %30, label %22, label %31
31: ; preds = %22, %9
ret i32 0
}