#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 mntent {
  char *mnt_opts;
};

/* Variables and functions */
int /*<<< orphan*/ die(char *);
char *hasmntopt(struct mntent *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  struct mntent me;
  char *c;
  me.mnt_opts = "foo,bar=baz,duh";
  if (!(c = hasmntopt(&me, "foo")))
    die("hasmntopt did not find foo");
  if (!(c = hasmntopt(&me, "duh")))
    die("hasmntopt did not find duh");
  printf("%s\n", hasmntopt(&me, "bar"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1050 <hasmntopt@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1174 <main+0x44>
lea    0xea1(%rip),%rdi
call   1040 <die@plt>
lea    -0x10(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1050 <hasmntopt@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    119e <main+0x6e>
lea    0xe92(%rip),%rdi
call   1040 <die@plt>
lea    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <hasmntopt@plt>
mov    %rax,%rsi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rax
mov    %rax,(%rsp)
lea    0xee4(%rip),%rsi
mov    %rsp,%rdi
call   1050 <hasmntopt@plt>
test   %rax,%rax
jne    115c <main+0x2c>
lea    0xeb9(%rip),%rdi
call   1040 <die@plt>
lea    0xedf(%rip),%rsi
mov    %rsp,%rdi
call   1050 <hasmntopt@plt>
test   %rax,%rax
jne    117c <main+0x4c>
lea    0xeb4(%rip),%rdi
call   1040 <die@plt>
lea    0xec7(%rip),%rsi
mov    %rsp,%rdi
call   1050 <hasmntopt@plt>
lea    0xeb4(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.mntent = type { i8* }
@.str = [16 x i8] c"foo,bar=baz,duh\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [27 x i8] c"hasmntopt did not find foo\00"
@.str.3 = [4 x i8] c"duh\00"
@.str.4 = [27 x i8] c"hasmntopt did not find duh\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [4 x i8] c"bar\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.mntent
%3 = alloca i8*
store i32 0, i32* %1
%4 = getelementptr inbounds %struct.mntent, %struct.mntent* %2, i32 0, i32 0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = call i8* @hasmntopt(%struct.mntent* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = call i8* @hasmntopt(%struct.mntent* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i8* %10, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = call i8* @hasmntopt(%struct.mntent* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
%struct.mntent = type { i8* }
@.str = [16 x i8] c"foo,bar=baz,duh\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [27 x i8] c"hasmntopt did not find foo\00"
@.str.3 = [4 x i8] c"duh\00"
@.str.4 = [27 x i8] c"hasmntopt did not find duh\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [4 x i8] c"bar\00"
define i32 @main() {
%1 = alloca %struct.mntent
%2 = bitcast %struct.mntent* %1 to i8*
%3 = getelementptr inbounds %struct.mntent, %struct.mntent* %1, i64 0, i32 0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = call i8* @hasmntopt(%struct.mntent* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = call i8* @hasmntopt(%struct.mntent* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = call i8* @hasmntopt(%struct.mntent* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %14)
ret i32 0
}