#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
char *optarg;
scalar_t__ opterr;
int optind;
char optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int aflag = 0;
  int bflag = 0;
  char *cvalue = NULL;
  int index;
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "abc:")) != -1) {
    switch (c) {
    case 'a': {
      aflag = 1;
      break;
    }
    case 'b': {
      bflag = 1;
      break;
    }
    case 'c': {
      cvalue = optarg;
      break;
    }
    case '?': {
      if (optopt == 'c') {
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      } else if (isprint(optopt)) {
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      } else {
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      }
      return (1);
    }
    default: {
      abort();
    }
    }
  }
  printf("aflag = %d, bflag = %d, cvalue = %s\n", aflag, bflag, cvalue);
  for (index = optind; index < argc; index++) {
    printf("Non-option argument %s\n", argv[index]);
  }
  return (0);
}


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,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e3d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xefc(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     12ac <main+0x15c>
mov    -0x28(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x24,%eax
ja     12a0 <main+0x150>
mov    -0x30(%rbp),%rax
lea    0xe37(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x14(%rbp)
jmp    12a7 <main+0x157>
movl   $0x1,-0x18(%rbp)
jmp    12a7 <main+0x157>
mov    0x2e07(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12a7 <main+0x157>
mov    0x2ddc(%rip),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    1234 <main+0xe4>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
mov    0x2db9(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    1294 <main+0x144>
mov    0x2da5(%rip),%rax
movsbl (%rax),%edi
call   1060 <isprint@plt>
cmp    $0x0,%eax
je     1270 <main+0x120>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rsi
mov    0x2d7d(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    128f <main+0x13f>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
mov    0x2d59(%rip),%rax
movsbl (%rax),%edx
call   1050 <fprintf@plt>
jmp    1294 <main+0x144>
movl   $0x1,-0x4(%rbp)
jmp    130b <main+0x1bb>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    118a <main+0x3a>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1304 <main+0x1b4>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12d0 <main+0x180>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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,%ebx
mov    0x2e59(%rip),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xe85(%rip),%rbp
mov    0x2e76(%rip),%r15
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1193 <main+0x43>
nopw   0x0(%rax,%rax,1)
mov    (%r15),%r12
mov    %ebx,%edi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1070 <getopt@plt>
cmp    $0x63,%eax
je     1190 <main+0x40>
cmp    $0x60,%eax
jle    11cb <main+0x7b>
cmp    $0x61,%eax
je     11c0 <main+0x70>
cmp    $0x62,%eax
jne    129f <main+0x14f>
mov    $0x1,%r13d
jmp    1193 <main+0x43>
mov    $0x1,%eax
mov    %rax,(%rsp)
jmp    1193 <main+0x43>
cmp    $0xffffffff,%eax
je     1200 <main+0xb0>
cmp    $0x3f,%eax
jne    129f <main+0x14f>
mov    0x2e00(%rip),%rbx
mov    (%rbx),%al
cmp    $0x63,%al
jne    1258 <main+0x108>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
mov    $0x63,%edx
jmp    1282 <main+0x132>
lea    0xe59(%rip),%rdi
xor    %r15d,%r15d
mov    (%rsp),%rsi
mov    %r13d,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2db6(%rip),%rax
movslq (%rax),%rax
cmp    %ebx,%eax
jge    128d <main+0x13d>
lea    (%r14,%rax,8),%r12
sub    %eax,%ebx
xor    %r15d,%r15d
lea    0xe4c(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %ebp,%ebx
jne    1240 <main+0xf0>
jmp    128d <main+0x13d>
movsbl %al,%edi
call   1060 <isprint@plt>
mov    0x2d61(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx),%cl
movsbl %cl,%edx
test   %eax,%eax
je     127b <main+0x12b>
lea    0xdae(%rip),%rsi
jmp    1282 <main+0x132>
lea    0xdbc(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [5 x i8] c"abc:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.4 = [37 x i8] c"aflag = %d, bflag = %d, cvalue = %s\0A\00"
@optind = global i32 0
@.str.5 = [24 x i8] c"Non-option 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 i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* null, i8** %8
store i64 0, i64* @opterr
br label %11
11: ; preds = %46, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %10
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %47
16: ; preds = %11
%17 = load i32, i32* %10
switch i32 %17, label %44 [
i32 97, label %18
i32 98, label %19
i32 99, label %20
i32 63, label %22
]
18: ; preds = %16
store i32 1, i32* %6
br label %46
19: ; preds = %16
store i32 1, i32* %7
br label %46
20: ; preds = %16
%21 = load i8*, i8** @optarg
store i8* %21, i8** %8
br label %46
22: ; preds = %16
%23 = load i8, i8* @optopt
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 99
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i8, i8* @optopt
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext %28)
br label %43
30: ; preds = %22
%31 = load i8, i8* @optopt
%32 = call i32 @isprint(i8 signext %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i8, i8* @optopt
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %36)
br label %42
38: ; preds = %30
%39 = load i32, i32* @stderr
%40 = load i8, i8* @optopt
%41 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext %40)
br label %42
42: ; preds = %38, %34
br label %43
43: ; preds = %42, %26
store i32 1, i32* %3
br label %68
44: ; preds = %16
%45 = call i32 (...) @abort()
unreachable
46: ; preds = %20, %19, %18
br label %11
47: ; preds = %11
%48 = load i32, i32* %6
%49 = load i32, i32* %7
%50 = load i8*, i8** %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %48, i32 %49, i8* %50)
%52 = load i32, i32* @optind
store i32 %52, i32* %9
br label %53
53: ; preds = %64, %47
%54 = load i32, i32* %9
%55 = load i32, i32* %4
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %67
57: ; preds = %53
%58 = load i8**, i8*** %5
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %57
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %53
67: ; preds = %53
store i32 0, i32* %3
br label %68
68: ; preds = %67, %43
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [5 x i8] c"abc:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.4 = [37 x i8] c"aflag = %d, bflag = %d, cvalue = %s\0A\00"
@optind = global i32 0
@.str.5 = [24 x i8] c"Non-option argument %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %10, %2
%4 = phi i32 [ 0, %2 ], [ 1, %10 ]
%5 = phi i32 [ 0, %2 ], [ %8, %10 ]
%6 = phi i8* [ null, %2 ], [ %11, %10 ]
br label %7
7: ; preds = %10, %3
%8 = phi i32 [ %5, %3 ], [ 1, %10 ]
%9 = phi i8* [ %6, %3 ], [ %11, %10 ]
br label %10
10: ; preds = %7, %13
%11 = phi i8* [ %14, %13 ], [ %9, %7 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %30 [
i32 -1, label %32
i32 97, label %3
i32 98, label %7
i32 99, label %13
i32 63, label %15
]
13: ; preds = %10
%14 = load i8*, i8** @optarg
br label %10
15: ; preds = %10
%16 = load i8, i8* @optopt
%17 = icmp eq i8 %16, 99
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext 99)
br label %46
21: ; preds = %15
%22 = tail call i32 @isprint(i8 signext %16)
%23 = icmp eq i32 %22, 0
%24 = load i32, i32* @stderr
%25 = load i8, i8* @optopt
br i1 %23, label %28, label %26
26: ; preds = %21
%27 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %25)
br label %46
28: ; preds = %21
%29 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext %25)
br label %46
30: ; preds = %10
%31 = tail call i32 (...) @abort()
unreachable
32: ; preds = %10
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %4, i32 %8, i8* %11)
%34 = load i32, i32* @optind
%35 = icmp slt i32 %34, %0
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = sext i32 %34 to i64
br label %38
38: ; preds = %36, %38
%39 = phi i64 [ %37, %36 ], [ %43, %38 ]
%40 = getelementptr inbounds i8*, i8** %1, i64 %39
%41 = load i8*, i8** %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = add nsw i64 %39, 1
%44 = trunc i64 %43 to i32
%45 = icmp eq i32 %44, %0
br i1 %45, label %46, label %38
46: ; preds = %38, %32, %18, %28, %26
%47 = phi i32 [ 1, %26 ], [ 1, %28 ], [ 1, %18 ], [ 0, %32 ], [ 0, %38 ]
ret i32 %47
}