#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
char *optarg;
scalar_t__ opterr;
size_t optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int result;
  opterr = 0;
  while ((result = getopt(argc, argv, "ab:c::")) != -1) {
    switch (result) {
    case 'a':
      printf("option=a, optopt=%c, optarg=%s\n", optopt, optarg);
      break;
    case 'b':
      printf("option=b, optopt=%c, optarg=%s\n", optopt, optarg);
      break;
    case 'c':
      printf("option=c, optopt=%c, optarg=%s\n", optopt, optarg);
      break;
    case '?':
      printf("result=?, optopt=%c, optarg=%s\n", optopt, optarg);
      break;
    default:
      printf("default, result=%c\n", result);
      break;
    }
    printf("argv[%d]=%s\n", optind, argv[optind]);
  }
  printf("----------------------\n");
  printf("result=-1, optind=%d\n", optind);
  for (result = optind; result < argc; result++)
    printf("-----argv[%d]=%s\n", result, argv[result]);
  for (result = 1; result < argc; result++)
    printf("\nat the end ----- argv[%d]=%s\n", result, argv[result]);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e7b(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf32(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1274 <main+0x144>
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x24,%eax
ja     1234 <main+0x104>
mov    -0x20(%rbp),%rax
lea    0xe6d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
mov    0x2e4c(%rip),%rax
mov    (%rax),%rdx
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <main+0x115>
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
mov    0x2e26(%rip),%rax
mov    (%rax),%rdx
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <main+0x115>
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
mov    0x2e00(%rip),%rax
mov    (%rax),%rdx
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <main+0x115>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    0x2dda(%rip),%rax
mov    (%rax),%rdx
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <main+0x115>
mov    -0x14(%rbp),%esi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x2d7e(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xf19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1154 <main+0x24>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12de <main+0x1ae>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a7 <main+0x177>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    131c <main+0x1ec>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12e5 <main+0x1b5>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r13d
mov    0x2e70(%rip),%rax
movq   $0x0,(%rax)
lea    0xf2e(%rip),%r14
mov    0x2e6b(%rip),%rbp
lea    0xff5(%rip),%r12
lea    0xe85(%rip),%r15
jmp    11b0 <main+0x70>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
mov    0x2e6b(%rip),%rax
mov    (%rax),%rdx
lea    0xf44(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%rbp),%rsi
mov    (%rbx,%rsi,8),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x24,%ecx
ja     1226 <main+0xe6>
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
mov    0x2e19(%rip),%rax
mov    (%rax),%rdx
lea    0xf12(%rip),%rdi
jmp    1197 <main+0x57>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
mov    0x2dfd(%rip),%rax
mov    (%rax),%rdx
lea    0xe96(%rip),%rdi
jmp    1197 <main+0x57>
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
mov    0x2de1(%rip),%rax
mov    (%rax),%rdx
lea    0xe9a(%rip),%rdi
jmp    1197 <main+0x57>
cmp    $0xffffffff,%eax
je     1240 <main+0x100>
lea    0xee9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119e <main+0x5e>
lea    0xf2f(%rip),%rdi
call   1030 <puts@plt>
mov    0x0(%rbp),%rsi
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%rbp),%rbp
cmp    %r13d,%ebp
jge    129b <main+0x15b>
movslq %ebp,%rax
lea    (%rbx,%rax,8),%r15
lea    0xed0(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x8,%r15
cmp    %ebp,%r13d
jne    1280 <main+0x140>
cmp    $0x2,%r13d
jl     12c9 <main+0x189>
mov    %r13d,%r15d
mov    $0x1,%ebp
lea    0xea7(%rip),%r14
mov    (%rbx,%rbp,8),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    12b0 <main+0x170>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [7 x i8] c"ab:c::\00"
@.str.1 = [32 x i8] c"option=a, optopt=%c, optarg=%s\0A\00"
@optopt = global i32 0
@optarg = global i8* null
@.str.2 = [32 x i8] c"option=b, optopt=%c, optarg=%s\0A\00"
@.str.3 = [32 x i8] c"option=c, optopt=%c, optarg=%s\0A\00"
@.str.4 = [32 x i8] c"result=?, optopt=%c, optarg=%s\0A\00"
@.str.5 = [20 x i8] c"default, result=%c\0A\00"
@.str.6 = [13 x i8] c"argv[%d]=%s\0A\00"
@optind = global i64 0
@.str.7 = [24 x i8] c"----------------------\0A\00"
@.str.8 = [22 x i8] c"result=-1, optind=%d\0A\00"
@.str.9 = [18 x i8] c"-----argv[%d]=%s\0A\00"
@.str.10 = [31 x i8] c"\0Aat the end ----- argv[%d]=%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
store i64 0, i64* @opterr
br label %7
7: ; preds = %33, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %40
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %30 [
i32 97, label %14
i32 98, label %18
i32 99, label %22
i32 63, label %26
]
14: ; preds = %12
%15 = load i32, i32* @optopt
%16 = load i8*, i8** @optarg
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %16)
br label %33
18: ; preds = %12
%19 = load i32, i32* @optopt
%20 = load i8*, i8** @optarg
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %19, i8* %20)
br label %33
22: ; preds = %12
%23 = load i32, i32* @optopt
%24 = load i8*, i8** @optarg
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %23, i8* %24)
br label %33
26: ; preds = %12
%27 = load i32, i32* @optopt
%28 = load i8*, i8** @optarg
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %27, i8* %28)
br label %33
30: ; preds = %12
%31 = load i32, i32* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %26, %22, %18, %14
%34 = load i64, i64* @optind
%35 = load i8**, i8*** %5
%36 = load i64, i64* @optind
%37 = getelementptr inbounds i8*, i8** %35, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 %34, i8* %38)
br label %7
40: ; preds = %7
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%42 = load i64, i64* @optind
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i64 %42)
%44 = load i64, i64* @optind
%45 = trunc i64 %44 to i32
store i32 %45, i32* %6
br label %46
46: ; preds = %58, %40
%47 = load i32, i32* %6
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %61
50: ; preds = %46
%51 = load i32, i32* %6
%52 = load i8**, i8*** %5
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %51, i8* %56)
br label %58
58: ; preds = %50
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %46
61: ; preds = %46
store i32 1, i32* %6
br label %62
62: ; preds = %74, %61
%63 = load i32, i32* %6
%64 = load i32, i32* %4
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %77
66: ; preds = %62
%67 = load i32, i32* %6
%68 = load i8**, i8*** %5
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %67, i8* %72)
br label %74
74: ; preds = %66
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %62
77: ; preds = %62
%78 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [7 x i8] c"ab:c::\00"
@.str.1 = [32 x i8] c"option=a, optopt=%c, optarg=%s\0A\00"
@optopt = global i32 0
@optarg = global i8* null
@.str.2 = [32 x i8] c"option=b, optopt=%c, optarg=%s\0A\00"
@.str.3 = [32 x i8] c"option=c, optopt=%c, optarg=%s\0A\00"
@.str.4 = [32 x i8] c"result=?, optopt=%c, optarg=%s\0A\00"
@.str.5 = [20 x i8] c"default, result=%c\0A\00"
@.str.6 = [13 x i8] c"argv[%d]=%s\0A\00"
@optind = global i64 0
@.str.8 = [22 x i8] c"result=-1, optind=%d\0A\00"
@.str.9 = [18 x i8] c"-----argv[%d]=%s\0A\00"
@.str.10 = [31 x i8] c"\0Aat the end ----- argv[%d]=%s\0A\00"
@str = [23 x i8] c"----------------------\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %23, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %21 [
i32 -1, label %28
i32 97, label %5
i32 98, label %9
i32 99, label %13
i32 63, label %17
]
5: ; preds = %3
%6 = load i32, i32* @optopt
%7 = load i8*, i8** @optarg
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %6, i8* %7)
br label %23
9: ; preds = %3
%10 = load i32, i32* @optopt
%11 = load i8*, i8** @optarg
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %10, i8* %11)
br label %23
13: ; preds = %3
%14 = load i32, i32* @optopt
%15 = load i8*, i8** @optarg
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %14, i8* %15)
br label %23
17: ; preds = %3
%18 = load i32, i32* @optopt
%19 = load i8*, i8** @optarg
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %18, i8* %19)
br label %23
21: ; preds = %3
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %4)
br label %23
23: ; preds = %21, %17, %13, %9, %5
%24 = load i64, i64* @optind
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 %24, i8* %26)
br label %3
28: ; preds = %3
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%30 = load i64, i64* @optind
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i64 %30)
%32 = load i64, i64* @optind
%33 = trunc i64 %32 to i32
%34 = icmp slt i32 %33, %0
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = shl i64 %32, 32
%37 = ashr exact i64 %36, 32
br label %42
38: ; preds = %42, %28
%39 = icmp sgt i32 %0, 1
br i1 %39, label %40, label %59
40: ; preds = %38
%41 = zext i32 %0 to i64
br label %51
42: ; preds = %35, %42
%43 = phi i64 [ %37, %35 ], [ %48, %42 ]
%44 = getelementptr inbounds i8*, i8** %1, i64 %43
%45 = load i8*, i8** %44
%46 = trunc i64 %43 to i32
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %46, i8* %45)
%48 = add nsw i64 %43, 1
%49 = trunc i64 %48 to i32
%50 = icmp eq i32 %49, %0
br i1 %50, label %38, label %42
51: ; preds = %40, %51
%52 = phi i64 [ 1, %40 ], [ %57, %51 ]
%53 = getelementptr inbounds i8*, i8** %1, i64 %52
%54 = load i8*, i8** %53
%55 = trunc i64 %52 to i32
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %55, i8* %54)
%57 = add nuw nsw i64 %52, 1
%58 = icmp eq i64 %57, %41
br i1 %58, label %59, label %51
59: ; preds = %51, %38
%60 = tail call i32 @exit(i32 0)
unreachable
}