#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 handle_zng(int);
int /*<<< orphan*/ printf(char *, ...);
int statfs(char *, struct statfs *);
int statfs_test(char *path, struct statfs *buf) {
  int ret, save_errno;
  int passed;
  printf("statfs(): path=%s\n", (((path) == NULL) ? "(null)" : (path)));
  fflush(NULL);
  passed = handle_zng(ret = statfs(path, 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\tPath: %s\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",
           (((path) == NULL) ? "(null)" : (path)), 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):
<statfs_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116b <statfs_test+0x2b>
lea    0xeb1(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1173 <statfs_test+0x33>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,%edi
call   1060 <fflush@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <statfs@plt>
mov    %eax,%edi
mov    %edi,-0x14(%rbp)
call   1030 <handle_zng@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0xfffffffe,%eax
je     12b0 <statfs_test+0x170>
jmp    11cc <statfs_test+0x8c>
mov    -0x2c(%rbp),%eax
sub    $0xffffffff,%eax
je     11ed <statfs_test+0xad>
jmp    11dd <statfs_test+0x9d>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
je     121a <statfs_test+0xda>
jmp    12cf <statfs_test+0x18f>
mov    -0x14(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
jmp    12e9 <statfs_test+0x1a9>
cmpq   $0x0,-0x8(%rbp)
jne    1235 <statfs_test+0xf5>
lea    0xde7(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    123d <statfs_test+0xfd>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
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    0xdc6(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
jmp    12e9 <statfs_test+0x1a9>
mov    -0x14(%rbp),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
jmp    12e9 <statfs_test+0x1a9>
mov    -0x1c(%rbp),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
mov    -0x18(%rbp),%ecx
mov    0x2ced(%rip),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<statfs_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbp
test   %rdi,%rdi
lea    0xeab(%rip),%rbx
cmovne %rdi,%rbx
lea    0xe8d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <fflush@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <statfs@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1040 <handle_zng@plt>
mov    0x2e40(%rip),%r12
mov    (%r12),%ebp
cmp    $0xfffffffe,%eax
je     11bd <statfs_test+0x6d>
test   %eax,%eax
je     11d0 <statfs_test+0x80>
cmp    $0xffffffff,%eax
je     1200 <statfs_test+0xb0>
lea    0xf27(%rip),%rdi
mov    %eax,%esi
jmp    11c7 <statfs_test+0x77>
lea    0xee7(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    121d <statfs_test+0xcd>
mov    0x14(%r15),%edx
mov    0x10(%r15),%ecx
mov    0xc(%r15),%r8d
mov    0x8(%r15),%r9d
mov    (%r15),%r10d
mov    0x4(%r15),%r11d
lea    0xe38(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
push   %r10
push   %r11
call   1050 <printf@plt>
add    $0x10,%rsp
lea    0xe13(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <fflush@plt>
mov    %ebp,(%r12)
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 = [19 x i8] c"statfs(): path=%s\0A\00"
@.str.1 = [7 x i8] c"(null)\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.3 = [20 x i8] c"\09Succeeded Phase 1\0A\00"
@.str.4 = [133 x i8] c"\09\09Path: %s\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.5 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.6 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
define i32 @statfs_test(i8* %0, %struct.statfs* %1) {
%3 = alloca i8*
%4 = alloca %struct.statfs*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store %struct.statfs* %1, %struct.statfs** %4
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
br label %13
11: ; preds = %2
%12 = load i8*, i8** %3
br label %13
13: ; preds = %11, %10
%14 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %10 ], [ %12, %11 ]
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @fflush(i32* null)
%17 = load i8*, i8** %3
%18 = load %struct.statfs*, %struct.statfs** %4
%19 = call i32 @statfs(i8* %17, %struct.statfs* %18)
store i32 %19, i32* %5
%20 = call i32 @handle_zng(i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* @errno
store i32 %21, i32* %6
%22 = load i32, i32* %7
switch i32 %22, label %63 [
i32 -1, label %23
i32 0, label %28
i32 -2, label %59
]
23: ; preds = %13
%24 = load i32, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @fflush(i32* null)
br label %67
28: ; preds = %13
%29 = load i8*, i8** %3
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %28
br label %34
32: ; preds = %28
%33 = load i8*, i8** %3
br label %34
34: ; preds = %32, %31
%35 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %31 ], [ %33, %32 ]
%36 = load %struct.statfs*, %struct.statfs** %4
%37 = getelementptr inbounds %struct.statfs, %struct.statfs* %36, i32 0, i32 5
%38 = load i32, i32* %37
%39 = load %struct.statfs*, %struct.statfs** %4
%40 = getelementptr inbounds %struct.statfs, %struct.statfs* %39, i32 0, i32 4
%41 = load i32, i32* %40
%42 = load %struct.statfs*, %struct.statfs** %4
%43 = getelementptr inbounds %struct.statfs, %struct.statfs* %42, i32 0, i32 3
%44 = load i32, i32* %43
%45 = load %struct.statfs*, %struct.statfs** %4
%46 = getelementptr inbounds %struct.statfs, %struct.statfs* %45, i32 0, i32 2
%47 = load i32, i32* %46
%48 = load %struct.statfs*, %struct.statfs** %4
%49 = getelementptr inbounds %struct.statfs, %struct.statfs* %48, i32 0, i32 1
%50 = load i32, i32* %49
%51 = load %struct.statfs*, %struct.statfs** %4
%52 = getelementptr inbounds %struct.statfs, %struct.statfs* %51, i32 0, i32 0
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.4, i64 0, i64 0), i8* %35, i32 %38, i32 %41, i32 %44, i32 %47, i32 %50, i32 %53)
%55 = load i32, i32* %5
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%58 = call i32 @fflush(i32* null)
br label %67
59: ; preds = %13
%60 = load i32, i32* %5
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = call i32 @fflush(i32* null)
br label %67
63: ; preds = %13
%64 = load i32, i32* %7
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %64)
%66 = call i32 @fflush(i32* null)
br label %67
67: ; preds = %63, %59, %34, %23
%68 = load i32, i32* %6
store i32 %68, i32* @errno
%69 = load i32, i32* %5
ret i32 %69
}

LLVM IR (-O2):
%struct.statfs = type { i32, i32, i32, i32, i32, i32 }
@.str = [19 x i8] c"statfs(): path=%s\0A\00"
@.str.1 = [7 x i8] c"(null)\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.4 = [133 x i8] c"\09\09Path: %s\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.5 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.6 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
@str.7 = [19 x i8] c"\09Succeeded Phase 1\00"
define i32 @statfs_test(i8* %0, %struct.statfs* %1) {
%3 = icmp eq i8* %0, null
%4 = select i1 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = tail call i32 @fflush(i32* null)
%7 = tail call i32 @statfs(i8* %0, %struct.statfs* %1)
%8 = tail call i32 @handle_zng(i32 %7)
%9 = load i32, i32* @errno
switch i32 %8, label %31 [
i32 -1, label %10
i32 0, label %13
i32 -2, label %29
]
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
br label %33
13: ; preds = %2
%14 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 5
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 3
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 2
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.statfs, %struct.statfs* %1, i64 0, i32 0
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([133 x i8], [133 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 %15, i32 %17, i32 %19, i32 %21, i32 %23, i32 %25)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
br label %33
29: ; preds = %2
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i32 %7)
br label %33
31: ; preds = %2
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %8)
br label %33
33: ; preds = %31, %29, %13, %10
%34 = tail call i32 @fflush(i32* null)
store i32 %9, i32* @errno
ret i32 %7
}