#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 {
  int dummy;
};

/* Variables and functions */
int MS_NOSUID;
int MS_RDONLY;
scalar_t__ hasmntopt(struct mntent *, char *);
int flagsof(struct mntent *mnt) {
  int f = 0;
  if (hasmntopt(mnt, "ro"))
    f |= MS_RDONLY;
  if (hasmntopt(mnt, "nosuid"))
    f |= MS_NOSUID;
  return f;
}


x86 assembly (clang, -O0):
<flagsof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1030 <hasmntopt@plt>
cmp    $0x0,%rax
je     114c <flagsof+0x3c>
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <hasmntopt@plt>
cmp    $0x0,%rax
je     1175 <flagsof+0x65>
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flagsof>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xee2(%rip),%rsi
call   1030 <hasmntopt@plt>
xor    %ebx,%ebx
mov    $0x0,%ebp
test   %rax,%rax
je     1138 <flagsof+0x28>
mov    0x2eaa(%rip),%rax
mov    (%rax),%ebp
lea    0xec4(%rip),%rsi
mov    %r14,%rdi
call   1030 <hasmntopt@plt>
test   %rax,%rax
je     1155 <flagsof+0x45>
mov    0x2e95(%rip),%rax
mov    (%rax),%ebx
or     %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
@.str = [3 x i8] c"ro\00"
@MS_RDONLY = global i32 0
@.str.1 = [7 x i8] c"nosuid\00"
@MS_NOSUID = global i32 0
define i32 @flagsof(%struct.mntent* %0) {
%2 = alloca %struct.mntent*
%3 = alloca i32
store %struct.mntent* %0, %struct.mntent** %2
store i32 0, i32* %3
%4 = load %struct.mntent*, %struct.mntent** %2
%5 = call i64 @hasmntopt(%struct.mntent* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @MS_RDONLY
%9 = load i32, i32* %3
%10 = or i32 %9, %8
store i32 %10, i32* %3
br label %11
11: ; preds = %7, %1
%12 = load %struct.mntent*, %struct.mntent** %2
%13 = call i64 @hasmntopt(%struct.mntent* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @MS_NOSUID
%17 = load i32, i32* %3
%18 = or i32 %17, %16
store i32 %18, i32* %3
br label %19
19: ; preds = %15, %11
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@.str = [3 x i8] c"ro\00"
@MS_RDONLY = global i32 0
@.str.1 = [7 x i8] c"nosuid\00"
@MS_NOSUID = global i32 0
define i32 @flagsof(%struct.mntent* %0) {
%2 = tail call i64 @hasmntopt(%struct.mntent* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
%4 = load i32, i32* @MS_RDONLY
%5 = select i1 %3, i32 0, i32 %4
%6 = tail call i64 @hasmntopt(%struct.mntent* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
%8 = load i32, i32* @MS_NOSUID
%9 = select i1 %7, i32 0, i32 %8
%10 = or i32 %9, %5
ret i32 %10
}