#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 fstab {
  char *fs_vfstype;
};

/* Variables and functions */
int /*<<< orphan*/ endfsent();
struct fstab *getfsent();
int setfsent();
char *filesystem_type(void) {
  int ret = setfsent();
  if (ret != 1)
    return NULL;
  struct fstab *file_system = getfsent();
  endfsent();
  if (!file_system)
    return NULL;
  return file_system->fs_vfstype;
}


x86 assembly (clang, -O0):
<filesystem_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <setfsent@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     1159 <filesystem_type+0x29>
movq   $0x0,-0x8(%rbp)
jmp    118e <filesystem_type+0x5e>
mov    $0x0,%al
call   1040 <getfsent@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <endfsent@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1183 <filesystem_type+0x53>
movq   $0x0,-0x8(%rbp)
jmp    118e <filesystem_type+0x5e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filesystem_type>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <setfsent@plt>
cmp    $0x1,%eax
jne    115d <filesystem_type+0x2d>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getfsent@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <endfsent@plt>
test   %r14,%r14
je     115d <filesystem_type+0x2d>
mov    (%r14),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.fstab = type { i8* }
define i8* @filesystem_type() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca %struct.fstab*
%4 = call i32 (...) @setfsent()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %0
store i8* null, i8** %1
br label %18
8: ; preds = %0
%9 = call %struct.fstab* (...) @getfsent()
store %struct.fstab* %9, %struct.fstab** %3
%10 = call i32 (...) @endfsent()
%11 = load %struct.fstab*, %struct.fstab** %3
%12 = icmp ne %struct.fstab* %11, null
br i1 %12, label %14, label %13
13: ; preds = %8
store i8* null, i8** %1
br label %18
14: ; preds = %8
%15 = load %struct.fstab*, %struct.fstab** %3
%16 = getelementptr inbounds %struct.fstab, %struct.fstab* %15, i32 0, i32 0
%17 = load i8*, i8** %16
store i8* %17, i8** %1
br label %18
18: ; preds = %14, %13, %7
%19 = load i8*, i8** %1
ret i8* %19
}

LLVM IR (-O2):
%struct.fstab = type { i8* }
define i8* @filesystem_type() {
%1 = tail call i32 (...) @setfsent()
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call %struct.fstab* (...) @getfsent()
%5 = tail call i32 (...) @endfsent()
%6 = icmp eq %struct.fstab* %4, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = getelementptr inbounds %struct.fstab, %struct.fstab* %4, i64 0, i32 0
%9 = load i8*, i8** %8
br label %10
10: ; preds = %7, %3, %0
%11 = phi i8* [ null, %0 ], [ %9, %7 ], [ null, %3 ]
ret i8* %11
}