#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 *, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(int);
int optopt;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int c;
  while ((c = getopt(argc, argv, "a")) != -1)
    switch (c) {
    case 'a':
      printf("parsed an a\n");
      break;
    case '?':
      if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      abort();
    }
  return 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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     122b <main+0xdb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x3f,%eax
je     11bb <main+0x6b>
jmp    1199 <main+0x49>
mov    -0x18(%rbp),%eax
sub    $0x61,%eax
jne    121f <main+0xcf>
jmp    11aa <main+0x5a>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
jmp    1226 <main+0xd6>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1060 <isprint@plt>
cmp    $0x0,%eax
je     11f5 <main+0xa5>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
lea    0xe24(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1213 <main+0xc3>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
lea    0xe18(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1232 <main+0xe2>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1166 <main+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xee0(%rip),%r14
lea    0xecf(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0x61,%eax
jne    118c <main+0x3c>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    1170 <main+0x20>
cmp    $0xffffffff,%eax
je     11d1 <main+0x81>
cmp    $0x3f,%eax
jne    11de <main+0x8e>
mov    0x2e4b(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1060 <isprint@plt>
test   %eax,%eax
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rax
lea    0xe41(%rip),%rsi
cmove  %rax,%rsi
mov    %ebx,%edx
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11d3 <main+0x83>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [13 x i8] c"parsed an a\0A\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\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
br label %7
7: ; preds = %31, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %32
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %29 [
i32 97, label %14
i32 63, label %16
]
14: ; preds = %12
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %31
16: ; preds = %12
%17 = load i32, i32* @optopt
%18 = call i32 @isprint(i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = load i32, i32* @optopt
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %28
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = load i32, i32* @optopt
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %20
store i32 1, i32* %3
br label %33
29: ; preds = %12
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %14
br label %7
32: ; preds = %7
store i32 0, i32* %3
br label %33
33: ; preds = %32, %28
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@optopt = global i32 0
@stderr = global i32 0
@.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 = [12 x i8] c"parsed an a\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %14 [
i32 -1, label %16
i32 97, label %5
i32 63, label %7
]
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %3
7: ; preds = %3
%8 = load i32, i32* @optopt
%9 = tail call i32 @isprint(i32 %8)
%10 = icmp eq i32 %9, 0
%11 = load i32, i32* @stderr
%12 = select i1 %10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0)
%13 = tail call i32 @fprintf(i32 %11, i8* %12, i32 %8)
br label %16
14: ; preds = %3
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %3, %7
%17 = phi i32 [ 1, %7 ], [ 0, %3 ]
ret i32 %17
}