#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 *);
int /*<<< orphan*/ *optarg;
int optind;
int /*<<< orphan*/ printf(char *, char *, int);
int test_getopt4(void) {
  int r;
  char *t2[] = {"bb", "wc", "README", NULL};
  optind = 0;
  r = getopt(3, t2, "l");
  do {
    if (!(r == -1)) {
      printf("expression '%s' untrue at %d\n", "r == -1", 85);
      return 0;
    }
  } while (0);
  do {
    if (!(optind == 1)) {
      printf("expression '%s' untrue at %d\n", "optind == 1", 86);
      return 0;
    }
  } while (0);
  do {
    if (!(optarg == NULL)) {
      printf("expression '%s' untrue at %d\n", "optarg == NULL", 87);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_getopt4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
mov    0x2e85(%rip),%rax
movl   $0x0,(%rax)
lea    -0x30(%rbp),%rsi
mov    $0x3,%edi
lea    0xe9c(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     11a7 <test_getopt4+0x87>
lea    0xe85(%rip),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x55,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1230 <test_getopt4+0x110>
jmp    11ac <test_getopt4+0x8c>
jmp    11b1 <test_getopt4+0x91>
mov    0x2e28(%rip),%rax
cmpl   $0x1,(%rax)
je     11e5 <test_getopt4+0xc5>
lea    0xe47(%rip),%rdi
lea    0xe66(%rip),%rsi
mov    $0x56,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1230 <test_getopt4+0x110>
jmp    11ea <test_getopt4+0xca>
jmp    11ef <test_getopt4+0xcf>
mov    0x2e02(%rip),%rax
cmpq   $0x0,(%rax)
je     1224 <test_getopt4+0x104>
lea    0xe08(%rip),%rdi
lea    0xe33(%rip),%rsi
mov    $0x57,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1230 <test_getopt4+0x110>
jmp    1229 <test_getopt4+0x109>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getopt4>:
push   %rbx
sub    $0x20,%rsp
movaps 0x2cd4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2cb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e9d(%rip),%rbx
movl   $0x0,(%rbx)
lea    0xebd(%rip),%rdx
mov    %rsp,%rsi
mov    $0x3,%edi
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     1177 <test_getopt4+0x57>
lea    0xea6(%rip),%rdi
lea    0xebd(%rip),%rsi
mov    $0x55,%edx
jmp    11b1 <test_getopt4+0x91>
cmpl   $0x1,(%rbx)
jne    119e <test_getopt4+0x7e>
mov    0x2e75(%rip),%rax
cmpq   $0x0,(%rax)
je     11be <test_getopt4+0x9e>
lea    0xe7f(%rip),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x57,%edx
jmp    11b1 <test_getopt4+0x91>
lea    0xe6a(%rip),%rdi
lea    0xe89(%rip),%rsi
mov    $0x56,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    $0x1,%eax
jmp    11b8 <test_getopt4+0x98>

LLVM IR (-O0):
@.str = [3 x i8] c"bb\00"
@.str.1 = [3 x i8] c"wc\00"
@.str.2 = [7 x i8] c"README\00"
@__const.test_getopt4.t2 = [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* null]
@optind = global i32 0
@.str.3 = [2 x i8] c"l\00"
@.str.4 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.5 = [8 x i8] c"r == -1\00"
@.str.6 = [12 x i8] c"optind == 1\00"
@optarg = global i32* null
@.str.7 = [15 x i8] c"optarg == NULL\00"
define i32 @test_getopt4() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i8*]
%4 = bitcast [4 x i8*]* %3 to i8*
store i32 0, i32* @optind
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%6 = call i32 @getopt(i32 3, i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 %6, i32* %2
br label %7
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, -1
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 85)
store i32 0, i32* %1
br label %28
12: ; preds = %7
br label %13
13: ; preds = %12
br label %14
14: ; preds = %13
%15 = load i32, i32* @optind
%16 = icmp eq i32 %15, 1
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 86)
store i32 0, i32* %1
br label %28
19: ; preds = %14
br label %20
20: ; preds = %19
br label %21
21: ; preds = %20
%22 = load i32*, i32** @optarg
%23 = icmp eq i32* %22, null
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 87)
store i32 0, i32* %1
br label %28
26: ; preds = %21
br label %27
27: ; preds = %26
store i32 1, i32* %1
br label %28
28: ; preds = %27, %24, %17, %10
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"bb\00"
@.str.1 = [3 x i8] c"wc\00"
@.str.2 = [7 x i8] c"README\00"
@__const.test_getopt4.t2 = [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* null]
@optind = global i32 0
@.str.3 = [2 x i8] c"l\00"
@.str.4 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.5 = [8 x i8] c"r == -1\00"
@.str.6 = [12 x i8] c"optind == 1\00"
@optarg = global i32* null
@.str.7 = [15 x i8] c"optarg == NULL\00"
define i32 @test_getopt4() {
%1 = alloca [4 x i8*]
%2 = bitcast [4 x i8*]* %1 to i8*
store i32 0, i32* @optind
%3 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%4 = call i32 @getopt(i32 3, i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = icmp eq i32 %4, -1
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 85)
br label %18
8: ; preds = %0
%9 = load i32, i32* @optind
%10 = icmp eq i32 %9, 1
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 86)
br label %18
13: ; preds = %8
%14 = load i32*, i32** @optarg
%15 = icmp eq i32* %14, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 87)
br label %18
18: ; preds = %13, %16, %11, %6
%19 = phi i32 [ 0, %16 ], [ 0, %11 ], [ 0, %6 ], [ 1, %13 ]
ret i32 %19
}