#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 dqblk {
  scalar_t__ dqb_itime;
  scalar_t__ dqb_ihardlimit;
  scalar_t__ dqb_isoftlimit;
  scalar_t__ dqb_curinodes;
  scalar_t__ dqb_btime;
  scalar_t__ dqb_bhardlimit;
  scalar_t__ dqb_bsoftlimit;
  scalar_t__ dqb_curspace;
};
typedef int /*<<< orphan*/ quota_info;
typedef int /*<<< orphan*/ caddr_t;

/* Variables and functions */
int /*<<< orphan*/ QCMD(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ Q_GETQUOTA;
int /*<<< orphan*/ USRQUOTA;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memset(struct dqblk *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_quotactl_error(char *);
int /*<<< orphan*/ printf(char *, unsigned long long, ...);
scalar_t__ quotactl(int /*<<< orphan*/, char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int print_quota_usage(const char *filesystem, int uid) {
  assert(NULL != filesystem);
  char emsg[1024];
  struct dqblk quota_info;
  memset(&quota_info, 0, sizeof(quota_info));
  if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), filesystem, uid,
               (caddr_t)&quota_info) < 0) {
    sprintf(emsg, "Failed retrieving quota for uid=%d", uid);
    print_quotactl_error(emsg);
    return -1;
  }
  printf("%d ", uid);
  printf("%llu %llu %llu %llu ",
         (long long unsigned int)quota_info.dqb_curspace,
         (long long unsigned int)quota_info.dqb_bsoftlimit,
         (long long unsigned int)quota_info.dqb_bhardlimit,
         (long long unsigned int)quota_info.dqb_btime);
  printf("%llu %llu %llu %llu\n",
         (long long unsigned int)quota_info.dqb_curinodes,
         (long long unsigned int)quota_info.dqb_isoftlimit,
         (long long unsigned int)quota_info.dqb_ihardlimit,
         (long long unsigned int)quota_info.dqb_itime);
  return 0;
}


x86 assembly (clang, -O0):
<print_quota_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x460(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
call   1080 <QCMD@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x460(%rbp),%rax
mov    %eax,%ecx
call   1030 <quotactl@plt>
cmp    $0x0,%rax
jge    120e <print_quota_usage+0x9e>
lea    -0x420(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe0f(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1060 <print_quotactl_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127b <print_quota_usage+0x10b>
movslq -0x14(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x428(%rbp),%rsi
mov    -0x430(%rbp),%rdx
mov    -0x438(%rbp),%rcx
mov    -0x440(%rbp),%r8
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x448(%rbp),%rsi
mov    -0x450(%rbp),%rdx
mov    -0x458(%rbp),%rcx
mov    -0x460(%rbp),%r8
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_quota_usage>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x448,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1070 <assert@plt>
mov    %rsp,%r15
xor    %r14d,%r14d
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    0x2e23(%rip),%rax
mov    (%rax),%esi
call   1080 <QCMD@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r15d,%ecx
call   1030 <quotactl@plt>
test   %rax,%rax
js     1226 <print_quota_usage+0xb6>
movslq %ebp,%rsi
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%rsi
mov    0x30(%rsp),%rdx
mov    0x20(%rsp),%r8
mov    0x28(%rsp),%rcx
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    (%rsp),%r8
mov    0x8(%rsp),%rcx
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    124a <print_quota_usage+0xda>
lea    0xdd3(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <print_quotactl_error@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x448,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dqblk = type { i64, i64, i64, i64, i64, i64, i64, i64 }
@Q_GETQUOTA = global i32 0
@USRQUOTA = global i32 0
@.str = [35 x i8] c"Failed retrieving quota for uid=%d\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [21 x i8] c"%llu %llu %llu %llu \00"
@.str.3 = [21 x i8] c"%llu %llu %llu %llu\0A\00"
define i32 @print_quota_usage(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca %struct.dqblk
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* null, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @memset(%struct.dqblk* %7, i32 0, i32 64)
%13 = load i32, i32* @Q_GETQUOTA
%14 = load i32, i32* @USRQUOTA
%15 = call i32 @QCMD(i32 %13, i32 %14)
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = ptrtoint %struct.dqblk* %7 to i32
%19 = call i64 @quotactl(i32 %15, i8* %16, i32 %17, i32 %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %2
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %5
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%26 = call i32 @print_quotactl_error(i8* %25)
store i32 -1, i32* %3
br label %49
27: ; preds = %2
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %29)
%31 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 7
%32 = load i64, i64* %31
%33 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 6
%34 = load i64, i64* %33
%35 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 5
%36 = load i64, i64* %35
%37 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 4
%38 = load i64, i64* %37
%39 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %32, i64 %34, i64 %36, i64 %38)
%40 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 3
%41 = load i64, i64* %40
%42 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 2
%43 = load i64, i64* %42
%44 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 1
%45 = load i64, i64* %44
%46 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %7, i32 0, i32 0
%47 = load i64, i64* %46
%48 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %41, i64 %43, i64 %45, i64 %47)
store i32 0, i32* %3
br label %49
49: ; preds = %27, %21
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
%struct.dqblk = type { i64, i64, i64, i64, i64, i64, i64, i64 }
@Q_GETQUOTA = global i32 0
@USRQUOTA = global i32 0
@.str = [35 x i8] c"Failed retrieving quota for uid=%d\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [21 x i8] c"%llu %llu %llu %llu \00"
@.str.3 = [21 x i8] c"%llu %llu %llu %llu\0A\00"
define i32 @print_quota_usage(i8* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.dqblk
%5 = icmp ne i8* %0, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = bitcast %struct.dqblk* %4 to i8*
%10 = call i32 @memset(%struct.dqblk* %4, i32 0, i32 64)
%11 = load i32, i32* @Q_GETQUOTA
%12 = load i32, i32* @USRQUOTA
%13 = call i32 @QCMD(i32 %11, i32 %12)
%14 = ptrtoint %struct.dqblk* %4 to i64
%15 = trunc i64 %14 to i32
%16 = call i64 @quotactl(i32 %13, i8* %0, i32 %1, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %1)
%20 = call i32 @print_quotactl_error(i8* %8)
br label %42
21: ; preds = %2
%22 = sext i32 %1 to i64
%23 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %22)
%24 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 7
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 6
%27 = load i64, i64* %26
%28 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 5
%29 = load i64, i64* %28
%30 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 4
%31 = load i64, i64* %30
%32 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %25, i64 %27, i64 %29, i64 %31)
%33 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 3
%34 = load i64, i64* %33
%35 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 2
%36 = load i64, i64* %35
%37 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 1
%38 = load i64, i64* %37
%39 = getelementptr inbounds %struct.dqblk, %struct.dqblk* %4, i64 0, i32 0
%40 = load i64, i64* %39
%41 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %34, i64 %36, i64 %38, i64 %40)
br label %42
42: ; preds = %21, %18
%43 = phi i32 [ -1, %18 ], [ 0, %21 ]
ret i32 %43
}