#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;
scalar_t__ opterr;
int /*<<< orphan*/ printf(char *, ...);
int parse_opt(int argc, char **argv) {
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "a:b:c")) != -1) {
    switch (c) {
    case 'a':
      printf("option=>%c arg=>%s\n", c, optarg);
      break;
    case 'b':
      printf("option=>%c arg=>%s\n", c, optarg);
      break;
    case 'c':
      printf("option=>%c arg=>%s\n", c, optarg);
      break;
    default:
      printf("what! [%s]\n", optarg);
    }
  }
}


x86 assembly (clang, -O0):
<parse_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea2(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xeb5(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     120f <parse_opt+0xef>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x61,%eax
je     1192 <parse_opt+0x72>
jmp    1170 <parse_opt+0x50>
mov    -0x18(%rbp),%eax
sub    $0x62,%eax
je     11b2 <parse_opt+0x92>
jmp    1181 <parse_opt+0x61>
mov    -0x18(%rbp),%eax
sub    $0x63,%eax
je     11d2 <parse_opt+0xb2>
jmp    11f2 <parse_opt+0xd2>
mov    -0x14(%rbp),%esi
mov    0x2e5c(%rip),%rax
mov    (%rax),%rdx
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <parse_opt+0xea>
mov    -0x14(%rbp),%esi
mov    0x2e3c(%rip),%rax
mov    (%rax),%rdx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <parse_opt+0xea>
mov    -0x14(%rbp),%esi
mov    0x2e1c(%rip),%rax
mov    (%rax),%rdx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <parse_opt+0xea>
mov    0x2dff(%rip),%rax
mov    (%rax),%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113d <parse_opt+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2ea1(%rip),%rax
movq   $0x0,(%rax)
lea    0xebb(%rip),%r14
mov    0x2eac(%rip),%r13
lea    0xeb3(%rip),%r15
lea    0xec0(%rip),%r12
jmp    1173 <parse_opt+0x53>
nopl   0x0(%rax)
mov    0x0(%r13),%rdx
mov    %r15,%rdi
mov    $0x62,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
cmp    $0x61,%eax
jle    11a0 <parse_opt+0x80>
cmp    $0x62,%eax
je     1160 <parse_opt+0x40>
cmp    $0x63,%eax
jne    11b5 <parse_opt+0x95>
mov    0x0(%r13),%rdx
mov    %r15,%rdi
mov    $0x63,%esi
jmp    116c <parse_opt+0x4c>
nopl   (%rax)
jne    11b0 <parse_opt+0x90>
mov    0x0(%r13),%rdx
mov    %r15,%rdi
mov    $0x61,%esi
jmp    116c <parse_opt+0x4c>
cmp    $0xffffffff,%eax
je     11c5 <parse_opt+0xa5>
mov    0x0(%r13),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1173 <parse_opt+0x53>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [6 x i8] c"a:b:c\00"
@.str.1 = [20 x i8] c"option=>%c arg=>%s\0A\00"
@optarg = global i8* null
@.str.2 = [12 x i8] c"what! [%s]\0A\00"
define i32 @parse_opt(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* @opterr
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %30
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %26 [
i32 97, label %14
i32 98, label %18
i32 99, label %22
]
14: ; preds = %12
%15 = load i32, i32* %6
%16 = load i8*, i8** @optarg
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %16)
br label %29
18: ; preds = %12
%19 = load i32, i32* %6
%20 = load i8*, i8** @optarg
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %20)
br label %29
22: ; preds = %12
%23 = load i32, i32* %6
%24 = load i8*, i8** @optarg
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %24)
br label %29
26: ; preds = %12
%27 = load i8*, i8** @optarg
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %22, %18, %14
br label %7
30: ; preds = %7
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [6 x i8] c"a:b:c\00"
@.str.1 = [20 x i8] c"option=>%c arg=>%s\0A\00"
@optarg = global i8* null
@.str.2 = [12 x i8] c"what! [%s]\0A\00"
define i32 @parse_opt(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %17, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %14 [
i32 -1, label %18
i32 97, label %5
i32 98, label %8
i32 99, label %11
]
5: ; preds = %3
%6 = load i8*, i8** @optarg
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 97, i8* %6)
br label %17
8: ; preds = %3
%9 = load i8*, i8** @optarg
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 98, i8* %9)
br label %17
11: ; preds = %3
%12 = load i8*, i8** @optarg
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 99, i8* %12)
br label %17
14: ; preds = %3
%15 = load i8*, i8** @optarg
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %11, %8, %5
br label %3
18: ; preds = %3
ret i32 undef
}