#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 */
typedef int /*<<< orphan*/ entry;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ mount(char const *, char const *, char *, int const, void const *);
int strlen(char *);
bool _mount_brute(const char *source, const char *dest, const int flags,
                  const void *data) {
  char entry[(
      (sizeof("nodev\tanon_inodefs") / sizeof("nodev\tanon_inodefs"[0])) - 1)] =
      {'\0'};
  bool result = false;
  FILE *list = NULL;
  assert(NULL != source);
  assert(NULL != dest);
  list = fopen("/proc/filesystems", "r");
  if (NULL == list) {
    goto end;
  }
  do {
    if (NULL == fgets(entry, ((sizeof(entry) / sizeof(entry[0])) - 1), list)) {
      break;
    }
    if ('\t' != entry[0]) {
      continue;
    }
    entry[strlen(entry) - 1] = '\0';
    if (0 == mount(source, dest, &entry[1], flags, data)) {
      result = true;
      break;
    }
  } while (1);
  (void)fclose(list);
end:
  return result;
}


x86 assembly (clang, -O0):
<_mount_brute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1060 <memset@plt>
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    0xe2d(%rip),%rdi
lea    0xe38(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x50(%rbp)
xor    %eax,%eax
cmp    -0x50(%rbp),%rax
jne    11f4 <_mount_brute+0x84>
jmp    129a <_mount_brute+0x12a>
jmp    11f9 <_mount_brute+0x89>
lea    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    $0x11,%esi
call   1070 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    121e <_mount_brute+0xae>
jmp    1291 <_mount_brute+0x121>
movsbl -0x40(%rbp),%ecx
mov    $0x9,%eax
cmp    %ecx,%eax
je     1234 <_mount_brute+0xc4>
jmp    1282 <_mount_brute+0x112>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x40(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
add    $0x1,%rdx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1050 <mount@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    127d <_mount_brute+0x10d>
movl   $0x1,-0x44(%rbp)
jmp    1291 <_mount_brute+0x121>
jmp    1282 <_mount_brute+0x112>
mov    $0x1,%al
test   $0x1,%al
jne    11f9 <_mount_brute+0x89>
jmp    1291 <_mount_brute+0x121>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mount_brute>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x10(%rsp)
xor    %edi,%edi
test   %rbp,%rbp
setne  %dil
call   1070 <assert@plt>
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1070 <assert@plt>
lea    0xe55(%rip),%rdi
lea    0xe60(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1229 <_mount_brute+0xc9>
mov    %rax,%rbx
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x11,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     121d <_mount_brute+0xbd>
cmpb   $0x9,(%rsp)
jne    11d0 <_mount_brute+0x70>
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r13,1)
mov    %rbp,%rdi
mov    %r12,%rsi
lea    0x1(%rsp),%rdx
mov    %r15d,%ecx
mov    %r14,%r8
call   1050 <mount@plt>
test   %rax,%rax
jne    11d0 <_mount_brute+0x70>
mov    $0x1,%ebp
jmp    121f <_mount_brute+0xbf>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    122b <_mount_brute+0xcb>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"/proc/filesystems\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @_mount_brute(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [18 x i8]
%10 = alloca i32
%11 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%12 = bitcast [18 x i8]* %9 to i8*
store i32 0, i32* %10
store i32* null, i32** %11
%13 = load i8*, i8** %5
%14 = icmp ne i8* null, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8*, i8** %6
%18 = icmp ne i8* null, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %11
%22 = load i32*, i32** %11
%23 = icmp eq i32* null, %22
br i1 %23, label %24, label %25
24: ; preds = %4
br label %57
25: ; preds = %4
br label %26
26: ; preds = %53, %25
%27 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 0
%28 = load i32*, i32** %11
%29 = call i32* @fgets(i8* %27, i32 17, i32* %28)
%30 = icmp eq i32* null, %29
br i1 %30, label %31, label %32
31: ; preds = %26
br label %54
32: ; preds = %26
%33 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 9, %35
br i1 %36, label %37, label %38
37: ; preds = %32
br label %53
38: ; preds = %32
%39 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 %42
store i8 0, i8* %43
%44 = load i8*, i8** %5
%45 = load i8*, i8** %6
%46 = getelementptr inbounds [18 x i8], [18 x i8]* %9, i64 0, i64 1
%47 = load i32, i32* %7
%48 = load i8*, i8** %8
%49 = call i64 @mount(i8* %44, i8* %45, i8* %46, i32 %47, i8* %48)
%50 = icmp eq i64 0, %49
br i1 %50, label %51, label %52
51: ; preds = %38
store i32 1, i32* %10
br label %54
52: ; preds = %38
br label %53
53: ; preds = %52, %37
br i1 true, label %26, label %54
54: ; preds = %53, %51, %31
%55 = load i32*, i32** %11
%56 = call i32 @fclose(i32* %55)
br label %57
57: ; preds = %54, %24
%58 = load i32, i32* %10
ret i32 %58
}

LLVM IR (-O2):
@.str = [18 x i8] c"/proc/filesystems\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @_mount_brute(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [18 x i8]
%6 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 0
%7 = icmp ne i8* %0, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ne i8* %1, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %36, label %15
15: ; preds = %4
%16 = call i32* @fgets(i8* %6, i32 17, i32* %13)
%17 = icmp eq i32* %16, null
br i1 %17, label %33, label %18
18: ; preds = %15
%19 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 1
br label %20
20: ; preds = %18, %30
%21 = load i8, i8* %6
%22 = icmp eq i8 %21, 9
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = call i32 @strlen(i8* %6)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 %26
store i8 0, i8* %27
%28 = call i64 @mount(i8* %0, i8* %1, i8* %19, i32 %2, i8* %3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %23, %20
%31 = call i32* @fgets(i8* %6, i32 17, i32* %13)
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %20
33: ; preds = %30, %23, %15
%34 = phi i32 [ 0, %15 ], [ 1, %23 ], [ 0, %30 ]
%35 = call i32 @fclose(i32* %13)
br label %36
36: ; preds = %4, %33
%37 = phi i32 [ 0, %4 ], [ %34, %33 ]
ret i32 %37
}