#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_getopt1(void) {
  int r;
  char *t1[] = {"prog", "-n", NULL};
  do {
    if (!(optind == 1)) {
      printf("expression '%s' untrue at %d\n", "optind == 1", 31);
      return 0;
    }
  } while (0);
  r = getopt(2, t1, "nt:");
  do {
    if (!(r == 'n')) {
      printf("expression '%s' untrue at %d\n", "r == 'n'", 34);
      return 0;
    }
  } while (0);
  do {
    if (!(optind == 2)) {
      printf("expression '%s' untrue at %d\n", "optind == 2", 35);
      return 0;
    }
  } while (0);
  do {
    if (!(optarg == NULL)) {
      printf("expression '%s' untrue at %d\n", "optarg == NULL", 36);
      return 0;
    }
  } while (0);
  r = getopt(2, t1, "nt:");
  do {
    if (!(r == -1)) {
      printf("expression '%s' untrue at %d\n", "r == -1", 39);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_getopt1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2cc1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cbe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2cbb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e88(%rip),%rax
cmpl   $0x1,(%rax)
je     117d <test_getopt1+0x5d>
lea    0xea8(%rip),%rdi
lea    0xebf(%rip),%rsi
mov    $0x1f,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_getopt1+0x17c>
jmp    1182 <test_getopt1+0x62>
lea    -0x20(%rbp),%rsi
mov    $0x2,%edi
lea    0xea0(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x6e,-0x8(%rbp)
je     11c8 <test_getopt1+0xa8>
lea    0xe5d(%rip),%rdi
lea    0xe84(%rip),%rsi
mov    $0x22,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_getopt1+0x17c>
jmp    11cd <test_getopt1+0xad>
jmp    11d2 <test_getopt1+0xb2>
mov    0x2dff(%rip),%rax
cmpl   $0x2,(%rax)
je     1206 <test_getopt1+0xe6>
lea    0xe1f(%rip),%rdi
lea    0xe4f(%rip),%rsi
mov    $0x23,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_getopt1+0x17c>
jmp    120b <test_getopt1+0xeb>
jmp    1210 <test_getopt1+0xf0>
mov    0x2dd9(%rip),%rax
cmpq   $0x0,(%rax)
je     1245 <test_getopt1+0x125>
lea    0xde0(%rip),%rdi
lea    0xe1c(%rip),%rsi
mov    $0x24,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_getopt1+0x17c>
jmp    124a <test_getopt1+0x12a>
lea    -0x20(%rbp),%rsi
mov    $0x2,%edi
lea    0xdd8(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1290 <test_getopt1+0x170>
lea    0xd95(%rip),%rdi
lea    0xde0(%rip),%rsi
mov    $0x27,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_getopt1+0x17c>
jmp    1295 <test_getopt1+0x175>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getopt1>:
push   %rbx
sub    $0x20,%rsp
mov    0x2cd4(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0x2cb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e95(%rip),%rbx
cmpl   $0x1,(%rbx)
jne    1188 <test_getopt1+0x68>
lea    0xee3(%rip),%rdx
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <getopt@plt>
cmp    $0x6e,%eax
jne    119d <test_getopt1+0x7d>
cmpl   $0x2,(%rbx)
jne    11b2 <test_getopt1+0x92>
mov    0x2e83(%rip),%rax
cmpq   $0x0,(%rax)
je     11d2 <test_getopt1+0xb2>
lea    0xe8e(%rip),%rdi
lea    0xeca(%rip),%rsi
mov    $0x24,%edx
jmp    11c5 <test_getopt1+0xa5>
lea    0xe79(%rip),%rdi
lea    0xe90(%rip),%rsi
mov    $0x1f,%edx
jmp    11c5 <test_getopt1+0xa5>
lea    0xe64(%rip),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x22,%edx
jmp    11c5 <test_getopt1+0xa5>
lea    0xe4f(%rip),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x23,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe59(%rip),%rdx
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     1200 <test_getopt1+0xe0>
lea    0xe16(%rip),%rdi
lea    0xe61(%rip),%rsi
mov    $0x27,%edx
jmp    11c5 <test_getopt1+0xa5>
mov    $0x1,%eax
jmp    11cc <test_getopt1+0xac>

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

LLVM IR (-O2):
@.str = [5 x i8] c"prog\00"
@.str.1 = [3 x i8] c"-n\00"
@__const.test_getopt1.t1 = [3 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* null]
@optind = global i32 0
@.str.2 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.3 = [12 x i8] c"optind == 1\00"
@.str.4 = [4 x i8] c"nt:\00"
@.str.5 = [9 x i8] c"r == 'n'\00"
@.str.6 = [12 x i8] c"optind == 2\00"
@optarg = global i32* null
@.str.7 = [15 x i8] c"optarg == NULL\00"
@.str.8 = [8 x i8] c"r == -1\00"
define i32 @test_getopt1() {
%1 = alloca [3 x i8*]
%2 = bitcast [3 x i8*]* %1 to i8*
%3 = load i32, i32* @optind
%4 = icmp eq i32 %3, 1
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 31)
br label %28
7: ; preds = %0
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%9 = call i32 @getopt(i32 2, i8** %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i32 %9, 110
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 34)
br label %28
13: ; preds = %7
%14 = load i32, i32* @optind
%15 = icmp eq i32 %14, 2
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 35)
br label %28
18: ; preds = %13
%19 = load i32*, i32** @optarg
%20 = icmp eq i32* %19, null
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 36)
br label %28
23: ; preds = %18
%24 = call i32 @getopt(i32 2, i8** %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i32 %24, -1
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 39)
br label %28
28: ; preds = %23, %26, %21, %16, %11, %5
%29 = phi i32 [ 0, %26 ], [ 0, %21 ], [ 0, %16 ], [ 0, %11 ], [ 0, %5 ], [ 1, %23 ]
ret i32 %29
}