#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *, char *);
scalar_t__ strcmp(char *, char const *);
int find_mount(const char *mount, char *debugfs) {
  char type[100];
  FILE *fp;
  if ((fp = fopen("/proc/mounts", "r")) == NULL)
    return 0;
  while (fscanf(fp,
                "%*s %"
                "1024"
                "s %99s %*s %*d %*d\n",
                debugfs, type) == 2) {
    if (strcmp(type, mount) == 0)
      break;
  }
  fclose(fp);
  if (strcmp(type, mount) != 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<find_mount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xea6(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    1183 <find_mount+0x43>
movl   $0x0,-0x4(%rbp)
jmp    1203 <find_mount+0xc3>
jmp    1188 <find_mount+0x48>
mov    -0x88(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x80(%rbp),%rcx
lea    0xe71(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jne    11cd <find_mount+0x8d>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c8 <find_mount+0x88>
jmp    11cd <find_mount+0x8d>
jmp    1188 <find_mount+0x48>
mov    -0x88(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11fc <find_mount+0xbc>
movl   $0x0,-0x4(%rbp)
jmp    1203 <find_mount+0xc3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_mount>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xea6(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11c6 <find_mount+0x86>
mov    %rax,%rbx
lea    0xe9a(%rip),%r12
mov    %rsp,%r13
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jne    11a6 <find_mount+0x66>
mov    %r13,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1180 <find_mount+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
jmp    11c8 <find_mount+0x88>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"%*s %1024s %99s %*s %*d %*d\0A\00"
define i32 @find_mount(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [100 x i8]
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %34
11: ; preds = %2
br label %12
12: ; preds = %24, %11
%13 = load i32*, i32** %7
%14 = load i8*, i8** %5
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* %15)
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %25
18: ; preds = %12
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%20 = load i8*, i8** %4
%21 = call i64 @strcmp(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
br label %25
24: ; preds = %18
br label %12
25: ; preds = %23, %12
%26 = load i32*, i32** %7
%27 = call i32 @fclose(i32* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%29 = load i8*, i8** %4
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 0, i32* %3
br label %34
33: ; preds = %25
store i32 1, i32* %3
br label %34
34: ; preds = %33, %32, %10
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [13 x i8] c"/proc/mounts\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"%*s %1024s %99s %*s %*d %*d\0A\00"
define i32 @find_mount(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %18, label %7
7: ; preds = %2, %10
%8 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %4)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i64 @strcmp(i8* %4, i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %10, %7
%14 = call i32 @fclose(i32* %5)
%15 = call i64 @strcmp(i8* %4, i8* %0)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %13, %2
%19 = phi i32 [ 0, %2 ], [ %17, %13 ]
ret i32 %19
}