#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 optind;
int /*<<< orphan*/ printf(char *, char *, int);
int test_getopt8(void) {
  int r;
  char *a1 = "ls";
  char *a2 = "-laR";
  char *t8[] = {a1, a2, NULL};
  int ac = 2;
  optind = 1;
  r = getopt(ac, t8, "alR");
  do {
    if (!(r == 'l')) {
      printf("expression '%s' untrue at %d\n", "r == 'l'", 186);
      return 0;
    }
  } while (0);
  r = getopt(ac, t8, "alR");
  do {
    if (!(r == 'a')) {
      printf("expression '%s' untrue at %d\n", "r == 'a'", 189);
      return 0;
    }
  } while (0);
  r = getopt(ac, t8, "alR");
  do {
    if (!(r == 'R')) {
      printf("expression '%s' untrue at %d\n", "r == 'R'", 192);
      return 0;
    }
  } while (0);
  r = getopt(ac, t8, "alR");
  do {
    if (!(r == -1)) {
      printf("expression '%s' untrue at %d\n", "r == -1", 195);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_getopt8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x2,-0x34(%rbp)
mov    0x2e84(%rip),%rax
movl   $0x1,(%rax)
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    0xe90(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x6c,-0x8(%rbp)
je     11ae <test_getopt8+0x8e>
lea    0xe7b(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0xba,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <test_getopt8+0x175>
jmp    11b3 <test_getopt8+0x93>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    0xe47(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x61,-0x8(%rbp)
je     11f7 <test_getopt8+0xd7>
lea    0xe32(%rip),%rdi
lea    0xe52(%rip),%rsi
mov    $0xbd,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <test_getopt8+0x175>
jmp    11fc <test_getopt8+0xdc>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    0xdfe(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x52,-0x8(%rbp)
je     1240 <test_getopt8+0x120>
lea    0xde9(%rip),%rdi
lea    0xe12(%rip),%rsi
mov    $0xc0,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <test_getopt8+0x175>
jmp    1245 <test_getopt8+0x125>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    0xdb5(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1289 <test_getopt8+0x169>
lea    0xda0(%rip),%rdi
lea    0xdd2(%rip),%rsi
mov    $0xc3,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <test_getopt8+0x175>
jmp    128e <test_getopt8+0x16e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getopt8>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rax
mov    %rax,(%rsp)
lea    0xecd(%rip),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e9d(%rip),%rax
movl   $0x1,(%rax)
lea    0xeb0(%rip),%rdx
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <getopt@plt>
cmp    $0x6c,%eax
jne    11ca <test_getopt8+0xaa>
lea    0xe97(%rip),%rdx
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <getopt@plt>
cmp    $0x61,%eax
jne    11df <test_getopt8+0xbf>
lea    0xe7e(%rip),%rdx
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <getopt@plt>
cmp    $0x52,%eax
jne    11f4 <test_getopt8+0xd4>
lea    0xe65(%rip),%rdx
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     1213 <test_getopt8+0xf3>
lea    0xe50(%rip),%rdi
lea    0xe82(%rip),%rsi
mov    $0xc3,%edx
jmp    1207 <test_getopt8+0xe7>
lea    0xe3b(%rip),%rdi
lea    0xe52(%rip),%rsi
mov    $0xba,%edx
jmp    1207 <test_getopt8+0xe7>
lea    0xe26(%rip),%rdi
lea    0xe46(%rip),%rsi
mov    $0xbd,%edx
jmp    1207 <test_getopt8+0xe7>
lea    0xe11(%rip),%rdi
lea    0xe3a(%rip),%rsi
mov    $0xc0,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    $0x1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ls\00"
@.str.1 = [5 x i8] c"-laR\00"
@optind = global i32 0
@.str.2 = [4 x i8] c"alR\00"
@.str.3 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.4 = [9 x i8] c"r == 'l'\00"
@.str.5 = [9 x i8] c"r == 'a'\00"
@.str.6 = [9 x i8] c"r == 'R'\00"
@.str.7 = [8 x i8] c"r == -1\00"
define i32 @test_getopt8() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [3 x i8*]
%6 = alloca i32
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %4
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
store i8* %8, i8** %7
%9 = getelementptr inbounds i8*, i8** %7, i64 1
%10 = load i8*, i8** %4
store i8* %10, i8** %9
%11 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* null, i8** %11
store i32 2, i32* %6
store i32 1, i32* @optind
%12 = load i32, i32* %6
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 %14, i32* %2
br label %15
15: ; preds = %0
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 108
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 186)
store i32 0, i32* %1
br label %52
20: ; preds = %15
br label %21
21: ; preds = %20
%22 = load i32, i32* %6
%23 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%24 = call i32 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 %24, i32* %2
br label %25
25: ; preds = %21
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 97
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 189)
store i32 0, i32* %1
br label %52
30: ; preds = %25
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%34 = call i32 @getopt(i32 %32, i8** %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 %34, i32* %2
br label %35
35: ; preds = %31
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 82
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 192)
store i32 0, i32* %1
br label %52
40: ; preds = %35
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%44 = call i32 @getopt(i32 %42, i8** %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 %44, i32* %2
br label %45
45: ; preds = %41
%46 = load i32, i32* %2
%47 = icmp eq i32 %46, -1
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 195)
store i32 0, i32* %1
br label %52
50: ; preds = %45
br label %51
51: ; preds = %50
store i32 1, i32* %1
br label %52
52: ; preds = %51, %48, %38, %28, %18
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"ls\00"
@.str.1 = [5 x i8] c"-laR\00"
@optind = global i32 0
@.str.2 = [4 x i8] c"alR\00"
@.str.3 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.4 = [9 x i8] c"r == 'l'\00"
@.str.5 = [9 x i8] c"r == 'a'\00"
@.str.6 = [9 x i8] c"r == 'R'\00"
@.str.7 = [8 x i8] c"r == -1\00"
define i32 @test_getopt8() {
%1 = alloca [3 x i8*]
%2 = bitcast [3 x i8*]* %1 to i8*
%3 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 2
store i8* null, i8** %5
store i32 1, i32* @optind
%6 = call i32 @getopt(i32 2, i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %6, 108
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 186)
br label %25
10: ; preds = %0
%11 = call i32 @getopt(i32 2, i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 97
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 189)
br label %25
15: ; preds = %10
%16 = call i32 @getopt(i32 2, i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 82
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 192)
br label %25
20: ; preds = %15
%21 = call i32 @getopt(i32 2, i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, -1
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 195)
br label %25
25: ; preds = %20, %23, %18, %13, %8
%26 = phi i32 [ 0, %23 ], [ 0, %18 ], [ 0, %13 ], [ 0, %8 ], [ 1, %20 ]
ret i32 %26
}