#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 {
  double f_bavail;
  double f_blocks;
  double f_bsize;
};
struct nlist {
  int dummy;
};

/* Variables and functions */
scalar_t__ seen_before(struct nlist **, char *);
scalar_t__ statvfs(char *, struct statvfs *);
float device_space(struct nlist **DFhashvector, char *mount, char *device,
                   double *total_size, double *total_free) {
  struct statvfs svfs;
  double blocksize;
  double free;
  double size;
  float pct = 0.0;
  if (seen_before(DFhashvector, device))
    return pct;
  if (statvfs(mount, &svfs)) {
    return pct;
  }
  free = svfs.f_bavail;
  size = svfs.f_blocks;
  blocksize = svfs.f_bsize;
  *total_size += size * blocksize;
  *total_free += free * blocksize;
  pct = size ? ((size - free) / (float)size) * 100 : 0.0;
  return pct;
}


x86 assembly (clang, -O0):
<device_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <seen_before@plt>
cmp    $0x0,%rax
je     116a <device_space+0x4a>
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    125d <device_space+0x13d>
mov    -0x18(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <statvfs@plt>
cmp    $0x0,%rax
je     1190 <device_space+0x70>
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    125d <device_space+0x13d>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1207 <device_space+0xe7>
jp     1207 <device_space+0xe7>
jmp    1238 <device_space+0x118>
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
cvtsd2ss %xmm1,%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  0xdd6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    1245 <device_space+0x125>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    1245 <device_space+0x125>
movsd  -0x70(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<device_space>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rsi,%rbx
mov    %rdx,%rsi
call   1030 <seen_before@plt>
xorps  %xmm0,%xmm0
test   %rax,%rax
jne    11bf <device_space+0x9f>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <statvfs@plt>
test   %rax,%rax
je     1159 <device_space+0x39>
xorps  %xmm0,%xmm0
jmp    11bf <device_space+0x9f>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm4
movsd  0x18(%rsp),%xmm2
movapd %xmm4,%xmm3
mulsd  %xmm2,%xmm3
addsd  (%r15),%xmm3
movsd  %xmm3,(%r15)
mulsd  %xmm1,%xmm2
addsd  (%r14),%xmm2
movsd  %xmm2,(%r14)
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm4
xorps  %xmm0,%xmm0
jne    119a <device_space+0x7a>
jnp    11bf <device_space+0x9f>
xorps  %xmm2,%xmm2
cvtsd2ss %xmm4,%xmm2
subsd  %xmm1,%xmm4
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
divsd  %xmm1,%xmm4
mulsd  0xe48(%rip),%xmm4
xorps  %xmm0,%xmm0
cvtsd2ss %xmm4,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.nlist = type { i32 }
%struct.statvfs = type { double, double, double }
define float @device_space(%struct.nlist** %0, i8* %1, i8* %2, double* %3, double* %4) {
%6 = alloca float
%7 = alloca %struct.nlist**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca double*
%11 = alloca double*
%12 = alloca %struct.statvfs
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca float
store %struct.nlist** %0, %struct.nlist*** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store double* %3, double** %10
store double* %4, double** %11
store float 0.000000e+00, float* %16
%17 = load %struct.nlist**, %struct.nlist*** %7
%18 = load i8*, i8** %9
%19 = call i64 @seen_before(%struct.nlist** %17, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %5
%22 = load float, float* %16
store float %22, float* %6
br label %62
23: ; preds = %5
%24 = load i8*, i8** %8
%25 = call i64 @statvfs(i8* %24, %struct.statvfs* %12)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load float, float* %16
store float %28, float* %6
br label %62
29: ; preds = %23
%30 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %12, i32 0, i32 0
%31 = load double, double* %30
store double %31, double* %14
%32 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %12, i32 0, i32 1
%33 = load double, double* %32
store double %33, double* %15
%34 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %12, i32 0, i32 2
%35 = load double, double* %34
store double %35, double* %13
%36 = load double, double* %15
%37 = load double, double* %13
%38 = load double*, double** %10
%39 = load double, double* %38
%40 = call double @llvm.fmuladd.f64(double %36, double %37, double %39)
store double %40, double* %38
%41 = load double, double* %14
%42 = load double, double* %13
%43 = load double*, double** %11
%44 = load double, double* %43
%45 = call double @llvm.fmuladd.f64(double %41, double %42, double %44)
store double %45, double* %43
%46 = load double, double* %15
%47 = fcmp une double %46, 0.000000e+00
br i1 %47, label %48, label %57
48: ; preds = %29
%49 = load double, double* %15
%50 = load double, double* %14
%51 = fsub double %49, %50
%52 = load double, double* %15
%53 = fptrunc double %52 to float
%54 = fpext float %53 to double
%55 = fdiv double %51, %54
%56 = fmul double %55, 1.000000e+02
br label %58
57: ; preds = %29
br label %58
58: ; preds = %57, %48
%59 = phi double [ %56, %48 ], [ 0.000000e+00, %57 ]
%60 = fptrunc double %59 to float
store float %60, float* %16
%61 = load float, float* %16
store float %61, float* %6
br label %62
62: ; preds = %58, %27, %21
%63 = load float, float* %6
ret float %63
}

LLVM IR (-O2):
%struct.nlist = type { i32 }
%struct.statvfs = type { double, double, double }
define float @device_space(%struct.nlist** %0, i8* %1, i8* %2, double* nocapture %3, double* nocapture %4) {
%6 = alloca %struct.statvfs
%7 = bitcast %struct.statvfs* %6 to i8*
%8 = tail call i64 @seen_before(%struct.nlist** %0, i8* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %5
%11 = call i64 @statvfs(i8* %1, %struct.statvfs* %6)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %32
13: ; preds = %10
%14 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %6, i64 0, i32 0
%15 = load double, double* %14
%16 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %6, i64 0, i32 1
%17 = load double, double* %16
%18 = getelementptr inbounds %struct.statvfs, %struct.statvfs* %6, i64 0, i32 2
%19 = load double, double* %18
%20 = load double, double* %3
%21 = call double @llvm.fmuladd.f64(double %17, double %19, double %20)
store double %21, double* %3
%22 = load double, double* %4
%23 = call double @llvm.fmuladd.f64(double %15, double %19, double %22)
store double %23, double* %4
%24 = fcmp une double %17, 0.000000e+00
br i1 %24, label %25, label %32
25: ; preds = %13
%26 = fsub double %17, %15
%27 = fptrunc double %17 to float
%28 = fpext float %27 to double
%29 = fdiv double %26, %28
%30 = fmul double %29, 1.000000e+02
%31 = fptrunc double %30 to float
br label %32
32: ; preds = %25, %13, %10, %5
%33 = phi float [ 0.000000e+00, %5 ], [ 0.000000e+00, %10 ], [ %31, %25 ], [ 0.000000e+00, %13 ]
ret float %33
}