#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*/ fprintf(int /*<<< orphan*/, char *, int);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int oc;
  char *b_opt_arg;
  while ((oc = getopt(argc, argv, "ab:")) != -1) {
    switch (oc) {
    case 'a':
      printf("options 'a' has been processed\n");
      break;
    case 'b':
      printf("options 'b' has been processed\n");
      b_opt_arg = optarg;
      break;
    case ':':
      fprintf(stderr, "Invalide option %c", oc);
      break;
    case '?':
    default:
      fprintf(stderr, "invalide option %c", oc);
      break;
    }
  }
  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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     121b <main+0xeb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3a,%eax
je     11dc <main+0xac>
jmp    1179 <main+0x49>
mov    -0x24(%rbp),%eax
sub    $0x3f,%eax
je     11f9 <main+0xc9>
jmp    118a <main+0x5a>
mov    -0x24(%rbp),%eax
sub    $0x61,%eax
je     11ac <main+0x7c>
jmp    119b <main+0x6b>
mov    -0x24(%rbp),%eax
sub    $0x62,%eax
je     11bd <main+0x8d>
jmp    11fe <main+0xce>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
jmp    1216 <main+0xe6>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1216 <main+0xe6>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe55(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1216 <main+0xe6>
jmp    11fe <main+0xce>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe46(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1146 <main+0x16>
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    0xeb9(%rip),%r14
mov    0x2e92(%rip),%r12
lea    0xed5(%rip),%r13
lea    0xeed(%rip),%r15
jmp    1168 <main+0x38>
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
cmp    $0x60,%eax
jle    1190 <main+0x60>
cmp    $0x62,%eax
je     1160 <main+0x30>
cmp    $0x61,%eax
jne    11b1 <main+0x81>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1168 <main+0x38>
xchg   %ax,%ax
cmp    $0x3a,%eax
jne    11ac <main+0x7c>
mov    (%r12),%edi
lea    0xe64(%rip),%rsi
mov    $0x3a,%edx
call   1040 <fprintf@plt>
jmp    1168 <main+0x38>
cmp    $0xffffffff,%eax
je     11c5 <main+0x95>
mov    (%r12),%edi
lea    0xe5b(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
jmp    1168 <main+0x38>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ab:\00"
@.str.1 = [32 x i8] c"options 'a' has been processed\0A\00"
@.str.2 = [32 x i8] c"options 'b' has been processed\0A\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.3 = [19 x i8] c"Invalide option %c\00"
@.str.4 = [19 x i8] c"invalide option %c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %30
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %25 [
i32 97, label %15
i32 98, label %17
i32 58, label %20
i32 63, label %24
]
15: ; preds = %13
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %29
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8*, i8** @optarg
store i8* %19, i8** %7
br label %29
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = load i32, i32* %6
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %29
24: ; preds = %13
br label %25
25: ; preds = %13, %24
%26 = load i32, i32* @stderr
%27 = load i32, i32* %6
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %20, %17, %15
br label %8
30: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"ab:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.3 = [19 x i8] c"Invalide option %c\00"
@.str.4 = [19 x i8] c"invalide option %c\00"
@str = [31 x i8] c"options 'b' has been processed\00"
@str.5 = [31 x i8] c"options 'a' has been processed\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %15, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %12 [
i32 -1, label %16
i32 97, label %5
i32 98, label %7
i32 58, label %9
]
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
br label %15
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %15
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 58)
br label %15
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %4)
br label %15
15: ; preds = %12, %9, %7, %5
br label %3
16: ; preds = %3
ret i32 0
}