#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_getopt3(void) {
  int r;
  char *t2[] = {"bb", "uname", "-m", NULL};
  optind = 0;
  r = getopt(3, t2, "snrvmpios");
  do {
    if (!(r == 'm')) {
      printf("expression '%s' untrue at %d\n", "r == 'm'", 71);
      return 0;
    }
  } while (0);
  do {
    if (!(optind == 3)) {
      printf("expression '%s' untrue at %d\n", "optind == 3", 72);
      return 0;
    }
  } while (0);
  do {
    if (!(optarg == NULL)) {
      printf("expression '%s' untrue at %d\n", "optarg == NULL", 73);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_getopt3>:
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    0xe9b(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x6d,-0x8(%rbp)
je     11a7 <test_getopt3+0x87>
lea    0xe8c(%rip),%rdi
lea    0xea3(%rip),%rsi
mov    $0x47,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1230 <test_getopt3+0x110>
jmp    11ac <test_getopt3+0x8c>
jmp    11b1 <test_getopt3+0x91>
mov    0x2e28(%rip),%rax
cmpl   $0x3,(%rax)
je     11e5 <test_getopt3+0xc5>
lea    0xe4e(%rip),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x48,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1230 <test_getopt3+0x110>
jmp    11ea <test_getopt3+0xca>
jmp    11ef <test_getopt3+0xcf>
mov    0x2e02(%rip),%rax
cmpq   $0x0,(%rax)
je     1224 <test_getopt3+0x104>
lea    0xe0f(%rip),%rdi
lea    0xe3b(%rip),%rsi
mov    $0x49,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1230 <test_getopt3+0x110>
jmp    1229 <test_getopt3+0x109>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getopt3>:
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    0xebc(%rip),%rdx
mov    %rsp,%rsi
mov    $0x3,%edi
call   1040 <getopt@plt>
cmp    $0x6d,%eax
jne    1189 <test_getopt3+0x69>
cmpl   $0x3,(%rbx)
jne    119e <test_getopt3+0x7e>
mov    0x2e8a(%rip),%rax
cmpq   $0x0,(%rax)
je     11be <test_getopt3+0x9e>
lea    0xe9b(%rip),%rdi
lea    0xec7(%rip),%rsi
mov    $0x49,%edx
jmp    11b1 <test_getopt3+0x91>
lea    0xe86(%rip),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x47,%edx
jmp    11b1 <test_getopt3+0x91>
lea    0xe71(%rip),%rdi
lea    0xe91(%rip),%rsi
mov    $0x48,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    $0x1,%eax
jmp    11b8 <test_getopt3+0x98>

LLVM IR (-O0):
@.str = [3 x i8] c"bb\00"
@.str.1 = [6 x i8] c"uname\00"
@.str.2 = [3 x i8] c"-m\00"
@__const.test_getopt3.t2 = [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 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]
@optind = global i32 0
@.str.3 = [10 x i8] c"snrvmpios\00"
@.str.4 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.5 = [9 x i8] c"r == 'm'\00"
@.str.6 = [12 x i8] c"optind == 3\00"
@optarg = global i32* null
@.str.7 = [15 x i8] c"optarg == NULL\00"
define i32 @test_getopt3() {
%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 ([10 x i8], [10 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, 109
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 ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 71)
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, 3
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 72)
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 73)
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 = [6 x i8] c"uname\00"
@.str.2 = [3 x i8] c"-m\00"
@__const.test_getopt3.t2 = [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 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]
@optind = global i32 0
@.str.3 = [10 x i8] c"snrvmpios\00"
@.str.4 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.5 = [9 x i8] c"r == 'm'\00"
@.str.6 = [12 x i8] c"optind == 3\00"
@optarg = global i32* null
@.str.7 = [15 x i8] c"optarg == NULL\00"
define i32 @test_getopt3() {
%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 ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%5 = icmp eq i32 %4, 109
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 ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 71)
br label %18
8: ; preds = %0
%9 = load i32, i32* @optind
%10 = icmp eq i32 %9, 3
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 72)
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 73)
br label %18
18: ; preds = %13, %16, %11, %6
%19 = phi i32 [ 0, %16 ], [ 0, %11 ], [ 0, %6 ], [ 1, %13 ]
ret i32 %19
}