#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 /*<<< orphan*/ f_files;
  int /*<<< orphan*/ f_ffree;
  int /*<<< orphan*/ f_bsize;
  int /*<<< orphan*/ f_blocks;
  int /*<<< orphan*/ f_bfree;
  int /*<<< orphan*/ f_bavail;
};

/* Variables and functions */
int errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int fstatfs(int, struct statfs *);
int handle_zng(int);
int /*<<< orphan*/ printf(char *, ...);
int fstatfs_test(int fd, struct statfs *buf) {
  int ret, save_errno;
  int passed;
  printf("fstatfs(): fd=%d\n", fd);
  fflush(NULL);
  passed = handle_zng(ret = fstatfs(fd, buf));
  save_errno = errno;
  switch (passed) {
  case -1:
    printf("\t\tret = %d\n", ret);
    printf("\tSucceeded Phase 1\n");
    fflush(NULL);
    break;
  case 0:
    printf("\t\tFd: %d\n"
           "\t\tFree Blocks(User): %ld\n"
           "\t\tFree Blocks: %ld\n"
           "\t\tTotal Blocks: %ld\n"
           "\t\tBlock Size: %ld\n"
           "\t\tFree Inodes: %ld\n"
           "\t\tTotal Inodes: %ld\n",
           fd, buf->f_bavail, buf->f_bfree, buf->f_blocks, buf->f_bsize,
           buf->f_ffree, buf->f_files);
    printf("\t\tret = %d\n", ret);
    printf("\tSucceeded Phase 1\n");
    fflush(NULL);
    break;
  case -2:
    printf("\tFailed Phase 1: returned undefined value! "
           "ret = %d\n",
           ret);
    fflush(NULL);
    break;
  default:
    printf("Internal syscalltester error: passed = %d\n", passed);
    fflush(NULL);
    break;
  }
  errno = save_errno;
  return ret;
}


x86 assembly (clang, -O0):
<fstatfs_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,%edi
call   1050 <fflush@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <fstatfs@plt>
mov    %eax,%edi
mov    %edi,-0x14(%rbp)
call   1030 <handle_zng@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0xfffffffe,%eax
je     1266 <fstatfs_test+0x126>
jmp    11a6 <fstatfs_test+0x66>
mov    -0x20(%rbp),%eax
sub    $0xffffffff,%eax
je     11c7 <fstatfs_test+0x87>
jmp    11b7 <fstatfs_test+0x77>
mov    -0x20(%rbp),%eax
test   %eax,%eax
je     11f4 <fstatfs_test+0xb4>
jmp    1285 <fstatfs_test+0x145>
mov    -0x14(%rbp),%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
jmp    129f <fstatfs_test+0x15f>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
lea    0xe08(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
jmp    129f <fstatfs_test+0x15f>
mov    -0x14(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
jmp    129f <fstatfs_test+0x15f>
mov    -0x1c(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
mov    -0x18(%rbp),%ecx
mov    0x2d37(%rip),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fstatfs_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe9c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1060 <fflush@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <fstatfs@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1040 <handle_zng@plt>
mov    0x2e51(%rip),%r15
mov    (%r15),%r12d
cmp    $0xfffffffe,%eax
je     11ab <fstatfs_test+0x5b>
test   %eax,%eax
je     11be <fstatfs_test+0x6e>
cmp    $0xffffffff,%eax
je     11e9 <fstatfs_test+0x99>
lea    0xf2f(%rip),%rdi
mov    %eax,%esi
jmp    11b5 <fstatfs_test+0x65>
lea    0xeef(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1206 <fstatfs_test+0xb6>
mov    0x14(%rbx),%edx
mov    0x10(%rbx),%ecx
mov    0xc(%rbx),%r8d
mov    0x8(%rbx),%r9d
mov    (%rbx),%r10d
mov    0x4(%rbx),%ebx
lea    0xe45(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
push   %r10
push   %rbx
call   1050 <printf@plt>
add    $0x10,%rsp
lea    0xe22(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf00(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <fflush@plt>
mov    %r12d,(%r15)
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.statfs = type { i32, i32, i32, i32, i32, i32 }
@.str = [18 x i8] c"fstatfs(): fd=%d\0A\00"
@errno = global i32 0
@.str.1 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.2 = [20 x i8] c"\09Succeeded Phase 1\0A\00"
@.str.3 = [131 x i8] c"\09\09Fd: %d\0A\09\09Free Blocks(User): %ld\0A\09\09Free Blocks: %ld\0A\09\09Total Blocks: %ld\0A\09\09Block Size: %ld\0A\09\09Free Inodes: %ld\0A\09\09Total Inodes: %ld\0A\00"
@.str.4 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.5 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
define i32 @fstatfs_test(i32 %0, %struct.statfs* %1) {
%3 = alloca i32
%4 = alloca %struct.statfs*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store %struct.statfs* %1, %struct.statfs** %4
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @fflush(i32* null)
%11 = load i32, i32* %3
%12 = load %struct.statfs*, %struct.statfs** %4
%13 = call i32 @fstatfs(i32 %11, %struct.statfs* %12)
store i32 %13, i32* %5
%14 = call i32 @handle_zng(i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* @errno
store i32 %15, i32* %6
%16 = load i32, i32* %7
switch i32 %16, label %51 [
i32 -1, label %17
i32 0, label %22
i32 -2, label %47
]
17: ; preds = %2
%18 = load i32, i32* %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @fflush(i32* null)
br label %55
22: ; preds = %2
%23 = load i32, i32* %3
%24 = load %struct.statfs*, %struct.statfs** %4
%25 = getelementptr inbounds %struct.statfs, %struct.statfs* %24, i32 0, i32 5
%26 = load i32, i32* %25
%27 = load %struct.statfs*, %struct.statfs** %4
%28 = getelementptr inbounds %struct.statfs, %struct.statfs* %27, i32 0, i32 4
%29 = load i32, i32* %28
%30 = load %struct.statfs*, %struct.statfs** %4
%31 = getelementptr inbounds %struct.statfs, %struct.statfs* %30, i32 0, i32 3
%32 = load i32, i32* %31
%33 = load %struct.statfs*, %struct.statfs** %4
%34 = getelementptr inbounds %struct.statfs, %struct.statfs* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = load %struct.statfs*, %struct.statfs** %4
%37 = getelementptr inbounds %struct.statfs, %struct.statfs* %36, i32 0, i32 1
%38 = load i32, i32* %37
%39 = load %struct.statfs*, %struct.statfs** %4
%40 = getelementptr inbounds %struct.statfs, %struct.statfs* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %26, i32 %29, i32 %32, i32 %35, i32 %38, i32 %41)
%43 = load i32, i32* %5
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%46 = call i32 @fflush(i32* null)
br label %55
47: ; preds = %2
%48 = load i32, i32* %5
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = call i32 @fflush(i32* null)
br label %55
51: ; preds = %2
%52 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = call i32 @fflush(i32* null)
br label %55
55: ; preds = %51, %47, %22, %17
%56 = load i32, i32* %6
store i32 %56, i32* @errno
%57 = load i32, i32* %5
ret i32 %57
}

LLVM IR (-O2):
%struct.statfs = type { i32, i32, i32, i32, i32, i32 }
@.str = [18 x i8] c"fstatfs(): fd=%d\0A\00"
@errno = global i32 0
@.str.1 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.3 = [131 x i8] c"\09\09Fd: %d\0A\09\09Free Blocks(User): %ld\0A\09\09Free Blocks: %ld\0A\09\09Total Blocks: %ld\0A\09\09Block Size: %ld\0A\09\09Free Inodes: %ld\0A\09\09Total Inodes: %ld\0A\00"
@.str.4 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.5 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
@str.6 = [19 x i8] c"\09Succeeded Phase 1\00"
define i32 @fstatfs_test(i32 %0, %struct.statfs* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = tail call i32 @fflush(i32* null)
%5 = tail call i32 @fstatfs(i32 %0, %struct.statfs* %1)
%6 = tail call i32 @handle_zng(i32 %5)
%7 = load i32, i32* @errno
switch i32 %6, label %29 [
i32 -1, label %8
i32 0, label %11
i32 -2, label %27
]
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
br label %31
11: ; preds = %2
%12 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 5
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 4
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 3
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 0
%23 = load i32, i32* %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([131 x i8], [131 x i8]* @.str.3, i64 0, i64 0), i32 %0, i32 %13, i32 %15, i32 %17, i32 %19, i32 %21, i32 %23)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
br label %31
27: ; preds = %2
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i32 %5)
br label %31
29: ; preds = %2
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %6)
br label %31
31: ; preds = %29, %27, %11, %8
%32 = tail call i32 @fflush(i32* null)
store i32 %7, i32* @errno
ret i32 %5
}