#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 statvfs {
  int /*<<< orphan*/ f_blocks;
  int /*<<< orphan*/ f_bsize;
};

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int statvfs(char *, struct statvfs *);
void getfstat1(void) {
  int ret;
  struct statvfs sbuf;
  ret = statvfs("/workspace", &sbuf);
  if (ret < 0) {
    perror("get fail:");
    return;
  }
  printf("fs size %ld blocks %ld \n", sbuf.f_bsize, sbuf.f_blocks);
}


x86 assembly (clang, -O0):
<getfstat1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <statvfs@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1166 <getfstat1+0x36>
lea    0xeaf(%rip),%rdi
call   1050 <perror@plt>
jmp    1178 <getfstat1+0x48>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getfstat1>:
push   %rax
lea    0xec8(%rip),%rdi
mov    %rsp,%rsi
call   1040 <statvfs@plt>
test   %eax,%eax
js     1158 <getfstat1+0x28>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
lea    0xec3(%rip),%rdi
pop    %rax
jmp    1030 <printf@plt>
lea    0xeac(%rip),%rdi
pop    %rax
jmp    1050 <perror@plt>

LLVM IR (-O0):
%struct.statvfs = type { i32, i32 }
@.str = [11 x i8] c"/workspace\00"
@.str.1 = [10 x i8] c"get fail:\00"
@.str.2 = [25 x i8] c"fs size %ld blocks %ld \0A\00"
define void @getfstat1() {
%1 = alloca i32
%2 = alloca %struct.statvfs
%3 = call i32 @statvfs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %struct.statvfs* %2)
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %14
8: ; preds = %0
%9 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i32 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %2, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %12)
br label %14
14: ; preds = %8, %6
ret void
}

LLVM IR (-O2):
%struct.statvfs = type { i32, i32 }
@.str = [11 x i8] c"/workspace\00"
@.str.1 = [10 x i8] c"get fail:\00"
@.str.2 = [25 x i8] c"fs size %ld blocks %ld \0A\00"
define void @getfstat1() {
%1 = alloca %struct.statvfs
%2 = bitcast %struct.statvfs* %1 to i8*
%3 = call i32 @statvfs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %struct.statvfs* %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %13
7: ; preds = %0
%8 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %11)
br label %13
13: ; preds = %7, %5
ret void
}