#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int optind;
int test_getopt_long1(void) {
  int r;
  char *t1[] = {"prog", "--yes", "-n", NULL};
  struct option lo1[] = {
      {"yes", 0, 0, 'y'},
      {0, 0, 0, 0},
  };
  if (optind != 1)
    return 0;
  r = getopt_long(3, t1, "nt:", lo1, NULL);
  if (r != 'y')
    return 0;
  if (optind != 2)
    return 0;
  r = getopt_long(3, t1, "nt:", lo1, NULL);
  if (r != 'n')
    return 0;
  if (optind != 3)
    return 0;
  r = getopt_long(3, t1, "nt:", lo1, NULL);
  if (r != -1)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<test_getopt_long1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x2cc1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cbe(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cbb(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cb8(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xe9c(%rip),%rax
mov    %rax,-0x60(%rbp)
movl   $0x79,-0x50(%rbp)
mov    0x2e63(%rip),%rax
cmpl   $0x1,(%rax)
je     1192 <test_getopt_long1+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1276 <test_getopt_long1+0x156>
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rcx
mov    $0x3,%edi
lea    0xe68(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x79,-0x8(%rbp)
je     11c9 <test_getopt_long1+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    1276 <test_getopt_long1+0x156>
mov    0x2e10(%rip),%rax
cmpl   $0x2,(%rax)
je     11e5 <test_getopt_long1+0xc5>
movl   $0x0,-0x4(%rbp)
jmp    1276 <test_getopt_long1+0x156>
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rcx
mov    $0x3,%edi
lea    0xe15(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x6e,-0x8(%rbp)
je     121c <test_getopt_long1+0xfc>
movl   $0x0,-0x4(%rbp)
jmp    1276 <test_getopt_long1+0x156>
mov    0x2dbd(%rip),%rax
cmpl   $0x3,(%rax)
je     1238 <test_getopt_long1+0x118>
movl   $0x0,-0x4(%rbp)
jmp    1276 <test_getopt_long1+0x156>
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rcx
mov    $0x3,%edi
lea    0xdc2(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     126f <test_getopt_long1+0x14f>
movl   $0x0,-0x4(%rbp)
jmp    1276 <test_getopt_long1+0x156>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getopt_long1>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movaps 0x2ce2(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2cc6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0xec0(%rip),%rax
mov    %rax,(%rsp)
movl   $0x79,0x10(%rsp)
mov    0x2e86(%rip),%r14
xor    %ebx,%ebx
cmpl   $0x1,(%r14)
jne    11d8 <test_getopt_long1+0xc8>
lea    0xea5(%rip),%rdx
xor    %ebx,%ebx
lea    0x30(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x3,%edi
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0x79,%eax
jne    11d8 <test_getopt_long1+0xc8>
cmpl   $0x2,(%r14)
jne    11d8 <test_getopt_long1+0xc8>
lea    0xe7c(%rip),%rdx
xor    %ebx,%ebx
lea    0x30(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x3,%edi
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0x6e,%eax
jne    11d8 <test_getopt_long1+0xc8>
cmpl   $0x3,(%r14)
jne    11d8 <test_getopt_long1+0xc8>
lea    0xe53(%rip),%rdx
lea    0x30(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x3,%edi
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"prog\00"
@.str.1 = [6 x i8] c"--yes\00"
@.str.2 = [3 x i8] c"-n\00"
@__const.test_getopt_long1.t1 = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [4 x i8] c"yes\00"
@optind = global i32 0
@.str.4 = [4 x i8] c"nt:\00"
define i32 @test_getopt_long1() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i8*]
%4 = alloca [2 x %struct.option]
%5 = bitcast [4 x i8*]* %3 to i8*
%6 = bitcast [2 x %struct.option]* %4 to i8*
%7 = bitcast i8* %6 to [2 x %struct.option]*
%8 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %7, i32 0, i32 0
%9 = getelementptr inbounds %struct.option, %struct.option* %8, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds %struct.option, %struct.option* %8, i32 0, i32 3
store i32 121, i32* %10
%11 = load i32, i32* @optind
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 0, i32* %1
br label %44
14: ; preds = %0
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%16 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %4, i64 0, i64 0
%17 = call i32 @getopt_long(i32 3, i8** %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %16, i32* null)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 121
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %1
br label %44
21: ; preds = %14
%22 = load i32, i32* @optind
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 0, i32* %1
br label %44
25: ; preds = %21
%26 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%27 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %4, i64 0, i64 0
%28 = call i32 @getopt_long(i32 3, i8** %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %27, i32* null)
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = icmp ne i32 %29, 110
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 0, i32* %1
br label %44
32: ; preds = %25
%33 = load i32, i32* @optind
%34 = icmp ne i32 %33, 3
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 0, i32* %1
br label %44
36: ; preds = %32
%37 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%38 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %4, i64 0, i64 0
%39 = call i32 @getopt_long(i32 3, i8** %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %38, i32* null)
store i32 %39, i32* %2
%40 = load i32, i32* %2
%41 = icmp ne i32 %40, -1
br i1 %41, label %42, label %43
42: ; preds = %36
store i32 0, i32* %1
br label %44
43: ; preds = %36
store i32 1, i32* %1
br label %44
44: ; preds = %43, %42, %35, %31, %24, %20, %13
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"prog\00"
@.str.1 = [6 x i8] c"--yes\00"
@.str.2 = [3 x i8] c"-n\00"
@__const.test_getopt_long1.t1 = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [4 x i8] c"yes\00"
@optind = global i32 0
@.str.4 = [4 x i8] c"nt:\00"
define i32 @test_getopt_long1() {
%1 = alloca [4 x i8*]
%2 = alloca [2 x %struct.option]
%3 = bitcast [4 x i8*]* %1 to i8*
%4 = bitcast [2 x %struct.option]* %2 to i8*
%5 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %2, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %2, i64 0, i64 0, i32 3
store i32 121, i32* %6
%7 = load i32, i32* @optind
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %27
9: ; preds = %0
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%11 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %2, i64 0, i64 0
%12 = call i32 @getopt_long(i32 3, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %11, i32* null)
%13 = icmp eq i32 %12, 121
%14 = load i32, i32* @optind
%15 = icmp eq i32 %14, 2
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %27
17: ; preds = %9
%18 = call i32 @getopt_long(i32 3, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %11, i32* null)
%19 = icmp eq i32 %18, 110
%20 = load i32, i32* @optind
%21 = icmp eq i32 %20, 3
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = call i32 @getopt_long(i32 3, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %struct.option* %11, i32* null)
%25 = icmp eq i32 %24, -1
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %23, %17, %9, %0
%28 = phi i32 [ 0, %0 ], [ 0, %9 ], [ 0, %17 ], [ %26, %23 ]
ret i32 %28
}