#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 optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  int optch;
  static char optstring[] = "gW;c";
  while ((optch = getopt(argc, argv, optstring)) != -1) {
    switch (optch) {
    case 'c':
      puts("-c processed");
      break;
    case 'g':
      puts("-g processed");
      break;
    case 'W':
      printf("-W '%s' processd\n", optarg);
      break;
    default:
      puts("unkown option");
      break;
    }
  }
  for (; optind < argc; ++optind) {
    printf("argv[ %d ] = '%s'\n", optind, argv[optind]);
  }
  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    0x2ee4(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11eb <main+0xbb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x57,%eax
je     11bd <main+0x8d>
jmp    1179 <main+0x49>
mov    -0x18(%rbp),%eax
sub    $0x63,%eax
je     119b <main+0x6b>
jmp    118a <main+0x5a>
mov    -0x18(%rbp),%eax
sub    $0x67,%eax
je     11ac <main+0x7c>
jmp    11da <main+0xaa>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
jmp    11e6 <main+0xb6>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
jmp    11e6 <main+0xb6>
mov    0x2e34(%rip),%rax
mov    (%rax),%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e6 <main+0xb6>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
jmp    1146 <main+0x16>
jmp    11f0 <main+0xc0>
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1245 <main+0x115>
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x2dca(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2da2(%rip),%rax
mov    %ecx,(%rax)
jmp    11f0 <main+0xc0>
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    0x2ef1(%rip),%r14
lea    0xede(%rip),%r12
lea    0xeab(%rip),%r13
lea    0xeb1(%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    $0x62,%eax
jle    1190 <main+0x60>
cmp    $0x63,%eax
je     1160 <main+0x30>
cmp    $0x67,%eax
jne    11b4 <main+0x84>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1168 <main+0x38>
xchg   %ax,%ax
cmp    $0x57,%eax
jne    11af <main+0x7f>
mov    0x2e5c(%rip),%rax
mov    (%rax),%rsi
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1168 <main+0x38>
cmp    $0xffffffff,%eax
je     11be <main+0x8e>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    1168 <main+0x38>
mov    0x2e1b(%rip),%r15
mov    (%r15),%eax
cmp    %ebp,%eax
jge    11fe <main+0xce>
lea    0xe67(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %eax,%rsi
mov    (%rbx,%rsi,8),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%eax
add    $0x1,%eax
mov    %eax,(%r15)
cmp    %ebp,%eax
jl     11e0 <main+0xb0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.optstring = internal global [5 x i8] c"gW;c\00"
@.str = [13 x i8] c"-c processed\00"
@.str.1 = [13 x i8] c"-g processed\00"
@.str.2 = [18 x i8] c"-W '%s' processd\0A\00"
@optarg = global i8* null
@.str.3 = [14 x i8] c"unkown option\00"
@optind = global i32 0
@.str.4 = [19 x i8] c"argv[ %d ] = '%s'\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 = %23, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @main.optstring, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %21 [
i32 99, label %14
i32 103, label %16
i32 87, label %18
]
14: ; preds = %12
%15 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %23
16: ; preds = %12
%17 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %23
18: ; preds = %12
%19 = load i8*, i8** @optarg
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %23
21: ; preds = %12
%22 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %18, %16, %14
br label %7
24: ; preds = %7
br label %25
25: ; preds = %37, %24
%26 = load i32, i32* @optind
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i32, i32* @optind
%31 = load i8**, i8*** %5
%32 = load i32, i32* @optind
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %30, i8* %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* @optind
%39 = add nsw i32 %38, 1
store i32 %39, i32* @optind
br label %25
40: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@main.optstring = internal global [5 x i8] c"gW;c\00"
@.str = [13 x i8] c"-c processed\00"
@.str.1 = [13 x i8] c"-g processed\00"
@.str.2 = [18 x i8] c"-W '%s' processd\0A\00"
@optarg = global i8* null
@.str.3 = [14 x i8] c"unkown option\00"
@optind = global i32 0
@.str.4 = [19 x i8] c"argv[ %d ] = '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %17, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @main.optstring, i64 0, i64 0))
switch i32 %4, label %15 [
i32 -1, label %5
i32 99, label %8
i32 103, label %10
i32 87, label %12
]
5: ; preds = %3
%6 = load i32, i32* @optind
%7 = icmp slt i32 %6, %0
br i1 %7, label %18, label %27
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %17
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %17
12: ; preds = %3
%13 = load i8*, i8** @optarg
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %3
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %12, %10, %8
br label %3
18: ; preds = %5, %18
%19 = phi i32 [ %25, %18 ], [ %6, %5 ]
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %19, i8* %22)
%24 = load i32, i32* @optind
%25 = add nsw i32 %24, 1
store i32 %25, i32* @optind
%26 = icmp slt i32 %25, %0
br i1 %26, label %18, label %27
27: ; preds = %18, %5
ret i32 0
}