#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 getopt(int, char **, char *);
char *optarg;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  int ch, aflag = 0, bflag = 0, lflag = 0;
  int i;
  while ((ch = getopt(argc, argv, "lab:")) != -1) {
    switch (ch) {
    case 'a':
      printf("option a is set\n");
      aflag = 1;
      break;
    case 'l':
      printf("option l is set\n");
      lflag = 1;
      break;
    case 'b':
      printf("option b is set");
      printf("b:%s\n", optarg);
      bflag = 1;
      break;
    default:
      printf("option %c is not set\n", optopt);
      break;
    }
  }
  for (i = 0; i < argc; i++) {
    printf("%s ", argv[i]);
  }
  puts("");
  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,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe97(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1232 <main+0x102>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x61,%eax
je     11b0 <main+0x80>
jmp    118e <main+0x5e>
mov    -0x28(%rbp),%eax
sub    $0x62,%eax
je     11e4 <main+0xb4>
jmp    119f <main+0x6f>
mov    -0x28(%rbp),%eax
sub    $0x6c,%eax
je     11ca <main+0x9a>
jmp    1216 <main+0xe6>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    122d <main+0xfd>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x20(%rbp)
jmp    122d <main+0xfd>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    122d <main+0xfd>
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115b <main+0x2b>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126d <main+0x13d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1239 <main+0x109>
lea    0xdc8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%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,%rbx
mov    %edi,%ebp
lea    0xea9(%rip),%r14
mov    0x2e9a(%rip),%r13
lea    0xeb0(%rip),%r15
lea    0xec9(%rip),%r12
jmp    118c <main+0x4c>
xchg   %ax,%ax
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
cmp    $0x61,%eax
jle    11c0 <main+0x80>
cmp    $0x62,%eax
je     1170 <main+0x30>
cmp    $0x6c,%eax
jne    11d5 <main+0x95>
mov    %r12,%rdi
call   1040 <puts@plt>
jmp    118c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
jne    11d0 <main+0x90>
lea    0xe7c(%rip),%rdi
call   1040 <puts@plt>
jmp    118c <main+0x4c>
cmp    $0xffffffff,%eax
je     11ee <main+0xae>
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    118c <main+0x4c>
test   %ebp,%ebp
jle    1217 <main+0xd7>
mov    %ebp,%r15d
lea    0xe35(%rip),%r14
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%rbx,%rbp,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1200 <main+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"lab:\00"
@.str.1 = [17 x i8] c"option a is set\0A\00"
@.str.2 = [17 x i8] c"option l is set\0A\00"
@.str.3 = [16 x i8] c"option b is set\00"
@.str.4 = [6 x i8] c"b:%s\0A\00"
@optarg = global i8* null
@.str.5 = [22 x i8] c"option %c is not set\0A\00"
@optopt = global i32 0
@.str.6 = [4 x i8] c"%s \00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%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* %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %29, %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* %6
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %30
16: ; preds = %11
%17 = load i32, i32* %6
switch i32 %17, label %26 [
i32 97, label %18
i32 108, label %20
i32 98, label %22
]
18: ; preds = %16
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %7
br label %29
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %9
br label %29
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%24 = load i8*, i8** @optarg
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %24)
store i32 1, i32* %8
br label %29
26: ; preds = %16
%27 = load i32, i32* @optopt
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %22, %20, %18
br label %11
30: ; preds = %11
store i32 0, i32* %10
br label %31
31: ; preds = %42, %30
%32 = load i32, i32* %10
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %45
35: ; preds = %31
%36 = load i8**, i8*** %5
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
br label %31
45: ; preds = %31
%46 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"lab:\00"
@.str.3 = [16 x i8] c"option b is set\00"
@.str.4 = [6 x i8] c"b:%s\0A\00"
@optarg = global i8* null
@.str.5 = [22 x i8] c"option %c is not set\0A\00"
@optopt = global i32 0
@.str.6 = [4 x i8] c"%s \00"
@str = [16 x i8] c"option l is set\00"
@str.8 = [16 x i8] c"option a is set\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %20, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %17 [
i32 -1, label %5
i32 97, label %9
i32 108, label %11
i32 98, label %13
]
5: ; preds = %3
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %28
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %21
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
br label %20
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %20
13: ; preds = %3
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%15 = load i8*, i8** @optarg
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br label %20
17: ; preds = %3
%18 = load i32, i32* @optopt
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %13, %11, %9
br label %3
21: ; preds = %7, %21
%22 = phi i64 [ 0, %7 ], [ %26, %21 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %8
br i1 %27, label %28, label %21
28: ; preds = %21, %5
%29 = tail call i32 @putchar(i32 10)
ret i32 0
}