#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 EOF;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
scalar_t__ opterr;
scalar_t__ optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
void main(int argc, char *argv[]) {
  int c;
  int aflag = 0;
  int bflag = 0;
  int numoption = 0;
  char txtoption[200] = "default";
  opterr = 0;
  while ((c = getopt(argc, argv, "abn:t:")) != EOF) {
    switch (c) {
    case 'a':
      aflag = 1;
      break;
    case 'b':
      bflag = 1;
      break;
    case 'n':
      numoption = atoi(optarg);
      break;
    case 't':
      strcpy(txtoption, optarg);
      break;
    case '?':
      fprintf(stderr, "invalid option: -%c\n", optopt);
    }
  }
  if (aflag)
    printf("Option a is set\n");
  if (bflag)
    printf("Option b is set\n");
  printf("Numeric option value is %d\n", numoption);
  printf("Text    option value is %s\n", txtoption);
  argv += optind;
  argc -= optind;
  while (argc--) {
    printf("arg: %s\n", *argv++);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0xf0(%rbp),%rdi
lea    0xe6b(%rip),%rsi
mov    $0xc8,%edx
call   1060 <memcpy@plt>
mov    0x2e12(%rip),%rax
movq   $0x0,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf0d(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e0e(%rip),%rcx
cmp    (%rcx),%eax
je     12a4 <main+0x144>
mov    -0x14(%rbp),%eax
mov    %eax,-0xf4(%rbp)
sub    $0x3f,%eax
je     1281 <main+0x121>
jmp    11e9 <main+0x89>
mov    -0xf4(%rbp),%eax
sub    $0x61,%eax
je     1239 <main+0xd9>
jmp    11fd <main+0x9d>
mov    -0xf4(%rbp),%eax
sub    $0x62,%eax
je     1245 <main+0xe5>
jmp    1211 <main+0xb1>
mov    -0xf4(%rbp),%eax
sub    $0x6e,%eax
je     1251 <main+0xf1>
jmp    1225 <main+0xc5>
mov    -0xf4(%rbp),%eax
sub    $0x74,%eax
je     1267 <main+0x107>
jmp    129f <main+0x13f>
movl   $0x1,-0x18(%rbp)
jmp    129f <main+0x13f>
movl   $0x1,-0x1c(%rbp)
jmp    129f <main+0x13f>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    129f <main+0x13f>
lea    -0xf0(%rbp),%rdi
mov    0x2d83(%rip),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
jmp    129f <main+0x13f>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
mov    0x2d4f(%rip),%rax
mov    (%rax),%edx
lea    0xe35(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ad <main+0x4d>
cmpl   $0x0,-0x18(%rbp)
je     12bc <main+0x15c>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     12d4 <main+0x174>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2cb9(%rip),%rax
mov    (%rax),%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     135d <main+0x1fd>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1324 <main+0x1c4>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xec3(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0xc8,%edx
call   1070 <memcpy@plt>
mov    0x2e15(%rip),%rax
movq   $0x0,(%rax)
lea    0xf67(%rip),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
call   1080 <getopt@plt>
mov    0x2e16(%rip),%r15
xor    %ebx,%ebx
cmp    (%r15),%eax
je     12a7 <main+0x137>
xor    %ebx,%ebx
lea    0xf42(%rip),%r12
lea    0xe23(%rip),%r13
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
jmp    1222 <main+0xb2>
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1080 <getopt@plt>
cmp    (%r15),%eax
je     1281 <main+0x111>
lea    -0x61(%rax),%ecx
cmp    $0x13,%ecx
ja     1240 <main+0xd0>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
movl   $0x1,0x8(%rsp)
jmp    1210 <main+0xa0>
xchg   %ax,%ax
cmp    $0x3f,%eax
jne    1210 <main+0xa0>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    0x2d8b(%rip),%rax
mov    (%rax),%edx
lea    0xec1(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1210 <main+0xa0>
movl   $0x1,0xc(%rsp)
jmp    1210 <main+0xa0>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1090 <atoi@plt>
mov    %eax,%ebx
jmp    1210 <main+0xa0>
cmpl   $0x0,0x8(%rsp)
je     1294 <main+0x124>
lea    0xef6(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
je     12a7 <main+0x137>
lea    0xed3(%rip),%rdi
call   1040 <puts@plt>
lea    0xe86(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe92(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2cff(%rip),%rax
mov    (%rax),%rbx
cmp    %ebx,%ebp
je     1306 <main+0x196>
mov    %ebp,%ebp
lea    0xe8b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    12f0 <main+0x180>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.txtoption = [200 x i8] c"default\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@opterr = global i64 0
@.str = [7 x i8] c"abn:t:\00"
@EOF = global i32 0
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"invalid option: -%c\0A\00"
@optopt = global i32 0
@.str.2 = [17 x i8] c"Option a is set\0A\00"
@.str.3 = [17 x i8] c"Option b is set\0A\00"
@.str.4 = [28 x i8] c"Numeric option value is %d\0A\00"
@.str.5 = [28 x i8] c"Text option value is %s\0A\00"
@optind = global i64 0
@.str.6 = [9 x i8] c"arg: %s\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [200 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%10 = bitcast [200 x i8]* %9 to i8*
store i64 0, i64* @opterr
br label %11
11: ; preds = %32, %2
%12 = load i32, i32* %3
%13 = load i8**, i8*** %4
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %5
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %11
%18 = load i32, i32* %5
switch i32 %18, label %32 [
i32 97, label %19
i32 98, label %20
i32 110, label %21
i32 116, label %24
i32 63, label %28
]
19: ; preds = %17
store i32 1, i32* %6
br label %32
20: ; preds = %17
store i32 1, i32* %7
br label %32
21: ; preds = %17
%22 = load i32, i32* @optarg
%23 = call i32 @atoi(i32 %22)
store i32 %23, i32* %8
br label %32
24: ; preds = %17
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%26 = load i32, i32* @optarg
%27 = call i32 @strcpy(i8* %25, i32 %26)
br label %32
28: ; preds = %17
%29 = load i32, i32* @stderr
%30 = load i32, i32* @optopt
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %17, %24, %21, %20, %19
br label %11
33: ; preds = %11
%34 = load i32, i32* %6
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
%39 = load i32, i32* %7
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %38
%44 = load i32, i32* %8
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %46)
%48 = load i64, i64* @optind
%49 = load i8**, i8*** %4
%50 = getelementptr inbounds i8*, i8** %49, i64 %48
store i8** %50, i8*** %4
%51 = load i64, i64* @optind
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = sub nsw i64 %53, %51
%55 = trunc i64 %54 to i32
store i32 %55, i32* %3
br label %56
56: ; preds = %60, %43
%57 = load i32, i32* %3
%58 = add nsw i32 %57, -1
store i32 %58, i32* %3
%59 = icmp ne i32 %57, 0
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = load i8**, i8*** %4
%62 = getelementptr inbounds i8*, i8** %61, i32 1
store i8** %62, i8*** %4
%63 = load i8*, i8** %61
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %63)
br label %56
65: ; preds = %56
ret void
}

LLVM IR (-O2):
@__const.main.txtoption = [200 x i8] c"default\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@opterr = global i64 0
@.str = [7 x i8] c"abn:t:\00"
@EOF = global i32 0
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"invalid option: -%c\0A\00"
@optopt = global i32 0
@.str.4 = [28 x i8] c"Numeric option value is %d\0A\00"
@.str.5 = [28 x i8] c"Text option value is %s\0A\00"
@optind = global i64 0
@.str.6 = [9 x i8] c"arg: %s\0A\00"
@str = [16 x i8] c"Option b is set\00"
@str.7 = [16 x i8] c"Option a is set\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
store i64 0, i64* @opterr
%5 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %40, label %8
8: ; preds = %2, %25
%9 = phi i32 [ %29, %25 ], [ %5, %2 ]
%10 = phi i32 [ %28, %25 ], [ 0, %2 ]
%11 = phi i32 [ %27, %25 ], [ 0, %2 ]
%12 = phi i32 [ %26, %25 ], [ 0, %2 ]
switch i32 %9, label %25 [
i32 97, label %13
i32 98, label %14
i32 110, label %15
i32 116, label %18
i32 63, label %21
]
13: ; preds = %8
br label %25
14: ; preds = %8
br label %25
15: ; preds = %8
%16 = load i32, i32* @optarg
%17 = call i32 @atoi(i32 %16)
br label %25
18: ; preds = %8
%19 = load i32, i32* @optarg
%20 = call i32 @strcpy(i8* %4, i32 %19)
br label %25
21: ; preds = %8
%22 = load i32, i32* @stderr
%23 = load i32, i32* @optopt
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %21, %8, %18, %15, %14, %13
%26 = phi i32 [ %12, %8 ], [ %12, %21 ], [ %12, %18 ], [ %12, %15 ], [ %12, %14 ], [ 1, %13 ]
%27 = phi i32 [ %11, %8 ], [ %11, %21 ], [ %11, %18 ], [ %11, %15 ], [ 1, %14 ], [ %11, %13 ]
%28 = phi i32 [ %10, %8 ], [ %10, %21 ], [ %10, %18 ], [ %17, %15 ], [ %10, %14 ], [ %10, %13 ]
%29 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %8
32: ; preds = %25
%33 = icmp eq i32 %26, 0
br i1 %33, label %36, label %34
34: ; preds = %32
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.7, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
%37 = icmp eq i32 %27, 0
br i1 %37, label %40, label %38
38: ; preds = %36
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %40
40: ; preds = %2, %38, %36
%41 = phi i32 [ %28, %38 ], [ %28, %36 ], [ 0, %2 ]
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%44 = load i64, i64* @optind
%45 = trunc i64 %44 to i32
%46 = sub i32 %0, %45
%47 = icmp eq i32 %46, 0
br i1 %47, label %58, label %48
48: ; preds = %40
%49 = getelementptr inbounds i8*, i8** %1, i64 %44
br label %50
50: ; preds = %48, %50
%51 = phi i32 [ %53, %50 ], [ %46, %48 ]
%52 = phi i8** [ %54, %50 ], [ %49, %48 ]
%53 = add nsw i32 %51, -1
%54 = getelementptr inbounds i8*, i8** %52, i64 1
%55 = load i8*, i8** %52
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = icmp eq i32 %53, 0
br i1 %57, label %58, label %50
58: ; preds = %50, %40
ret void
}