#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 optind;
char optopt;
int /*<<< orphan*/ printf(char *);
int test_getopt_long1();
int test_getopt_long2();
int main(int argc, char **argv) {
  if (optind != 1)
    return 1;
  if (optopt != '?')
    return 1;
  if (test_getopt_long1() != 1)
    return 1;
  optind = 1;
  optopt = '?';
  if (test_getopt_long2() != 1)
    return 1;
  printf("ok\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e93(%rip),%rax
cmpl   $0x1,(%rax)
je     1162 <main+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xb3>
mov    0x2e7f(%rip),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
je     1181 <main+0x51>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xb3>
mov    $0x0,%al
call   1050 <test_getopt_long1@plt>
cmp    $0x1,%eax
je     119d <main+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xb3>
mov    0x2e3c(%rip),%rax
movl   $0x1,(%rax)
mov    0x2e37(%rip),%rax
movb   $0x3f,(%rax)
mov    $0x0,%al
call   1030 <test_getopt_long2@plt>
cmp    $0x1,%eax
je     11d0 <main+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xb3>
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2ea4(%rip),%r14
cmpl   $0x1,(%r14)
mov    $0x1,%ebx
jne    1185 <main+0x55>
mov    0x2e9a(%rip),%r15
cmpb   $0x3f,(%r15)
jne    1185 <main+0x55>
xor    %eax,%eax
call   1050 <test_getopt_long1@plt>
cmp    $0x1,%eax
jne    1185 <main+0x55>
movl   $0x1,(%r14)
movb   $0x3f,(%r15)
xor    %eax,%eax
call   1030 <test_getopt_long2@plt>
cmp    $0x1,%eax
jne    1185 <main+0x55>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@optind = global i32 0
@optopt = global i8 0
@.str = [4 x i8] c"ok\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @optind
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 1, i32* %3
br label %24
9: ; preds = %2
%10 = load i8, i8* @optopt
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 63
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 1, i32* %3
br label %24
14: ; preds = %9
%15 = call i32 (...) @test_getopt_long1()
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 1, i32* %3
br label %24
18: ; preds = %14
store i32 1, i32* @optind
store i8 63, i8* @optopt
%19 = call i32 (...) @test_getopt_long2()
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %3
br label %24
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %24
24: ; preds = %22, %21, %17, %13, %8
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@optind = global i32 0
@optopt = global i8 0
@str = [3 x i8] c"ok\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @optind
%4 = icmp eq i32 %3, 1
%5 = load i8, i8* @optopt
%6 = icmp eq i8 %5, 63
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = tail call i32 (...) @test_getopt_long1()
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %8
store i32 1, i32* @optind
store i8 63, i8* @optopt
%12 = tail call i32 (...) @test_getopt_long2()
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %11, %8, %2, %14
%17 = phi i32 [ 0, %14 ], [ 1, %2 ], [ 1, %8 ], [ 1, %11 ]
ret i32 %17
}