#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 *const *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *const, int);
scalar_t__ opterr;
int optopt;
int /*<<< orphan*/ stderr;
int getopt(int argc, char *const argv[], const char *optstring) {
  int ret_val;
  ret_val = __getopt(argc, argv, optstring);
  if ((ret_val != ':') && (ret_val != '?')) {
    return ret_val;
  }
  if ((optstring[0] != ':') && opterr) {
    if (ret_val == ':') {
      fprintf(stderr, "%s: option requires an argument -- %c\n", argv[0],
              optopt);
      ret_val = '?';
    } else if (ret_val == '?') {
      fprintf(stderr, "%s: illegal option -- %c\n", argv[0], optopt);
    }
  }
  return ret_val;
}


x86 assembly (clang, -O0):
<getopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <__getopt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x3a,-0x1c(%rbp)
je     1165 <getopt+0x45>
cmpl   $0x3f,-0x1c(%rbp)
je     1165 <getopt+0x45>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <getopt+0xe0>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     11fa <getopt+0xda>
mov    0x2e54(%rip),%rax
cmpq   $0x0,(%rax)
je     11fa <getopt+0xda>
cmpl   $0x3a,-0x1c(%rbp)
jne    11c1 <getopt+0xa1>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    0x2e41(%rip),%rax
mov    (%rax),%ecx
lea    0xe50(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x3f,-0x1c(%rbp)
jmp    11f5 <getopt+0xd5>
cmpl   $0x3f,-0x1c(%rbp)
jne    11f0 <getopt+0xd0>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    0x2e06(%rip),%rax
mov    (%rax),%ecx
lea    0xe3c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11f5 <getopt+0xd5>
jmp    11fa <getopt+0xda>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getopt>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
call   1030 <__getopt@plt>
cmp    $0x3f,%eax
je     1139 <getopt+0x19>
cmp    $0x3a,%eax
jne    1184 <getopt+0x64>
cmpb   $0x3a,(%rbx)
je     1184 <getopt+0x64>
mov    0x2e8b(%rip),%rcx
cmpq   $0x0,(%rcx)
je     1184 <getopt+0x64>
cmp    $0x3a,%eax
je     115e <getopt+0x3e>
cmp    $0x3f,%eax
jne    1184 <getopt+0x64>
lea    0xecb(%rip),%rsi
jmp    1165 <getopt+0x45>
lea    0xe9b(%rip),%rsi
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x2e70(%rip),%rax
mov    (%rax),%ecx
call   1040 <fprintf@plt>
mov    $0x3f,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@opterr = global i64 0
@stderr = global i32 0
@.str = [39 x i8] c"%s: option requires an argument -- %c\0A\00"
@optopt = global i32 0
@.str.1 = [26 x i8] c"%s: illegal option -- %c\0A\00"
define i32 @getopt(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%9 = load i32, i32* %5
%10 = load i8**, i8*** %6
%11 = load i8*, i8** %7
%12 = call i32 @__getopt(i32 %9, i8** %10, i8* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 58
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 63
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32, i32* %8
store i32 %19, i32* %4
br label %53
20: ; preds = %15, %3
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 58
br i1 %25, label %26, label %51
26: ; preds = %20
%27 = load i64, i64* @opterr
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %51
29: ; preds = %26
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 58
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %6
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = load i32, i32* @optopt
%38 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %36, i32 %37)
store i32 63, i32* %8
br label %50
39: ; preds = %29
%40 = load i32, i32* %8
%41 = icmp eq i32 %40, 63
br i1 %41, label %42, label %49
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %6
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i32, i32* @optopt
%48 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %46, i32 %47)
br label %49
49: ; preds = %42, %39
br label %50
50: ; preds = %49, %32
br label %51
51: ; preds = %50, %26, %20
%52 = load i32, i32* %8
store i32 %52, i32* %4
br label %53
53: ; preds = %51, %18
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
@opterr = global i64 0
@stderr = global i32 0
@.str = [39 x i8] c"%s: option requires an argument -- %c\0A\00"
@optopt = global i32 0
@.str.1 = [26 x i8] c"%s: illegal option -- %c\0A\00"
define i32 @getopt(i32 %0, i8** %1, i8* %2) {
%4 = tail call i32 @__getopt(i32 %0, i8** %1, i8* %2)
switch i32 %4, label %19 [
i32 63, label %5
i32 58, label %5
]
5: ; preds = %3, %3
%6 = load i8, i8* %2
%7 = icmp ne i8 %6, 58
%8 = load i64, i64* @opterr
%9 = icmp ne i64 %8, 0
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %19
11: ; preds = %5
switch i32 %4, label %19 [
i32 58, label %13
i32 63, label %12
]
12: ; preds = %11
br label %13
13: ; preds = %11, %12
%14 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), %12 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), %11 ]
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = load i32, i32* @optopt
%18 = tail call i32 @fprintf(i32 %15, i8* %14, i8* %16, i32 %17)
br label %19
19: ; preds = %13, %5, %11, %3
%20 = phi i32 [ %4, %3 ], [ %4, %5 ], [ %4, %11 ], [ 63, %13 ]
ret i32 %20
}