#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 /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int opt;
  while ((opt = getopt(argc, argv, "ab:c:d")) != -1) {
    switch (opt) {
    case 'a':
      printf("a\n");
      break;
    case 'b':
      printf("b:%s\n", optarg);
      break;
    case 'c':
      printf("c:%s\n", optarg);
      break;
    case 'd':
      printf("d\n");
      break;
      break;
    default:
      printf("%s [-a] [-b b] [-c c] [-d]\n", argv[0]);
      return -1;
    }
  }
  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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xecc(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1204 <main+0xe4>
mov    -0x14(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11de <main+0xbe>
mov    -0x20(%rbp),%rax
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ff <main+0xdf>
mov    0x2e60(%rip),%rax
mov    (%rax),%rsi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ff <main+0xdf>
mov    0x2e43(%rip),%rax
mov    (%rax),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ff <main+0xdf>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ff <main+0xdf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120b <main+0xeb>
jmp    1136 <main+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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    0xec9(%rip),%r14
lea    0xeb2(%rip),%r12
mov    0x2ea3(%rip),%r13
lea    0xeb9(%rip),%r15
jmp    1168 <main+0x38>
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
lea    -0x61(%rax),%ecx
cmp    $0x3,%ecx
ja     11c4 <main+0x94>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
jmp    1168 <main+0x38>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13),%rsi
lea    0xe6c(%rip),%rdi
jmp    11bb <main+0x8b>
nopl   (%rax)
mov    0x0(%r13),%rsi
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1168 <main+0x38>
cmp    $0xffffffff,%eax
jne    11cd <main+0x9d>
xor    %eax,%eax
jmp    11e3 <main+0xb3>
mov    (%rbx),%rsi
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"ab:c:d\00"
@.str.1 = [3 x i8] c"a\0A\00"
@.str.2 = [6 x i8] c"b:%s\0A\00"
@optarg = global i8* null
@.str.3 = [6 x i8] c"c:%s\0A\00"
@.str.4 = [3 x i8] c"d\0A\00"
@.str.5 = [28 x i8] c"%s [-a] [-b b] [-c c] [-d]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
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 ([7 x i8], [7 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 %24 [
i32 97, label %14
i32 98, label %16
i32 99, label %19
i32 100, label %22
]
14: ; preds = %12
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %29
16: ; preds = %12
%17 = load i8*, i8** @optarg
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %29
19: ; preds = %12
%20 = load i8*, i8** @optarg
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %29
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %29
24: ; preds = %12
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %27)
store i32 -1, i32* %3
br label %31
29: ; preds = %22, %19, %16, %14
br label %7
30: ; preds = %7
store i32 0, i32* %3
br label %31
31: ; preds = %30, %24
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [7 x i8] c"ab:c:d\00"
@.str.2 = [6 x i8] c"b:%s\0A\00"
@optarg = global i8* null
@.str.3 = [6 x i8] c"c:%s\0A\00"
@.str.5 = [28 x i8] c"%s [-a] [-b b] [-c c] [-d]\0A\00"
@str = [2 x i8] c"d\00"
@str.6 = [2 x i8] c"a\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 ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %16 [
i32 -1, label %19
i32 97, label %5
i32 98, label %7
i32 99, label %10
i32 100, label %13
]
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
br label %15
7: ; preds = %3
%8 = load i8*, i8** @optarg
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %15
10: ; preds = %3
%11 = load i8*, i8** @optarg
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %15
13: ; preds = %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10, %7, %5
br label %3
16: ; preds = %3
%17 = load i8*, i8** %1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %3, %16
%20 = phi i32 [ -1, %16 ], [ 0, %3 ]
ret i32 %20
}