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

/* Variables and functions */
int /*<<< orphan*/ FSETLOCKING_BYCALLER;
int /*<<< orphan*/ __fsetlocking(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ strstr(char *, char *);
int smackfs_exists(void) {
  int exists = 0;
  FILE *fp = NULL;
  char *buf = NULL;
  size_t len;
  ssize_t num;
  fp = fopen("/proc/filesystems", "r");
  if (!fp)
    return 1;
  __fsetlocking(fp, FSETLOCKING_BYCALLER);
  num = getline(&buf, &len, fp);
  while (num != -1) {
    if (strstr(buf, "smackfs")) {
      exists = 1;
      break;
    }
    num = getline(&buf, &len, fp);
  }
  free(buf);
  fclose(fp);
  return exists;
}


x86 assembly (clang, -O0):
<smackfs_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ad <smackfs_exists+0x4d>
movl   $0x1,-0x4(%rbp)
jmp    1234 <smackfs_exists+0xd4>
mov    -0x10(%rbp),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
call   1050 <__fsetlocking@plt>
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
je     121c <smackfs_exists+0xbc>
mov    -0x18(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1203 <smackfs_exists+0xa3>
movl   $0x1,-0x8(%rbp)
jmp    121c <smackfs_exists+0xbc>
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x24(%rbp)
jmp    11d3 <smackfs_exists+0x73>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smackfs_exists>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
lea    0xe85(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11f6 <smackfs_exists+0x96>
mov    %rax,%rbx
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <__fsetlocking@plt>
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rbx,%rdx
call   1070 <getline@plt>
xor    %r14d,%r14d
cmp    $0xffffffff,%eax
je     1204 <smackfs_exists+0xa4>
lea    0xe55(%rip),%r12
mov    %rsp,%r15
lea    0x8(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
mov    %r12,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
jne    11fe <smackfs_exists+0x9e>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
jne    11d0 <smackfs_exists+0x70>
jmp    1204 <smackfs_exists+0xa4>
mov    $0x1,%r14d
jmp    1215 <smackfs_exists+0xb5>
mov    $0x1,%r14d
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
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"
@FSETLOCKING_BYCALLER = global i32 0
@.str.2 = [8 x i8] c"smackfs\00"
define i32 @smackfs_exists() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %2
store i32* null, i32** %3
store i8* null, i8** %4
%7 = 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* %7, i32** %3
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %0
store i32 1, i32* %1
br label %34
11: ; preds = %0
%12 = load i32*, i32** %3
%13 = load i32, i32* @FSETLOCKING_BYCALLER
%14 = call i32 @__fsetlocking(i32* %12, i32 %13)
%15 = load i32*, i32** %3
%16 = call i32 @getline(i8** %4, i64* %5, i32* %15)
store i32 %16, i32* %6
br label %17
17: ; preds = %25, %11
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %2
br label %28
25: ; preds = %20
%26 = load i32*, i32** %3
%27 = call i32 @getline(i8** %4, i64* %5, i32* %26)
store i32 %27, i32* %6
br label %17
28: ; preds = %24, %17
%29 = load i8*, i8** %4
%30 = call i32 @free(i8* %29)
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
%33 = load i32, i32* %2
store i32 %33, i32* %1
br label %34
34: ; preds = %28, %10
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [18 x i8] c"/proc/filesystems\00"
@.str.1 = [2 x i8] c"r\00"
@FSETLOCKING_BYCALLER = global i32 0
@.str.2 = [8 x i8] c"smackfs\00"
define i32 @smackfs_exists() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
%5 = 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))
%6 = icmp eq i32* %5, null
br i1 %6, label %24, label %7
7: ; preds = %0
%8 = load i32, i32* @FSETLOCKING_BYCALLER
%9 = tail call i32 @__fsetlocking(i32* %5, i32 %8)
%10 = call i32 @getline(i8** %1, i64* %2, i32* %5)
%11 = icmp eq i32 %10, -1
br i1 %11, label %19, label %12
12: ; preds = %7, %16
%13 = load i8*, i8** %1
%14 = call i64 @strstr(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = call i32 @getline(i8** %1, i64* %2, i32* %5)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %12
19: ; preds = %16, %12, %7
%20 = phi i32 [ 0, %7 ], [ 1, %12 ], [ 0, %16 ]
%21 = load i8*, i8** %1
%22 = call i32 @free(i8* %21)
%23 = call i32 @fclose(i32* %5)
br label %24
24: ; preds = %0, %19
%25 = phi i32 [ %20, %19 ], [ 1, %0 ]
ret i32 %25
}