#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 */

/* Variables and functions */
int getopt(int, char **, char *);
char *optarg;
int opterr;
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char *argv[]) {
  int c;
  printf("[start] optind = %d, opterr = %d, optopt = %d(%c), optarg = %s\n",
         optind, opterr, optopt, optopt, optarg ? optarg : "NULL");
  opterr = 1;
  while ((c = getopt(argc, argv, "-i:F::")) != -1) {
    printf(
        "[while loop] optind = %d, opterr = %d, optopt = %d(%c), optarg = %s\n",
        optind, opterr, optopt, optopt, optarg ? optarg : "NULL");
    switch (c) {
    case 'i':
      printf("option is %c, option value is %s\n", c, optarg);
      break;
    case 'F':
      printf("option is %c, option value is %s\n", c, optarg);
      break;
    case 1:
      printf("option is %c, option value is %s\n", c, optarg);
      break;
    case '?':
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e8b(%rip),%rax
cmpq   $0x0,(%rax)
je     118a <main+0x6a>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    119a <main+0x7a>
lea    0xeaf(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    119a <main+0x7a>
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%r9
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e08(%rip),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe71(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     131e <main+0x1fe>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2ddc(%rip),%rax
cmpq   $0x0,(%rax)
je     1239 <main+0x119>
mov    0x2dcb(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    1249 <main+0x129>
lea    0xe00(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    1249 <main+0x129>
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%esi
mov    -0x48(%rbp),%r9
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x1,%eax
je     12ef <main+0x1cf>
jmp    127c <main+0x15c>
mov    -0x4c(%rbp),%eax
sub    $0x3f,%eax
je     130f <main+0x1ef>
jmp    128d <main+0x16d>
mov    -0x4c(%rbp),%eax
sub    $0x46,%eax
je     12cf <main+0x1af>
jmp    129e <main+0x17e>
mov    -0x4c(%rbp),%eax
sub    $0x69,%eax
jne    1314 <main+0x1f4>
jmp    12af <main+0x18f>
mov    -0x14(%rbp),%esi
mov    0x2d3f(%rip),%rax
mov    (%rax),%rdx
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1319 <main+0x1f9>
mov    -0x14(%rbp),%esi
mov    0x2d1f(%rip),%rax
mov    (%rax),%rdx
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1319 <main+0x1f9>
mov    -0x14(%rbp),%esi
mov    0x2cff(%rip),%rax
mov    (%rax),%rdx
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1319 <main+0x1f9>
jmp    1314 <main+0x1f4>
jmp    1319 <main+0x1f9>
jmp    11c6 <main+0xa6>
mov    -0x4(%rbp),%eax
add    $0x50,%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,%r13
mov    %edi,%ebp
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
mov    0x2e88(%rip),%rbx
mov    (%rbx),%edx
mov    0x2e97(%rip),%rax
mov    (%rax),%ecx
mov    0x2ea6(%rip),%r15
mov    (%r15),%r9
test   %r9,%r9
lea    0xee1(%rip),%rax
cmove  %rax,%r9
lea    0xe96(%rip),%rdi
mov    %ecx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x1,(%rbx)
lea    0xec4(%rip),%rdx
mov    %ebp,%edi
mov    %r13,%rsi
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     1221 <main+0x101>
mov    %eax,%ebx
lea    0xeaf(%rip),%r14
lea    0xea1(%rip),%r12
jmp    11d7 <main+0xb7>
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%rdx
lea    0xed7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r12,%rdx
call   1040 <getopt@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1221 <main+0x101>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
mov    0x2df0(%rip),%rax
mov    (%rax),%ecx
mov    (%r15),%r9
test   %r9,%r9
lea    0xe41(%rip),%rax
cmove  %rax,%r9
mov    %r14,%rdi
mov    %ecx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%ebx
je     11b0 <main+0x90>
cmp    $0x69,%ebx
je     11b0 <main+0x90>
cmp    $0x46,%ebx
je     11b0 <main+0x90>
jmp    11c3 <main+0xa3>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"[start] optind = %d, opterr = %d, optopt = %d(%c), optarg = %s\0A\00"
@optind = global i32 0
@opterr = global i32 0
@optopt = global i32 0
@optarg = global i8* null
@.str.1 = [5 x i8] c"NULL\00"
@.str.2 = [7 x i8] c"-i:F::\00"
@.str.3 = [69 x i8] c"[while loop] optind = %d, opterr = %d, optopt = %d(%c), optarg = %s\0A\00"
@.str.4 = [34 x i8] c"option is %c, option value is %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @optind
%8 = load i32, i32* @opterr
%9 = load i32, i32* @optopt
%10 = load i32, i32* @optopt
%11 = load i8*, i8** @optarg
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i8*, i8** @optarg
br label %16
15: ; preds = %2
br label %16
16: ; preds = %15, %13
%17 = phi i8* [ %14, %13 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %15 ]
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i32 %9, i32 %10, i8* %17)
store i32 1, i32* @opterr
br label %19
19: ; preds = %52, %16
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 %22, i32* %6
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %53
24: ; preds = %19
%25 = load i32, i32* @optind
%26 = load i32, i32* @opterr
%27 = load i32, i32* @optopt
%28 = load i32, i32* @optopt
%29 = load i8*, i8** @optarg
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = load i8*, i8** @optarg
br label %34
33: ; preds = %24
br label %34
34: ; preds = %33, %31
%35 = phi i8* [ %32, %31 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %33 ]
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %26, i32 %27, i32 %28, i8* %35)
%37 = load i32, i32* %6
switch i32 %37, label %51 [
i32 105, label %38
i32 70, label %42
i32 1, label %46
i32 63, label %50
]
38: ; preds = %34
%39 = load i32, i32* %6
%40 = load i8*, i8** @optarg
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %39, i8* %40)
br label %52
42: ; preds = %34
%43 = load i32, i32* %6
%44 = load i8*, i8** @optarg
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %43, i8* %44)
br label %52
46: ; preds = %34
%47 = load i32, i32* %6
%48 = load i8*, i8** @optarg
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %47, i8* %48)
br label %52
50: ; preds = %34
br label %51
51: ; preds = %34, %50
br label %52
52: ; preds = %51, %46, %42, %38
br label %19
53: ; preds = %19
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [64 x i8] c"[start] optind = %d, opterr = %d, optopt = %d(%c), optarg = %s\0A\00"
@optind = global i32 0
@opterr = global i32 0
@optopt = global i32 0
@optarg = global i8* null
@.str.1 = [5 x i8] c"NULL\00"
@.str.2 = [7 x i8] c"-i:F::\00"
@.str.3 = [69 x i8] c"[while loop] optind = %d, opterr = %d, optopt = %d(%c), optarg = %s\0A\00"
@.str.4 = [34 x i8] c"option is %c, option value is %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @optind
%4 = load i32, i32* @opterr
%5 = load i32, i32* @optopt
%6 = load i8*, i8** @optarg
%7 = icmp eq i8* %6, null
%8 = select i1 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4, i32 %5, i32 %5, i8* %8)
store i32 1, i32* @opterr
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, -1
br i1 %11, label %27, label %12
12: ; preds = %2, %24
%13 = phi i32 [ %25, %24 ], [ %10, %2 ]
%14 = load i32, i32* @optind
%15 = load i32, i32* @opterr
%16 = load i32, i32* @optopt
%17 = load i8*, i8** @optarg
%18 = icmp eq i8* %17, null
%19 = select i1 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %17
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %15, i32 %16, i32 %16, i8* %19)
switch i32 %13, label %24 [
i32 105, label %21
i32 70, label %21
i32 1, label %21
]
21: ; preds = %12, %12, %12
%22 = load i8*, i8** @optarg
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %13, i8* %22)
br label %24
24: ; preds = %21, %12
%25 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %12
27: ; preds = %24, %2
ret i32 0
}