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

/* Variables and functions */
int EXIT_SUCCESS;
int getopt_long(int, char **, char *, struct option *, int *);
#define no_argument 129
char *optarg;
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
#define required_argument 128
int main(int argc, char **argv) {
  int c;
  int i = 0;
  int verbose = 0;
  static struct option longopts[] = {
      {"append", no_argument, 0, 'a'},        {"verbose", no_argument, 0, 'v'},
      {"file", required_argument, 0, 'f'},    {"long", no_argument, 0, 0},
      {"longextra", required_argument, 0, 0}, {NULL, 0, NULL, 0}};
  while ((c = getopt_long(argc, argv, "af:v", longopts, &i)) != -1) {
    switch (c) {
    case 0:
      printf("option %s", longopts[i].name);
      if (optarg)
        printf(" with arg %s", optarg);
      printf("\n");
      break;
    case 'a':
      printf("option a\n");
      break;
    case 'f':
      printf("option f with %s.\n", optarg);
      break;
    case 'v':
      verbose = 1;
      break;
    default:
      printf("unknown option = %c = ascii(0%x)\n", optopt, optopt);
      printf("return value of getopt_long() = %c\n", c);
    }
  }
  printf("verbose mode = %i\n", verbose);
  if (optind < argc) {
    int j = 1;
    while (optind < argc) {
      printf("argument[%i]=%s\n", j, argv[optind++]);
      j++;
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xed1(%rip),%rdx
lea    0x2ee7(%rip),%rcx
lea    -0x18(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1286 <main+0x166>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     11b4 <main+0x94>
jmp    1181 <main+0x61>
mov    -0x24(%rbp),%eax
sub    $0x61,%eax
je     1214 <main+0xf4>
jmp    1192 <main+0x72>
mov    -0x24(%rbp),%eax
sub    $0x66,%eax
je     1227 <main+0x107>
jmp    11a3 <main+0x83>
mov    -0x24(%rbp),%eax
sub    $0x76,%eax
je     1244 <main+0x124>
jmp    1250 <main+0x130>
movslq -0x18(%rbp),%rcx
lea    0x2e81(%rip),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e19(%rip),%rax
cmpq   $0x0,(%rax)
je     1201 <main+0xe1>
mov    0x2e08(%rip),%rax
mov    (%rax),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1281 <main+0x161>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1281 <main+0x161>
mov    0x2dca(%rip),%rax
mov    (%rax),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1281 <main+0x161>
movl   $0x1,-0x1c(%rbp)
jmp    1281 <main+0x161>
mov    0x2d89(%rip),%rax
mov    (%rax),%esi
mov    0x2d80(%rip),%rax
mov    (%rax),%edx
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1144 <main+0x24>
mov    -0x1c(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1308 <main+0x1e8>
movl   $0x1,-0x20(%rbp)
mov    0x2d21(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1303 <main+0x1e3>
mov    -0x20(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x2d08(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    0x2cfa(%rip),%rdx
mov    %edi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12b0 <main+0x190>
jmp    1308 <main+0x1e8>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
movl   $0x0,0x4(%rsp)
lea    0xec4(%rip),%rbx
lea    0x2eea(%rip),%r15
lea    0x4(%rsp),%r12
movl   $0x0,(%rsp)
jmp    118c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xf35(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1050 <getopt_long@plt>
mov    %eax,%r13d
cmp    $0x60,%eax
jle    11d0 <main+0x90>
cmp    $0x61,%r13d
je     1180 <main+0x40>
cmp    $0x66,%r13d
jne    121d <main+0xdd>
mov    0x2e3e(%rip),%rax
mov    (%rax),%rsi
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    118c <main+0x4c>
nopl   (%rax)
test   %r13d,%r13d
jne    122f <main+0xef>
movslq 0x4(%rsp),%rax
lea    (%rax,%rax,4),%rax
mov    0x10(%r15,%rax,8),%rsi
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     120e <main+0xce>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    118c <main+0x4c>
cmp    $0x76,%r13d
jne    1235 <main+0xf5>
movl   $0x1,(%rsp)
jmp    118c <main+0x4c>
cmp    $0xffffffff,%r13d
je     1264 <main+0x124>
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
lea    0xe0d(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe1f(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    118c <main+0x4c>
lea    0xe2d(%rip),%rdi
mov    (%rsp),%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d5c(%rip),%r12
mov    (%r12),%eax
cmp    %ebp,%eax
jge    12b4 <main+0x174>
mov    $0x1,%ebx
lea    0xe1b(%rip),%r15
lea    0x1(%rax),%ecx
mov    %ecx,(%r12)
cltq
mov    (%r14,%rax,8),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
mov    (%r12),%eax
cmp    %ebp,%eax
jl     1290 <main+0x150>
mov    0x2d0d(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i8*, i32*, i32 }
@main.longopts = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8 -127, i8* null, i32* inttoptr (i64 97 to i32*), i32 0 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -127, i8* null, i32* inttoptr (i64 118 to i32*), i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -128, i8* null, i32* inttoptr (i64 102 to i32*), i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -127, i8* null, i32* null, i32 0 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8 -128, i8* null, i32* null, i32 0 }, %struct.option zeroinitializer]
@.str = [7 x i8] c"append\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [5 x i8] c"file\00"
@.str.3 = [5 x i8] c"long\00"
@.str.4 = [10 x i8] c"longextra\00"
@.str.5 = [5 x i8] c"af:v\00"
@.str.6 = [10 x i8] c"option %s\00"
@optarg = global i8* null
@.str.7 = [13 x i8] c" with arg %s\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [10 x i8] c"option a\0A\00"
@.str.10 = [19 x i8] c"option f with %s.\0A\00"
@.str.11 = [34 x i8] c"unknown option = %c = ascii(0%x)\0A\00"
@optopt = global i32 0
@.str.12 = [36 x i8] c"return value of getopt_long() = %c\0A\00"
@.str.13 = [19 x i8] c"verbose mode = %i\0A\00"
@optind = global i32 0
@.str.14 = [17 x i8] c"argument[%i]=%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %43, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt_long(i32 %11, i8** %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.longopts, i64 0, i64 0), i32* %7)
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %44
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %37 [
i32 0, label %17
i32 97, label %31
i32 102, label %33
i32 118, label %36
]
17: ; preds = %15
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* @main.longopts, i64 0, i64 %19
%21 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 2
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** @optarg
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %17
%27 = load i8*, i8** @optarg
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %17
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %43
31: ; preds = %15
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
br label %43
33: ; preds = %15
%34 = load i8*, i8** @optarg
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %34)
br label %43
36: ; preds = %15
store i32 1, i32* %8
br label %43
37: ; preds = %15
%38 = load i32, i32* @optopt
%39 = load i32, i32* @optopt
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %37, %36, %33, %31, %29
br label %10
44: ; preds = %10
%45 = load i32, i32* %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @optind
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %67
50: ; preds = %44
store i32 1, i32* %9
br label %51
51: ; preds = %55, %50
%52 = load i32, i32* @optind
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %66
55: ; preds = %51
%56 = load i32, i32* %9
%57 = load i8**, i8*** %5
%58 = load i32, i32* @optind
%59 = add nsw i32 %58, 1
store i32 %59, i32* @optind
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds i8*, i8** %57, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i32 %56, i8* %62)
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %51
66: ; preds = %51
br label %67
67: ; preds = %66, %44
%68 = load i32, i32* @EXIT_SUCCESS
ret i32 %68
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i8*, i32*, i32 }
@main.longopts = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8 -127, i8* null, i32* inttoptr (i64 97 to i32*), i32 0 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -127, i8* null, i32* inttoptr (i64 118 to i32*), i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -128, i8* null, i32* inttoptr (i64 102 to i32*), i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -127, i8* null, i32* null, i32 0 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8 -128, i8* null, i32* null, i32 0 }, %struct.option zeroinitializer]
@.str = [7 x i8] c"append\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [5 x i8] c"file\00"
@.str.3 = [5 x i8] c"long\00"
@.str.4 = [10 x i8] c"longextra\00"
@.str.5 = [5 x i8] c"af:v\00"
@.str.6 = [10 x i8] c"option %s\00"
@optarg = global i8* null
@.str.7 = [13 x i8] c" with arg %s\00"
@.str.10 = [19 x i8] c"option f with %s.\0A\00"
@.str.11 = [34 x i8] c"unknown option = %c = ascii(0%x)\0A\00"
@optopt = global i32 0
@.str.12 = [36 x i8] c"return value of getopt_long() = %c\0A\00"
@.str.13 = [19 x i8] c"verbose mode = %i\0A\00"
@optind = global i32 0
@.str.14 = [17 x i8] c"argument[%i]=%s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [9 x i8] c"option a\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %7, %2
%6 = phi i32 [ 0, %2 ], [ 1, %7 ]
br label %7
7: ; preds = %30, %5
%8 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.longopts, i64 0, i64 0), i32* %3)
switch i32 %8, label %26 [
i32 -1, label %31
i32 0, label %9
i32 97, label %21
i32 102, label %23
i32 118, label %5
]
9: ; preds = %7
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* @main.longopts, i64 0, i64 %11, i32 2
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** @optarg
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %9
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %15)
br label %19
19: ; preds = %17, %9
%20 = call i32 @putchar(i32 10)
br label %30
21: ; preds = %7
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %30
23: ; preds = %7
%24 = load i8*, i8** @optarg
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %24)
br label %30
26: ; preds = %7
%27 = load i32, i32* @optopt
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %27, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %8)
br label %30
30: ; preds = %26, %23, %21, %19
br label %7
31: ; preds = %7
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %6)
%33 = load i32, i32* @optind
%34 = icmp slt i32 %33, %0
br i1 %34, label %35, label %46
35: ; preds = %31, %35
%36 = phi i32 [ %44, %35 ], [ %33, %31 ]
%37 = phi i32 [ %43, %35 ], [ 1, %31 ]
%38 = add nsw i32 %36, 1
store i32 %38, i32* @optind
%39 = sext i32 %36 to i64
%40 = getelementptr inbounds i8*, i8** %1, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i32 %37, i8* %41)
%43 = add nuw nsw i32 %37, 1
%44 = load i32, i32* @optind
%45 = icmp slt i32 %44, %0
br i1 %45, label %35, label %46
46: ; preds = %35, %31
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}