#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 */
char getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char option_symb = 0;
  while ((option_symb = getopt(argc, argv, "ab:c")) != -1) {
    switch (option_symb) {
    case 'a':
      printf("-a is set\n");
      break;
    case 'b':
      printf("-b is set with arg = %s\n", optarg);
      break;
    case 'c':
      printf("-c is set\n");
      break;
    case '?':
    default:
      printf("Unknown option.\n");
      break;
    }
  }
  return 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)
movb   $0x0,-0x11(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf4c(%rip),%rdx
call   1040 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     11e1 <main+0xc1>
movsbl -0x11(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x24,%eax
ja     11ce <main+0xae>
mov    -0x20(%rbp),%rax
lea    0xe83(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xbc>
mov    0x2e58(%rip),%rax
mov    (%rax),%rsi
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xbc>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xbc>
jmp    11ce <main+0xae>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113a <main+0x1a>
xor    %eax,%eax
add    $0x20,%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),%rdx
call   1050 <getopt@plt>
cmp    $0xff,%al
je     11c9 <main+0x99>
lea    0xea9(%rip),%r15
lea    0xea7(%rip),%r12
lea    0xec3(%rip),%r13
lea    0xec6(%rip),%r14
jmp    1189 <main+0x59>
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0xff,%al
je     11c9 <main+0x99>
movsbl %al,%eax
cmp    $0x63,%eax
je     11c0 <main+0x90>
cmp    $0x62,%eax
je     11a0 <main+0x70>
cmp    $0x61,%eax
jne    1170 <main+0x40>
mov    %r13,%rdi
jmp    1173 <main+0x43>
mov    0x2e51(%rip),%rax
mov    (%rax),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1178 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
lea    0xe57(%rip),%rdi
jmp    1173 <main+0x43>
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"ab:c\00"
@.str.1 = [11 x i8] c"-a is set\0A\00"
@.str.2 = [25 x i8] c"-b is set with arg = %s\0A\00"
@optarg = global i8* null
@.str.3 = [11 x i8] c"-c is set\0A\00"
@.str.4 = [17 x i8] c"Unknown option.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %6
br label %7
7: ; preds = %26, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call signext i8 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8 %10, i8* %6
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %27
13: ; preds = %7
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
switch i32 %15, label %24 [
i32 97, label %16
i32 98, label %18
i32 99, label %21
i32 63, label %23
]
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %26
18: ; preds = %13
%19 = load i8*, i8** @optarg
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %26
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %26
23: ; preds = %13
br label %24
24: ; preds = %13, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %21, %18, %16
br label %7
27: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"ab:c\00"
@.str.2 = [25 x i8] c"-b is set with arg = %s\0A\00"
@optarg = global i8* null
@str = [10 x i8] c"-c is set\00"
@str.5 = [10 x i8] c"-a is set\00"
@str.6 = [16 x i8] c"Unknown option.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8 %3, -1
br i1 %4, label %20, label %5
5: ; preds = %2, %17
%6 = phi i8 [ %18, %17 ], [ %3, %2 ]
%7 = sext i8 %6 to i32
switch i32 %7, label %15 [
i32 97, label %8
i32 98, label %10
i32 99, label %13
]
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
br label %17
10: ; preds = %5
%11 = load i8*, i8** @optarg
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %17
13: ; preds = %5
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %17
15: ; preds = %5
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %10, %8
%18 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i8 %18, -1
br i1 %19, label %20, label %5
20: ; preds = %17, %2
ret i32 0
}