#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 strlen(char const *);
char *strstr(char *, char const *);
char *hasmntopt(const struct mntent *mnt, const char *opt) {
  char *cp = mnt->mnt_opts;
  int len = strlen(opt);
  if (!mnt->mnt_opts)
    return 0;
  while (1) {
    if (!(cp = strstr(cp, opt)))
      break;
    if ((cp == mnt->mnt_opts || cp[-1] == ',') &&
        (cp[len] == 0 || cp[len] == ',' || cp[len] == '='))
      return cp;
    cp += (len + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<hasmntopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1162 <hasmntopt+0x42>
movq   $0x0,-0x8(%rbp)
jmp    1216 <hasmntopt+0xf6>
jmp    1167 <hasmntopt+0x47>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1187 <hasmntopt+0x67>
jmp    120e <hasmntopt+0xee>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
je     11a9 <hasmntopt+0x89>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2c,%eax
jne    11f5 <hasmntopt+0xd5>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11e8 <hasmntopt+0xc8>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
je     11e8 <hasmntopt+0xc8>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    11f5 <hasmntopt+0xd5>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1216 <hasmntopt+0xf6>
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1167 <hasmntopt+0x47>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hasmntopt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    (%rdi),%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    0x0(%rbp),%rbp
test   %rbp,%rbp
je     11a1 <hasmntopt+0x81>
mov    %eax,%r14d
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     11a1 <hasmntopt+0x81>
movslq %r14d,%r14
lea    0x1(%r14),%ecx
movslq %ecx,%r15
movabs $0x2000100000000001,%r12
jmp    1183 <hasmntopt+0x63>
nopl   0x0(%rax,%rax,1)
add    %r15,%rax
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     11a1 <hasmntopt+0x81>
cmp    %rbp,%rax
je     118e <hasmntopt+0x6e>
cmpb   $0x2c,-0x1(%rax)
jne    1170 <hasmntopt+0x50>
movzbl (%rax,%r14,1),%ecx
cmp    $0x3d,%rcx
ja     1170 <hasmntopt+0x50>
bt     %rcx,%r12
jae    1170 <hasmntopt+0x50>
jmp    11a3 <hasmntopt+0x83>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mntent = type { i8* }
define i8* @hasmntopt(%struct.mntent* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca %struct.mntent*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store %struct.mntent* %0, %struct.mntent** %4
store i8* %1, i8** %5
%8 = load %struct.mntent*, %struct.mntent** %4
%9 = getelementptr inbounds %struct.mntent, %struct.mntent* %8, i32 0, i32 0
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %7
%13 = load %struct.mntent*, %struct.mntent** %4
%14 = getelementptr inbounds %struct.mntent, %struct.mntent* %13, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %2
store i8* null, i8** %3
br label %70
18: ; preds = %2
br label %19
19: ; preds = %18, %63
%20 = load i8*, i8** %6
%21 = load i8*, i8** %5
%22 = call i8* @strstr(i8* %20, i8* %21)
store i8* %22, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %19
br label %69
25: ; preds = %19
%26 = load i8*, i8** %6
%27 = load %struct.mntent*, %struct.mntent** %4
%28 = getelementptr inbounds %struct.mntent, %struct.mntent* %27, i32 0, i32 0
%29 = load i8*, i8** %28
%30 = icmp eq i8* %26, %29
br i1 %30, label %37, label %31
31: ; preds = %25
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 -1
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 44
br i1 %36, label %37, label %63
37: ; preds = %31, %25
%38 = load i8*, i8** %6
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %61, label %45
45: ; preds = %37
%46 = load i8*, i8** %6
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 44
br i1 %52, label %61, label %53
53: ; preds = %45
%54 = load i8*, i8** %6
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 61
br i1 %60, label %61, label %63
61: ; preds = %53, %45, %37
%62 = load i8*, i8** %6
store i8* %62, i8** %3
br label %70
63: ; preds = %53, %31
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
%66 = load i8*, i8** %6
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds i8, i8* %66, i64 %67
store i8* %68, i8** %6
br label %19
69: ; preds = %24
store i8* null, i8** %3
br label %70
70: ; preds = %69, %61, %17
%71 = load i8*, i8** %3
ret i8* %71
}

LLVM IR (-O2):
%struct.mntent = type { i8* }
define i8* @hasmntopt(%struct.mntent* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.mntent, %struct.mntent* %0, i64 0, i32 0
%4 = load i8*, i8** %3
%5 = tail call i32 @strlen(i8* %1)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %29, label %8
8: ; preds = %2
%9 = tail call i8* @strstr(i8* dereferenceable(1) %4, i8* dereferenceable(1) %1)
%10 = icmp eq i8* %9, null
br i1 %10, label %29, label %11
11: ; preds = %8
%12 = sext i32 %5 to i64
%13 = add nsw i32 %5, 1
%14 = sext i32 %13 to i64
br label %15
15: ; preds = %11, %25
%16 = phi i8* [ %9, %11 ], [ %27, %25 ]
%17 = icmp eq i8* %16, %6
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %16, i64 -1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 44
br i1 %21, label %22, label %25
22: ; preds = %18, %15
%23 = getelementptr inbounds i8, i8* %16, i64 %12
%24 = load i8, i8* %23
switch i8 %24, label %25 [
i8 0, label %29
i8 44, label %29
i8 61, label %29
]
25: ; preds = %22, %18
%26 = getelementptr inbounds i8, i8* %16, i64 %14
%27 = tail call i8* @strstr(i8* dereferenceable(1) %26, i8* dereferenceable(1) %1)
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %15
29: ; preds = %22, %22, %22, %25, %8, %2
%30 = phi i8* [ null, %2 ], [ null, %8 ], [ %16, %22 ], [ %16, %22 ], [ %16, %22 ], [ null, %25 ]
ret i8* %30
}