#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 errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int ow__gets(int /*<<< orphan*/ *, char *, size_t);
int ow__strarr_push(char **, size_t *, char *);
int strlen(char *);
int ow__read_physfs(char **buf, size_t *len) {
  int r = 0;
  FILE *f = fopen("/proc/filesystems", "r");
  if (f == NULL) {
    return -errno;
  }
  while ((r = ow__gets(f, *buf, *len)) == 0 && !feof(f)) {
    if ((*buf)[0] == '\t') {
      size_t num = strlen(*buf) - 1;
      (*buf)[num] = '\0';
      r = ow__strarr_push(buf, len, *buf + 1);
      if (r != 0)
        break;
    }
  }
  fclose(f);
  return r;
}


x86 assembly (clang, -O0):
<ow__read_physfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe82(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ac <ow__read_physfs+0x4c>
xor    %eax,%eax
mov    0x2e3e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1279 <ow__read_physfs+0x119>
jmp    11b1 <ow__read_physfs+0x51>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
call   1080 <ow__gets@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    11ef <ow__read_physfs+0x8f>
mov    -0x28(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11ff <ow__read_physfs+0x9f>
jmp    126a <ow__read_physfs+0x10a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    1265 <ow__read_physfs+0x105>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
add    $0x1,%rdx
call   1060 <ow__strarr_push@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1260 <ow__read_physfs+0x100>
jmp    126a <ow__read_physfs+0x10a>
jmp    1265 <ow__read_physfs+0x105>
jmp    11b1 <ow__read_physfs+0x51>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ow__read_physfs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe8c(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f2 <ow__read_physfs+0x92>
mov    %rax,%r15
mov    (%rbx),%rsi
mov    (%r14),%rdx
mov    %rax,%rdi
call   1080 <ow__gets@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1201 <ow__read_physfs+0xa1>
jmp    11b2 <ow__read_physfs+0x52>
xchg   %ax,%ax
mov    (%rbx),%rsi
mov    (%r14),%rdx
mov    %r15,%rdi
call   1080 <ow__gets@plt>
test   %eax,%eax
jne    11ee <ow__read_physfs+0x8e>
mov    %r15,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11ff <ow__read_physfs+0x9f>
mov    (%rbx),%rsi
cmpb   $0x9,(%rsi)
jne    11a3 <ow__read_physfs+0x43>
mov    %rsi,%rdi
call   1040 <strlen@plt>
cltq
mov    (%rbx),%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    (%rbx),%rdx
add    $0x1,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <ow__strarr_push@plt>
test   %eax,%eax
je     11a0 <ow__read_physfs+0x40>
mov    %eax,%ebp
jmp    1201 <ow__read_physfs+0xa1>
mov    0x2de7(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    1209 <ow__read_physfs+0xa9>
xor    %ebp,%ebp
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
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"
@errno = global i32 0
define i32 @ow__read_physfs(i8** %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
store i8** %0, i8*** %4
store i64* %1, i64** %5
store i32 0, i32* %6
%9 = 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* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @errno
%14 = sub nsw i32 0, %13
store i32 %14, i32* %3
br label %63
15: ; preds = %2
br label %16
16: ; preds = %58, %15
%17 = load i32*, i32** %7
%18 = load i8**, i8*** %4
%19 = load i8*, i8** %18
%20 = load i64*, i64** %5
%21 = load i64, i64* %20
%22 = call i32 @ow__gets(i32* %17, i8* %19, i64 %21)
store i32 %22, i32* %6
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = load i32*, i32** %7
%26 = call i32 @feof(i32* %25)
%27 = icmp ne i32 %26, 0
%28 = xor i1 %27, true
br label %29
29: ; preds = %24, %16
%30 = phi i1 [ false, %16 ], [ %28, %24 ]
br i1 %30, label %31, label %59
31: ; preds = %29
%32 = load i8**, i8*** %4
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 9
br i1 %37, label %38, label %58
38: ; preds = %31
%39 = load i8**, i8*** %4
%40 = load i8*, i8** %39
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
store i64 %43, i64* %8
%44 = load i8**, i8*** %4
%45 = load i8*, i8** %44
%46 = load i64, i64* %8
%47 = getelementptr inbounds i8, i8* %45, i64 %46
store i8 0, i8* %47
%48 = load i8**, i8*** %4
%49 = load i64*, i64** %5
%50 = load i8**, i8*** %4
%51 = load i8*, i8** %50
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = call i32 @ow__strarr_push(i8** %48, i64* %49, i8* %52)
store i32 %53, i32* %6
%54 = load i32, i32* %6
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %38
br label %59
57: ; preds = %38
br label %58
58: ; preds = %57, %31
br label %16
59: ; preds = %56, %29
%60 = load i32*, i32** %7
%61 = call i32 @fclose(i32* %60)
%62 = load i32, i32* %6
store i32 %62, i32* %3
br label %63
63: ; preds = %59, %12
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str = [18 x i8] c"/proc/filesystems\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i32 0
define i32 @ow__read_physfs(i8** %0, i64* %1) {
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i8*, i8** %0
%7 = load i64, i64* %1
%8 = tail call i32 @ow__gets(i32* %3, i8* %6, i64 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %37
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = sub nsw i32 0, %11
br label %40
13: ; preds = %5, %32
%14 = tail call i32 @feof(i32* %3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %37
16: ; preds = %13
%17 = load i8*, i8** %0
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 9
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = tail call i32 @strlen(i8* %17)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = load i8*, i8** %0
%25 = getelementptr inbounds i8, i8* %24, i64 %23
store i8 0, i8* %25
%26 = load i8*, i8** %0
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = tail call i32 @ow__strarr_push(i8** %0, i64* %1, i8* %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %20
%31 = load i8*, i8** %0
br label %32
32: ; preds = %30, %16
%33 = phi i8* [ %31, %30 ], [ %17, %16 ]
%34 = load i64, i64* %1
%35 = tail call i32 @ow__gets(i32* %3, i8* %33, i64 %34)
%36 = icmp eq i32 %35, 0
br i1 %36, label %13, label %37
37: ; preds = %13, %32, %20, %5
%38 = phi i32 [ %8, %5 ], [ %28, %20 ], [ %35, %32 ], [ 0, %13 ]
%39 = tail call i32 @fclose(i32* %3)
br label %40
40: ; preds = %37, %10
%41 = phi i32 [ %12, %10 ], [ %38, %37 ]
ret i32 %41
}