#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 oc;
  while ((oc = getopt(argc, argv, "ABCDe:f:g:")) != -1) {
    switch (oc) {
    case 'A':
      printf("set option A\n\r");
      break;
    case 'B':
      printf("set option B\n\r");
      break;
    case 'C':
      printf("set option C\n\r");
      break;
    case 'D':
      printf("set option D\n\r");
      break;
    case 'e':
      printf("arg e option = %s\n\r", optarg);
      break;
    case 'f':
      printf("arg f option = %s\n\r", optarg);
      break;
    case 'g':
      printf("arg g option = %s\n\r", optarg);
      break;
    default:
      printf("invalid command line switch\n\r");
      return -1;
      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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf58(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1240 <main+0x120>
mov    -0x14(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x26,%eax
ja     1221 <main+0x101>
mov    -0x20(%rbp),%rax
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
lea    0xf1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
lea    0xf1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
mov    0x2e27(%rip),%rax
mov    (%rax),%rsi
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
mov    0x2e0a(%rip),%rax
mov    (%rax),%rsi
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
mov    0x2ded(%rip),%rax
mov    (%rax),%rsi
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1247 <main+0x127>
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    0xf65(%rip),%r14
lea    0xec2(%rip),%r12
mov    0x2eb3(%rip),%r13
lea    0xfbf(%rip),%r15
jmp    115c <main+0x3c>
lea    0xf52(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
lea    -0x41(%rax),%ecx
cmp    $0x26,%ecx
ja     11bf <main+0x9f>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xf35(%rip),%rdi
jmp    1155 <main+0x35>
lea    0xf3b(%rip),%rdi
jmp    1155 <main+0x35>
lea    0xf41(%rip),%rdi
jmp    1155 <main+0x35>
mov    0x0(%r13),%rsi
lea    0xf43(%rip),%rdi
jmp    11b6 <main+0x96>
mov    0x0(%r13),%rsi
lea    0xf4a(%rip),%rdi
jmp    11b6 <main+0x96>
mov    0x0(%r13),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    115c <main+0x3c>
cmp    $0xffffffff,%eax
jne    11c8 <main+0xa8>
xor    %eax,%eax
jmp    11db <main+0xbb>
lea    0xf50(%rip),%rdi
xor    %eax,%eax
call   1030 <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 = [11 x i8] c"ABCDe:f:g:\00"
@.str.1 = [15 x i8] c"set option A\0A\0D\00"
@.str.2 = [15 x i8] c"set option B\0A\0D\00"
@.str.3 = [15 x i8] c"set option C\0A\0D\00"
@.str.4 = [15 x i8] c"set option D\0A\0D\00"
@.str.5 = [20 x i8] c"arg e option = %s\0A\0D\00"
@optarg = global i8* null
@.str.6 = [20 x i8] c"arg f option = %s\0A\0D\00"
@.str.7 = [20 x i8] c"arg g option = %s\0A\0D\00"
@.str.8 = [30 x i8] c"invalid command line switch\0A\0D\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 = %33, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %34
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %31 [
i32 65, label %14
i32 66, label %16
i32 67, label %18
i32 68, label %20
i32 101, label %22
i32 102, label %25
i32 103, label %28
]
14: ; preds = %12
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %33
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %33
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %33
20: ; preds = %12
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %33
22: ; preds = %12
%23 = load i8*, i8** @optarg
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %23)
br label %33
25: ; preds = %12
%26 = load i8*, i8** @optarg
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %26)
br label %33
28: ; preds = %12
%29 = load i8*, i8** @optarg
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %29)
br label %33
31: ; preds = %12
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %35
33: ; preds = %28, %25, %22, %20, %18, %16, %14
br label %7
34: ; preds = %7
store i32 0, i32* %3
br label %35
35: ; preds = %34, %31
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [11 x i8] c"ABCDe:f:g:\00"
@.str.1 = [15 x i8] c"set option A\0A\0D\00"
@.str.2 = [15 x i8] c"set option B\0A\0D\00"
@.str.3 = [15 x i8] c"set option C\0A\0D\00"
@.str.4 = [15 x i8] c"set option D\0A\0D\00"
@.str.5 = [20 x i8] c"arg e option = %s\0A\0D\00"
@optarg = global i8* null
@.str.6 = [20 x i8] c"arg f option = %s\0A\0D\00"
@.str.7 = [20 x i8] c"arg g option = %s\0A\0D\00"
@.str.8 = [30 x i8] c"invalid command line switch\0A\0D\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %22, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %23 [
i32 -1, label %25
i32 65, label %5
i32 66, label %7
i32 67, label %9
i32 68, label %11
i32 101, label %13
i32 102, label %16
i32 103, label %19
]
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %22
7: ; preds = %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %22
9: ; preds = %3
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %22
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %22
13: ; preds = %3
%14 = load i8*, i8** @optarg
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %14)
br label %22
16: ; preds = %3
%17 = load i8*, i8** @optarg
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %17)
br label %22
19: ; preds = %3
%20 = load i8*, i8** @optarg
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %16, %13, %11, %9, %7, %5
br label %3
23: ; preds = %3
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %25
25: ; preds = %3, %23
%26 = phi i32 [ -1, %23 ], [ 0, %3 ]
ret i32 %26
}