#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ const member_1;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int getopt_long(int, char **, char *, struct option const *,
                int /*<<< orphan*/ *);
#define no_argument 130
char *optarg;
int optind;
#define optional_argument 129
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
#define required_argument 128
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  static const struct option options[] = {
      {"required", required_argument, NULL, 'r'},
      {"optional", optional_argument, NULL, 'o'},
      {"none", no_argument, NULL, 'n'},
      {"color", no_argument, NULL, 'C'},
      {"colour", no_argument, NULL, 'C'},
      {NULL, 0, NULL, 0}};
  int aflag = 0;
  int bflag = 0;
  char *cvalue = NULL;
  int Cflag = 0;
  int nflag = 0;
  int idx;
  int c;
  int result = 0;
  while ((c = getopt_long(argc, argv, "abc:", options, NULL)) >= 0)
    switch (c) {
    case 'a':
      aflag = 1;
      break;
    case 'b':
      bflag = 1;
      break;
    case 'c':
      cvalue = optarg;
      break;
    case 'C':
      ++Cflag;
      break;
    case '?':
      fputs("Unknown option.\n", stderr);
      return 1;
    default:
      fprintf(stderr, "This should never happen!\n");
      return 1;
    case 'r':
      printf("--required %s\n", optarg);
      result |= strcmp(optarg, "foobar") != 0;
      break;
    case 'o':
      printf("--optional %s\n", optarg);
      result |= optarg == NULL || strcmp(optarg, "bazbug") != 0;
      break;
    case 'n':
      puts("--none");
      nflag = 1;
      break;
    }
  printf("aflag = %d, bflag = %d, cvalue = %s, Cflags = %d, nflag = %d\n",
         aflag, bflag, cvalue, Cflag, nflag);
  result |= (aflag != 1 || bflag != 1 || cvalue == NULL ||
             strcmp(cvalue, "foobar") != 0 || Cflag != 3 || nflag != 1);
  for (idx = optind; idx < argc; idx++)
    printf("Non-option argument %s\n", argv[idx]);
  result |= optind + 1 != argc || strcmp(argv[optind], "random") != 0;
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf40(%rip),%rdx
lea    0x2b8a(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jl     132e <main+0x1ce>
mov    -0x30(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x33,%eax
ja     124f <main+0xef>
mov    -0x40(%rbp),%rax
lea    0xe14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x14(%rbp)
jmp    1329 <main+0x1c9>
movl   $0x1,-0x18(%rbp)
jmp    1329 <main+0x1c9>
mov    0x2ddc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1329 <main+0x1c9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1329 <main+0x1c9>
mov    0x2d93(%rip),%rax
mov    (%rax),%esi
lea    0xeb6(%rip),%rdi
call   1060 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2fb>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2fb>
mov    0x2d79(%rip),%rax
mov    (%rax),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%rdi
lea    0xe96(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1329 <main+0x1c9>
mov    0x2d34(%rip),%rax
mov    (%rax),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%al
mov    0x2d1a(%rip),%rcx
cmpq   $0x0,(%rcx)
mov    %al,-0x41(%rbp)
je     1303 <main+0x1a3>
mov    0x2d06(%rip),%rax
mov    (%rax),%rdi
lea    0xe51(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1329 <main+0x1c9>
lea    0xe2f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x28(%rbp)
jmp    11a1 <main+0x41>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x14(%rbp)
mov    %al,-0x42(%rbp)
jne    13b7 <main+0x257>
mov    $0x1,%al
cmpl   $0x1,-0x18(%rbp)
mov    %al,-0x42(%rbp)
jne    13b7 <main+0x257>
mov    $0x1,%al
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x42(%rbp)
je     13b7 <main+0x257>
mov    -0x20(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x42(%rbp)
jne    13b7 <main+0x257>
mov    $0x1,%al
cmpl   $0x3,-0x24(%rbp)
mov    %al,-0x42(%rbp)
jne    13b7 <main+0x257>
cmpl   $0x1,-0x28(%rbp)
setne  %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2c0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1405 <main+0x2a5>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    13d1 <main+0x271>
mov    0x2bcc(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    $0x1,%al
cmp    -0x8(%rbp),%ecx
mov    %al,-0x43(%rbp)
jne    1447 <main+0x2e7>
mov    -0x10(%rbp),%rax
mov    0x2bae(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd71(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x43(%rbp)
mov    -0x43(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,%r13d
lea    0xf74(%rip),%rdx
lea    0x2bbe(%rip),%rcx
xor    %r12d,%r12d
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
movl   $0x0,0x8(%rsp)
mov    $0x0,%ecx
mov    %rcx,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
test   %eax,%eax
js     1302 <main+0x1a2>
lea    0xe3b(%rip),%rbx
lea    0x2b74(%rip),%rbp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
movl   $0x0,0xc(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x10(%rsp)
movl   $0x0,0x8(%rsp)
xor    %r14d,%r14d
jmp    1236 <main+0xd6>
lea    0xf4e(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %r14d,%r12d
mov    %r13d,%edi
mov    %r15,%rsi
lea    0xecf(%rip),%rdx
mov    %rbp,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
mov    %r12d,%r14d
test   %eax,%eax
js     1302 <main+0x1a2>
add    $0xffffffc1,%eax
cmp    $0x33,%eax
ja     1422 <main+0x2c2>
mov    $0x1,%r12d
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
addl   $0x1,0xc(%rsp)
jmp    1210 <main+0xb0>
movl   $0x1,0x8(%rsp)
jmp    1210 <main+0xb0>
mov    0x2d87(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
jmp    1210 <main+0xb0>
mov    0x2d76(%rip),%rbp
mov    0x0(%rbp),%rsi
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%rdi
test   %rdi,%rdi
je     12ea <main+0x18a>
lea    0xea9(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
setne  %al
jmp    12ec <main+0x18c>
mov    0x2d40(%rip),%rbp
mov    0x0(%rbp),%rsi
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%rdi
lea    0x2a73(%rip),%rbp
lea    0xe5b(%rip),%rsi
call   1070 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
or     %ecx,0x4(%rsp)
jmp    1210 <main+0xb0>
mov    $0x1,%al
movzbl %al,%eax
or     %eax,0x4(%rsp)
mov    %r14d,%r12d
lea    0x2a43(%rip),%rbp
jmp    1213 <main+0xb3>
lea    0xe4a(%rip),%rdi
mov    %r12d,%esi
mov    0x8(%rsp),%r14d
mov    %r14d,%edx
mov    0x10(%rsp),%rbx
mov    %rbx,%rcx
mov    0xc(%rsp),%ebp
mov    %ebp,%r8d
mov    (%rsp),%r9d
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%esi
cmp    $0x1,%r12d
jne    1373 <main+0x213>
cmp    $0x1,%r14d
jne    1373 <main+0x213>
test   %rbx,%rbx
je     1373 <main+0x213>
lea    0xde4(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    136e <main+0x20e>
cmp    $0x3,%ebp
mov    $0x1,%esi
jne    1373 <main+0x213>
xor    %esi,%esi
cmpl   $0x1,(%rsp)
setne  %sil
jmp    1373 <main+0x213>
mov    $0x1,%esi
mov    0x2c5e(%rip),%rax
mov    (%rax),%eax
cmp    %r13d,%eax
jge    13c4 <main+0x264>
mov    %esi,(%rsp)
movslq %eax,%rcx
lea    (%r15,%rcx,8),%rbp
mov    %r13d,%r12d
sub    %eax,%r12d
lea    0xdf9(%rip),%rbx
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,8),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14
cmp    %r14d,%r12d
jne    13a0 <main+0x240>
mov    0x2c19(%rip),%rax
mov    (%rax),%eax
mov    (%rsp),%esi
or     0x4(%rsp),%esi
lea    0x1(%rax),%edx
mov    $0x1,%ecx
cmp    %r13d,%edx
jne    13f3 <main+0x293>
cltq
mov    (%r15,%rax,8),%rdi
mov    %esi,%ebx
lea    0xdc5(%rip),%rsi
call   1070 <strcmp@plt>
mov    %ebx,%esi
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
or     %ecx,%esi
mov    %esi,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bbb(%rip),%rax
mov    (%rax),%esi
lea    0xcde(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x1,%esi
jmp    13f5 <main+0x295>
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
lea    0xcd3(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%esi
jmp    13f5 <main+0x295>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@main.options = internal constant [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 114 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32* null, i32 111 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -126, i32* null, i32 110 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8 -126, i32* null, i32 67 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -126, i32* null, i32 67 }, %struct.option zeroinitializer]
@.str = [9 x i8] c"required\00"
@.str.1 = [9 x i8] c"optional\00"
@.str.2 = [5 x i8] c"none\00"
@.str.3 = [6 x i8] c"color\00"
@.str.4 = [7 x i8] c"colour\00"
@.str.5 = [5 x i8] c"abc:\00"
@optarg = global i8* null
@.str.6 = [17 x i8] c"Unknown option.\0A\00"
@stderr = global i32 0
@.str.7 = [27 x i8] c"This should never happen!\0A\00"
@.str.8 = [15 x i8] c"--required %s\0A\00"
@.str.9 = [7 x i8] c"foobar\00"
@.str.10 = [15 x i8] c"--optional %s\0A\00"
@.str.11 = [7 x i8] c"bazbug\00"
@.str.12 = [7 x i8] c"--none\00"
@.str.13 = [62 x i8] c"aflag = %d, bflag = %d, cvalue = %s, Cflags = %d, nflag = %d\0A\00"
@optind = global i32 0
@.str.14 = [24 x i8] c"Non-option argument %s\0A\00"
@.str.15 = [7 x i8] c"random\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
%11 = alloca i32
%12 = alloca i32
%13 = 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 i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %13
br label %14
14: ; preds = %59, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt_long(i32 %15, i8** %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
store i32 %17, i32* %12
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %60
19: ; preds = %14
%20 = load i32, i32* %12
switch i32 %20, label %31 [
i32 97, label %21
i32 98, label %22
i32 99, label %23
i32 67, label %25
i32 63, label %28
i32 114, label %34
i32 111, label %43
i32 110, label %57
]
21: ; preds = %19
store i32 1, i32* %6
br label %59
22: ; preds = %19
store i32 1, i32* %7
br label %59
23: ; preds = %19
%24 = load i8*, i8** @optarg
store i8* %24, i8** %8
br label %59
25: ; preds = %19
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %59
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %29)
store i32 1, i32* %3
br label %124
31: ; preds = %19
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %124
34: ; preds = %19
%35 = load i8*, i8** @optarg
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** @optarg
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
%40 = zext i1 %39 to i32
%41 = load i32, i32* %13
%42 = or i32 %41, %40
store i32 %42, i32* %13
br label %59
43: ; preds = %19
%44 = load i8*, i8** @optarg
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** @optarg
%47 = icmp eq i8* %46, null
br i1 %47, label %52, label %48
48: ; preds = %43
%49 = load i8*, i8** @optarg
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br label %52
52: ; preds = %48, %43
%53 = phi i1 [ true, %43 ], [ %51, %48 ]
%54 = zext i1 %53 to i32
%55 = load i32, i32* %13
%56 = or i32 %55, %54
store i32 %56, i32* %13
br label %59
57: ; preds = %19
%58 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %10
br label %59
59: ; preds = %57, %52, %34, %25, %23, %22, %21
br label %14
60: ; preds = %14
%61 = load i32, i32* %6
%62 = load i32, i32* %7
%63 = load i8*, i8** %8
%64 = load i32, i32* %9
%65 = load i32, i32* %10
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.13, i64 0, i64 0), i32 %61, i32 %62, i8* %63, i32 %64, i32 %65)
%67 = load i32, i32* %6
%68 = icmp ne i32 %67, 1
br i1 %68, label %85, label %69
69: ; preds = %60
%70 = load i32, i32* %7
%71 = icmp ne i32 %70, 1
br i1 %71, label %85, label %72
72: ; preds = %69
%73 = load i8*, i8** %8
%74 = icmp eq i8* %73, null
br i1 %74, label %85, label %75
75: ; preds = %72
%76 = load i8*, i8** %8
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%78 = icmp ne i64 %77, 0
br i1 %78, label %85, label %79
79: ; preds = %75
%80 = load i32, i32* %9
%81 = icmp ne i32 %80, 3
br i1 %81, label %85, label %82
82: ; preds = %79
%83 = load i32, i32* %10
%84 = icmp ne i32 %83, 1
br label %85
85: ; preds = %82, %79, %75, %72, %69, %60
%86 = phi i1 [ true, %79 ], [ true, %75 ], [ true, %72 ], [ true, %69 ], [ true, %60 ], [ %84, %82 ]
%87 = zext i1 %86 to i32
%88 = load i32, i32* %13
%89 = or i32 %88, %87
store i32 %89, i32* %13
%90 = load i32, i32* @optind
store i32 %90, i32* %11
br label %91
91: ; preds = %102, %85
%92 = load i32, i32* %11
%93 = load i32, i32* %4
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %105
95: ; preds = %91
%96 = load i8**, i8*** %5
%97 = load i32, i32* %11
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8*, i8** %96, i64 %98
%100 = load i8*, i8** %99
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8* %100)
br label %102
102: ; preds = %95
%103 = load i32, i32* %11
%104 = add nsw i32 %103, 1
store i32 %104, i32* %11
br label %91
105: ; preds = %91
%106 = load i32, i32* @optind
%107 = add nsw i32 %106, 1
%108 = load i32, i32* %4
%109 = icmp ne i32 %107, %108
br i1 %109, label %118, label %110
110: ; preds = %105
%111 = load i8**, i8*** %5
%112 = load i32, i32* @optind
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8*, i8** %111, i64 %113
%115 = load i8*, i8** %114
%116 = call i64 @strcmp(i8* %115, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%117 = icmp ne i64 %116, 0
br label %118
118: ; preds = %110, %105
%119 = phi i1 [ true, %105 ], [ %117, %110 ]
%120 = zext i1 %119 to i32
%121 = load i32, i32* %13
%122 = or i32 %121, %120
store i32 %122, i32* %13
%123 = load i32, i32* %13
store i32 %123, i32* %3
br label %124
124: ; preds = %118, %31, %28
%125 = load i32, i32* %3
ret i32 %125
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@main.options = internal constant [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 114 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32* null, i32 111 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -126, i32* null, i32 110 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8 -126, i32* null, i32 67 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -126, i32* null, i32 67 }, %struct.option zeroinitializer]
@.str = [9 x i8] c"required\00"
@.str.1 = [9 x i8] c"optional\00"
@.str.2 = [5 x i8] c"none\00"
@.str.3 = [6 x i8] c"color\00"
@.str.4 = [7 x i8] c"colour\00"
@.str.5 = [5 x i8] c"abc:\00"
@optarg = global i8* null
@.str.6 = [17 x i8] c"Unknown option.\0A\00"
@stderr = global i32 0
@.str.7 = [27 x i8] c"This should never happen!\0A\00"
@.str.8 = [15 x i8] c"--required %s\0A\00"
@.str.9 = [7 x i8] c"foobar\00"
@.str.10 = [15 x i8] c"--optional %s\0A\00"
@.str.11 = [7 x i8] c"bazbug\00"
@.str.12 = [7 x i8] c"--none\00"
@.str.13 = [62 x i8] c"aflag = %d, bflag = %d, cvalue = %s, Cflags = %d, nflag = %d\0A\00"
@optind = global i32 0
@.str.14 = [24 x i8] c"Non-option argument %s\0A\00"
@.str.15 = [7 x i8] c"random\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %55
5: ; preds = %2, %46
%6 = phi i32 [ %53, %46 ], [ %3, %2 ]
%7 = phi i32 [ %52, %46 ], [ 0, %2 ]
%8 = phi i32 [ %51, %46 ], [ 0, %2 ]
%9 = phi i32 [ %50, %46 ], [ 0, %2 ]
%10 = phi i8* [ %49, %46 ], [ null, %2 ]
%11 = phi i32 [ %48, %46 ], [ 0, %2 ]
%12 = phi i32 [ %47, %46 ], [ 0, %2 ]
switch i32 %6, label %21 [
i32 97, label %46
i32 98, label %13
i32 99, label %14
i32 67, label %16
i32 63, label %18
i32 114, label %24
i32 111, label %32
i32 110, label %44
]
13: ; preds = %5
br label %46
14: ; preds = %5
%15 = load i8*, i8** @optarg
br label %46
16: ; preds = %5
%17 = add nsw i32 %9, 1
br label %46
18: ; preds = %5
%19 = load i32, i32* @stderr
%20 = tail call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %19)
br label %107
21: ; preds = %5
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %107
24: ; preds = %5
%25 = load i8*, i8** @optarg
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** @optarg
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
%30 = zext i1 %29 to i32
%31 = or i32 %7, %30
br label %46
32: ; preds = %5
%33 = load i8*, i8** @optarg
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** @optarg
%36 = icmp eq i8* %35, null
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = tail call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br label %40
40: ; preds = %37, %32
%41 = phi i1 [ true, %32 ], [ %39, %37 ]
%42 = zext i1 %41 to i32
%43 = or i32 %7, %42
br label %46
44: ; preds = %5
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %46
46: ; preds = %5, %44, %40, %24, %16, %14, %13
%47 = phi i32 [ %12, %44 ], [ %12, %40 ], [ %12, %24 ], [ %12, %16 ], [ %12, %14 ], [ %12, %13 ], [ 1, %5 ]
%48 = phi i32 [ %11, %44 ], [ %11, %40 ], [ %11, %24 ], [ %11, %16 ], [ %11, %14 ], [ 1, %13 ], [ %11, %5 ]
%49 = phi i8* [ %10, %44 ], [ %10, %40 ], [ %10, %24 ], [ %10, %16 ], [ %15, %14 ], [ %10, %13 ], [ %10, %5 ]
%50 = phi i32 [ %9, %44 ], [ %9, %40 ], [ %9, %24 ], [ %17, %16 ], [ %9, %14 ], [ %9, %13 ], [ %9, %5 ]
%51 = phi i32 [ 1, %44 ], [ %8, %40 ], [ %8, %24 ], [ %8, %16 ], [ %8, %14 ], [ %8, %13 ], [ %8, %5 ]
%52 = phi i32 [ %7, %44 ], [ %43, %40 ], [ %31, %24 ], [ %7, %16 ], [ %7, %14 ], [ %7, %13 ], [ %7, %5 ]
%53 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
%54 = icmp sgt i32 %53, -1
br i1 %54, label %5, label %55
55: ; preds = %46, %2
%56 = phi i32 [ 0, %2 ], [ %47, %46 ]
%57 = phi i32 [ 0, %2 ], [ %48, %46 ]
%58 = phi i8* [ null, %2 ], [ %49, %46 ]
%59 = phi i32 [ 0, %2 ], [ %50, %46 ]
%60 = phi i32 [ 0, %2 ], [ %51, %46 ]
%61 = phi i32 [ 0, %2 ], [ %52, %46 ]
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.13, i64 0, i64 0), i32 %56, i32 %57, i8* %58, i32 %59, i32 %60)
%63 = icmp ne i32 %56, 1
%64 = icmp ne i32 %57, 1
%65 = or i1 %63, %64
%66 = icmp eq i8* %58, null
%67 = or i1 %65, %66
br i1 %67, label %76, label %68
68: ; preds = %55
%69 = tail call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%70 = icmp ne i64 %69, 0
%71 = icmp ne i32 %59, 3
%72 = or i1 %70, %71
br i1 %72, label %76, label %73
73: ; preds = %68
%74 = icmp ne i32 %60, 1
%75 = zext i1 %74 to i32
br label %76
76: ; preds = %73, %68, %55
%77 = phi i32 [ 1, %68 ], [ 1, %55 ], [ %75, %73 ]
%78 = or i32 %77, %61
%79 = load i32, i32* @optind
%80 = icmp slt i32 %79, %0
br i1 %80, label %81, label %93
81: ; preds = %76
%82 = sext i32 %79 to i64
br label %83
83: ; preds = %81, %83
%84 = phi i64 [ %82, %81 ], [ %88, %83 ]
%85 = getelementptr inbounds i8*, i8** %1, i64 %84
%86 = load i8*, i8** %85
%87 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8* %86)
%88 = add nsw i64 %84, 1
%89 = trunc i64 %88 to i32
%90 = icmp eq i32 %89, %0
br i1 %90, label %91, label %83
91: ; preds = %83
%92 = load i32, i32* @optind
br label %93
93: ; preds = %91, %76
%94 = phi i32 [ %92, %91 ], [ %79, %76 ]
%95 = add nsw i32 %94, 1
%96 = icmp eq i32 %95, %0
br i1 %96, label %97, label %104
97: ; preds = %93
%98 = sext i32 %94 to i64
%99 = getelementptr inbounds i8*, i8** %1, i64 %98
%100 = load i8*, i8** %99
%101 = tail call i64 @strcmp(i8* %100, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%102 = icmp ne i64 %101, 0
%103 = zext i1 %102 to i32
br label %104
104: ; preds = %97, %93
%105 = phi i32 [ 1, %93 ], [ %103, %97 ]
%106 = or i32 %78, %105
br label %107
107: ; preds = %104, %21, %18
%108 = phi i32 [ 1, %21 ], [ 1, %18 ], [ %106, %104 ]
ret i32 %108
}