#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 */

/* Variables and functions */
float readFloat(char *);
int getBatRemainingMins() {
  float energy_now = readFloat("/sys/class/power_supply/BAT0/energy_now");
  float power_now = readFloat("/sys/class/power_supply/BAT0/power_now");
  if (power_now == 0) {
    return 0;
  }
  return 60 * energy_now / power_now;
}


x86 assembly (clang, -O0):
<getBatRemainingMins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee5(%rip),%rdi
call   1030 <readFloat@plt>
movss  %xmm0,-0x8(%rbp)
lea    0xefc(%rip),%rdi
call   1030 <readFloat@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    115d <getBatRemainingMins+0x4d>
jp     115d <getBatRemainingMins+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    1176 <getBatRemainingMins+0x66>
movss  0xe9b(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBatRemainingMins>:
push   %rax
lea    0xeec(%rip),%rdi
call   1030 <readFloat@plt>
movss  %xmm0,0x4(%rsp)
lea    0xf02(%rip),%rdi
call   1030 <readFloat@plt>
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    113d <getBatRemainingMins+0x2d>
jp     113d <getBatRemainingMins+0x2d>
pop    %rcx
ret
movss  0x4(%rsp),%xmm1
mulss  0xeb5(%rip),%xmm1
divss  %xmm0,%xmm1
cvttss2si %xmm1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"/sys/class/power_supply/BAT0/energy_now\00"
@.str.1 = [39 x i8] c"/sys/class/power_supply/BAT0/power_now\00"
define i32 @getBatRemainingMins() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = call float @readFloat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store float %4, float* %2
%5 = call float @readFloat(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
store float %5, float* %3
%6 = load float, float* %3
%7 = fcmp oeq float %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 0, i32* %1
br label %15
9: ; preds = %0
%10 = load float, float* %2
%11 = fmul float 6.000000e+01, %10
%12 = load float, float* %3
%13 = fdiv float %11, %12
%14 = fptosi float %13 to i32
store i32 %14, i32* %1
br label %15
15: ; preds = %9, %8
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [40 x i8] c"/sys/class/power_supply/BAT0/energy_now\00"
@.str.1 = [39 x i8] c"/sys/class/power_supply/BAT0/power_now\00"
define i32 @getBatRemainingMins() {
%1 = tail call float @readFloat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%2 = tail call float @readFloat(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%3 = fcmp oeq float %2, 0.000000e+00
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = fmul float %1, 6.000000e+01
%6 = fdiv float %5, %2
%7 = fptosi float %6 to i32
br label %8
8: ; preds = %0, %4
%9 = phi i32 [ %7, %4 ], [ 0, %0 ]
ret i32 %9
}