#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 statfs {
  int f_type;
};

/* Variables and functions */
int errno;
int statfs(char const *, struct statfs *);
int __tapdisk_fs_storage_type(const char *rpath) {
  struct statfs fst;
  int type, err;
  err = statfs(rpath, &fst);
  if (err)
    return -errno;
  switch (fst.f_type) {
  case 0x6969:
    type = 1;
    break;
  default:
    type = 2;
    break;
  }
  return type;
}


x86 assembly (clang, -O0):
<__tapdisk_fs_storage_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <statfs@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1149 <__tapdisk_fs_storage_type+0x39>
xor    %eax,%eax
mov    0x2ea1(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1175 <__tapdisk_fs_storage_type+0x65>
mov    -0x18(%rbp),%eax
sub    $0x6969,%eax
jne    1168 <__tapdisk_fs_storage_type+0x58>
jmp    115c <__tapdisk_fs_storage_type+0x4c>
movl   $0x1,-0x1c(%rbp)
jmp    116f <__tapdisk_fs_storage_type+0x5f>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__tapdisk_fs_storage_type>:
push   %rax
mov    %rsp,%rsi
call   1030 <statfs@plt>
test   %eax,%eax
je     112a <__tapdisk_fs_storage_type+0x1a>
mov    0x2ebc(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
pop    %rcx
ret
xor    %ecx,%ecx
cmpl   $0x6969,(%rsp)
sete   %cl
mov    $0x2,%eax
sub    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.statfs = type { i32 }
@errno = global i32 0
define i32 @__tapdisk_fs_storage_type(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.statfs
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @statfs(i8* %7, %struct.statfs* %4)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = sub nsw i32 0, %12
store i32 %13, i32* %2
br label %21
14: ; preds = %1
%15 = getelementptr inbounds %struct.statfs, %struct.statfs* %4, i32 0, i32 0
%16 = load i32, i32* %15
switch i32 %16, label %18 [
i32 26985, label %17
]
17: ; preds = %14
store i32 1, i32* %5
br label %19
18: ; preds = %14
store i32 2, i32* %5
br label %19
19: ; preds = %18, %17
%20 = load i32, i32* %5
store i32 %20, i32* %2
br label %21
21: ; preds = %19, %11
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
%struct.statfs = type { i32 }
@errno = global i32 0
define i32 @__tapdisk_fs_storage_type(i8* %0) {
%2 = alloca %struct.statfs
%3 = bitcast %struct.statfs* %2 to i8*
%4 = call i32 @statfs(i8* %0, %struct.statfs* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = sub nsw i32 0, %7
br label %14
9: ; preds = %1
%10 = getelementptr inbounds %struct.statfs, %struct.statfs* %2, i64 0, i32 0
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 26985
%13 = select i1 %12, i32 1, i32 2
br label %14
14: ; preds = %9, %6
%15 = phi i32 [ %8, %6 ], [ %13, %9 ]
ret i32 %15
}