#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 EOF;
char *getenv(char *);
int getopt(int, char *const *, char const *);
char *optarg;
size_t optind;
int optopt;
int /*<<< orphan*/ printf(char *, char *, size_t, char *const, char *, int);
int main(int argc, char *const *argv) {
  const char *parser;
  char showchar[] = "\'?\'";
  int c;
  parser = getenv("GETOPTTEST");
  if (!parser)
    parser = "abzf:o:";
  do {
    c = getopt(argc, argv, parser);
    showchar[1] = c;
    printf("c = %s, optind = %d (%s), optarg = \"%s\", optopt = \'%c\'\n",
           (c == EOF) ? "EOF" : showchar, optind, argv[optind], optarg, optopt);
  } while (c != -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb4(%rip),%eax
mov    %eax,-0x1c(%rbp)
lea    0xeae(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1175 <main+0x45>
lea    0xe9e(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    117a <main+0x4a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,-0x1b(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e3b(%rip),%rcx
cmp    (%rcx),%eax
jne    11b5 <main+0x85>
lea    0xea3(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11bd <main+0x8d>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    0x2e08(%rip),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x2dfa(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    0x2e14(%rip),%rax
mov    (%rax),%r8
mov    0x2df2(%rip),%rax
mov    (%rax),%r9d
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xffffffff,-0x20(%rbp)
jne    117a <main+0x4a>
xor    %eax,%eax
add    $0x30,%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,%r14d
movl   $0x273f27,0x4(%rsp)
lea    0xeb0(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xeac(%rip),%r12
cmovne %rax,%r12
mov    0x2e76(%rip),%r13
lea    0xea2(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
mov    %eax,%ebp
mov    %bpl,0x5(%rsp)
mov    0x2e3c(%rip),%rax
cmp    (%rax),%ebp
lea    0x4(%rsp),%rsi
lea    0xea1(%rip),%rax
cmove  %rax,%rsi
mov    0x2e1b(%rip),%rax
mov    (%rax),%rdx
mov    (%rbx,%rdx,8),%rcx
mov    0x2e35(%rip),%rax
mov    (%rax),%r8
mov    0x0(%r13),%r9d
mov    %r15,%rdi
call   1040 <printf@plt>
cmp    $0xffffffff,%ebp
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.showchar = [4 x i8] c"'?'\00"
@.str = [11 x i8] c"GETOPTTEST\00"
@.str.1 = [8 x i8] c"abzf:o:\00"
@.str.2 = [56 x i8] c"c = %s, optind = %d (%s), optarg = \22%s\22, optopt = '%c'\0A\00"
@EOF = global i32 0
@.str.3 = [4 x i8] c"EOF\00"
@optind = global i64 0
@optarg = global i8* null
@optopt = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [4 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [4 x i8]* %7 to i8*
%10 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %14
14: ; preds = %13, %2
br label %15
15: ; preds = %39, %14
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %6
%19 = call i32 @getopt(i32 %16, i8** %17, i8* %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
store i8 %21, i8* %22
%23 = load i32, i32* %8
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %15
br label %29
27: ; preds = %15
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
br label %29
29: ; preds = %27, %26
%30 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %26 ], [ %28, %27 ]
%31 = load i64, i64* @optind
%32 = load i8**, i8*** %5
%33 = load i64, i64* @optind
%34 = getelementptr inbounds i8*, i8** %32, i64 %33
%35 = load i8*, i8** %34
%36 = load i8*, i8** @optarg
%37 = load i32, i32* @optopt
%38 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i8* %30, i64 %31, i8* %35, i8* %36, i32 %37)
br label %39
39: ; preds = %29
%40 = load i32, i32* %8
%41 = icmp ne i32 %40, -1
br i1 %41, label %15, label %42
42: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"GETOPTTEST\00"
@.str.1 = [8 x i8] c"abzf:o:\00"
@.str.2 = [56 x i8] c"c = %s, optind = %d (%s), optarg = \22%s\22, optopt = '%c'\0A\00"
@EOF = global i32 0
@.str.3 = [4 x i8] c"EOF\00"
@optind = global i64 0
@optarg = global i8* null
@optopt = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to [4 x i8]*
%5 = bitcast i32* %3 to i8*
store i32 2572071, i32* %3
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
%8 = select i1 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %6
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
br label %10
10: ; preds = %10, %2
%11 = call i32 @getopt(i32 %0, i8** %1, i8* %8)
%12 = trunc i32 %11 to i8
store i8 %12, i8* %9
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %11, %13
%15 = select i1 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %5
%16 = load i64, i64* @optind
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = load i8*, i8** @optarg
%20 = load i32, i32* @optopt
%21 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i8* %15, i64 %16, i8* %18, i8* %19, i32 %20)
%22 = icmp eq i32 %11, -1
br i1 %22, label %23, label %10
23: ; preds = %10
ret i32 0
}