// File: /workspace/github_cpp_makefile_star2_O3/Juve45[P]batstat/main.cpp
// Function: getBatteryInfo()
BatteryStatus getBatteryInfo() {
	float currentPower, currentEnergy;
	if(checkfile(powerPath + "_now")) { // Unit is Watts
		ifstream powNow(powerPath + "_now");
		ifstream enNow(energyPath + "_now");
		powNow >> currentPower;
		enNow >> currentEnergy;
	} else { 
			ifstream currNow(currentPath + "_now");
			ifstream chgNow(chargePath + "_now");
			
			currNow >> currentPower;
			chgNow >> currentEnergy;
		/*if(checkfile(voltagePath + "_now")) { // Unit is Watts
			float voltage;
			ifstream volNow(voltagePath + "_now");
			volNow >> voltage;
			if(voltage == 0) voltage = 1;
			currentPower *= voltage / 1000000;
			currentEnergy *= voltage / 1000000;
		} else { // Unit is Amps, no voltage to be subtracted 
		}*/
		// TODO: fix voltage bug -> create class which handles energy and power readings 
		// in every scenario.
	} 
	return BatteryStatus(currentPower, currentEnergy);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x440, %rsp            # imm = 0x440
leaq -0x438(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x15761(%rip), %rsi     # 0x193e8
movq 0x15762(%rip), %rdx     # 0x193f0
addq %rsi, %rdx
leaq -0x448(%rbp), %rbx
movq %rbx, %rdi
callq 0x51f6
leaq 0xc98b(%rip), %rsi      # 0x10632
movq %rbx, %rdi
callq 0x3560
movq -0x448(%rbp), %rdi
leaq 0xd834(%rip), %rsi      # 0x114f1
callq 0x33b0
movq %rax, %rbx
testq %rax, %rax
je 0x3cd2
movq %rbx, %rdi
callq 0x3310
movq -0x448(%rbp), %rdi
cmpq %r14, %rdi
je 0x3ce3
callq 0x32f0
leaq -0x230(%rbp), %r14
testq %rbx, %rbx
je 0x3dc9
movq %r14, -0x10(%r14)
movq 0x156ea(%rip), %rsi     # 0x193e8
movq 0x156eb(%rip), %rdx     # 0x193f0
addq %rsi, %rdx
leaq -0x240(%rbp), %rbx
movq %rbx, %rdi
callq 0x51f6
leaq 0xc914(%rip), %rsi      # 0x10632
movq %rbx, %rdi
callq 0x3560
leaq -0x448(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movl $0x8, %edx
callq 0x34a0
movq -0x240(%rbp), %rdi
cmpq %r14, %rdi
je 0x3d4f
callq 0x32f0
leaq -0x28(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x1566a(%rip), %rsi     # 0x193c8
movq 0x1566b(%rip), %rdx     # 0x193d0
addq %rsi, %rdx
leaq -0x38(%rbp), %rdi
callq 0x51f6
leaq 0xc8ba(%rip), %rsi      # 0x10632
leaq -0x38(%rbp), %rdi
callq 0x3560
leaq -0x240(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movl $0x8, %edx
callq 0x34a0
movq -0x38(%rbp), %rdi
cmpq %r14, %rdi
je 0x3da4
callq 0x32f0
leaq -0x448(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3590
leaq -0x240(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x3590
jmp 0x3e9a
movq %r14, -0x10(%r14)
movq 0x15674(%rip), %rsi     # 0x19448
movq 0x15675(%rip), %rdx     # 0x19450
addq %rsi, %rdx
leaq -0x240(%rbp), %rbx
movq %rbx, %rdi
callq 0x51f6
leaq 0xc83e(%rip), %rsi      # 0x10632
movq %rbx, %rdi
callq 0x3560
leaq -0x448(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movl $0x8, %edx
callq 0x34a0
movq -0x240(%rbp), %rdi
cmpq %r14, %rdi
je 0x3e25
callq 0x32f0
leaq -0x28(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x155d4(%rip), %rsi     # 0x19408
movq 0x155d5(%rip), %rdx     # 0x19410
addq %rsi, %rdx
leaq -0x38(%rbp), %rdi
callq 0x51f6
leaq 0xc7e4(%rip), %rsi      # 0x10632
leaq -0x38(%rbp), %rdi
callq 0x3560
leaq -0x240(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movl $0x8, %edx
callq 0x34a0
movq -0x38(%rbp), %rdi
cmpq %r14, %rdi
je 0x3e7a
callq 0x32f0
leaq -0x448(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3590
leaq -0x240(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x3590
leaq -0x240(%rbp), %rdi
callq 0x30c0
leaq -0x448(%rbp), %rdi
callq 0x30c0
movss -0x14(%rbp), %xmm1
movss -0x18(%rbp), %xmm0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
addq $0x440, %rsp            # imm = 0x440
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x3ed7
jmp 0x3ed7
jmp 0x3eea
jmp 0x3ef1
jmp 0x3ef1
jmp 0x3ed7
movq %rax, %rbx
movq -0x38(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f24
callq 0x32f0
jmp 0x3f24
movq %rax, %rbx
jmp 0x3f24
jmp 0x3ef1
movq %rax, %rbx
movq -0x240(%rbp), %rdi
jmp 0x3f09
jmp 0x3f15
movq %rax, %rbx
movq -0x448(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f30
callq 0x32f0
jmp 0x3f30
movq %rax, %rbx
leaq -0x240(%rbp), %rdi
callq 0x30c0
leaq -0x448(%rbp), %rdi
callq 0x30c0
movq %rbx, %rdi
callq 0x3530