#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;
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int opt;
  while ((opt = getopt(argc, argv, ":if:lr")) != -1) {
    switch (opt) {
    case 'i':
    case 'l':
    case 'r':
      printf("option: %c\n", opt);
      break;
    case 'f':
      printf("filename: %s\n", optarg);
      break;
    case ':':
      printf("option needs a value\n");
      break;
    case '?':
      printf("unknown option: %c\n", optopt);
      break;
    }
  }
  for (; optind < argc; optind++)
    printf("argument: %s\n", argv[optind]);
  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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf90(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11f0 <main+0xc0>
mov    -0x14(%rbp),%eax
add    $0xffffffc6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x38,%eax
ja     11eb <main+0xbb>
mov    -0x20(%rbp),%rax
lea    0xe7b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%esi
lea    0xf7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xbb>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rsi
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xbb>
lea    0xf31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xbb>
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
lea    0xf2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1146 <main+0x16>
jmp    11f5 <main+0xc5>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1241 <main+0x111>
mov    -0x10(%rbp),%rax
mov    0x2dc6(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2d9e(%rip),%rax
mov    %ecx,(%rax)
jmp    11f5 <main+0xc5>
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,%ebp
lea    0xf8d(%rip),%r14
lea    0xea2(%rip),%r12
lea    0xf86(%rip),%r13
lea    0xf95(%rip),%r15
jmp    117c <main+0x3c>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
lea    -0x3a(%rax),%ecx
cmp    $0x38,%ecx
ja     11d0 <main+0x90>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
lea    0xf7a(%rip),%rdi
call   1030 <puts@plt>
jmp    117c <main+0x3c>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    0xf41(%rip),%rdi
jmp    1175 <main+0x35>
mov    0x2e37(%rip),%rax
mov    (%rax),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117c <main+0x3c>
cmp    $0xffffffff,%eax
jne    117c <main+0x3c>
mov    0x2dfc(%rip),%r15
mov    (%r15),%eax
cmp    %ebp,%eax
jge    120d <main+0xcd>
lea    0xf23(%rip),%r14
nopw   0x0(%rax,%rax,1)
cltq
mov    (%rbx,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%eax
add    $0x1,%eax
mov    %eax,(%r15)
cmp    %ebp,%eax
jl     11f0 <main+0xb0>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c":if:lr\00"
@.str.1 = [12 x i8] c"option: %c\0A\00"
@.str.2 = [14 x i8] c"filename: %s\0A\00"
@optarg = global i8* null
@.str.3 = [22 x i8] c"option needs a value\0A\00"
@.str.4 = [20 x i8] c"unknown option: %c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.5 = [14 x i8] c"argument: %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
br label %7
7: ; preds = %25, %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 %26
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %25 [
i32 105, label %14
i32 108, label %14
i32 114, label %14
i32 102, label %17
i32 58, label %20
i32 63, label %22
]
14: ; preds = %12, %12, %12
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %25
17: ; preds = %12
%18 = load i8*, i8** @optarg
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %25
20: ; preds = %12
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %25
22: ; preds = %12
%23 = load i32, i32* @optopt
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %12, %22, %20, %17, %14
br label %7
26: ; preds = %7
br label %27
27: ; preds = %38, %26
%28 = load i32, i32* @optind
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = load i8**, i8*** %5
%33 = load i32, i32* @optind
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %31
%39 = load i32, i32* @optind
%40 = add nsw i32 %39, 1
store i32 %40, i32* @optind
br label %27
41: ; preds = %27
%42 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c":if:lr\00"
@.str.1 = [12 x i8] c"option: %c\0A\00"
@.str.2 = [14 x i8] c"filename: %s\0A\00"
@optarg = global i8* null
@.str.4 = [20 x i8] c"unknown option: %c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.5 = [14 x i8] c"argument: %s\0A\00"
@str = [21 x i8] c"option needs a value\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 ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %5 [
i32 -1, label %6
i32 105, label %9
i32 108, label %9
i32 114, label %9
i32 102, label %11
i32 58, label %14
i32 63, label %16
]
5: ; preds = %3, %16, %14, %11, %9
br label %3
6: ; preds = %3
%7 = load i32, i32* @optind
%8 = icmp slt i32 %7, %0
br i1 %8, label %19, label %28
9: ; preds = %3, %3, %3
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %5
11: ; preds = %3
%12 = load i8*, i8** @optarg
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %5
14: ; preds = %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %5
16: ; preds = %3
%17 = load i32, i32* @optopt
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %5
19: ; preds = %6, %19
%20 = phi i32 [ %26, %19 ], [ %7, %6 ]
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @optind
%26 = add nsw i32 %25, 1
store i32 %26, i32* @optind
%27 = icmp slt i32 %26, %0
br i1 %27, label %19, label %28
28: ; preds = %19, %6
%29 = tail call i32 @exit(i32 0)
unreachable
}