// File: 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
subq $0x900, %rsp            # imm = 0x900
leaq 0x378b6(%rip), %rsi     # 0x3c468
leaq 0x22ff9(%rip), %rdx     # 0x27bb2
leaq -0x30(%rbp), %rdi
movq %rdi, -0x8f0(%rbp)
callq 0x61e0
movq -0x8f0(%rbp), %rdi
callq 0x6190
movb %al, -0x8e1(%rbp)
jmp 0x4bdd
leaq -0x30(%rbp), %rdi
callq 0x46a8
movb -0x8e1(%rbp), %al
testb $0x1, %al
jne 0x4bf5
jmp 0x4d47
leaq 0x3786c(%rip), %rsi     # 0x3c468
leaq 0x22faf(%rip), %rdx     # 0x27bb2
leaq -0x268(%rbp), %rdi
movq %rdi, -0x8f8(%rbp)
callq 0x61e0
movq -0x8f8(%rbp), %rsi
leaq -0x248(%rbp), %rdi
movl $0x8, %edx
callq 0x4580
jmp 0x4c30
leaq -0x268(%rbp), %rdi
callq 0x46a8
leaq 0x37805(%rip), %rsi     # 0x3c448
leaq 0x22f68(%rip), %rdx     # 0x27bb2
leaq -0x490(%rbp), %rdi
callq 0x61e0
jmp 0x4c58
leaq -0x470(%rbp), %rdi
leaq -0x490(%rbp), %rsi
movl $0x8, %edx
callq 0x4580
jmp 0x4c72
leaq -0x490(%rbp), %rdi
callq 0x46a8
leaq -0x248(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0x40d0
jmp 0x4c90
leaq -0x470(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x40d0
jmp 0x4ca2
leaq -0x470(%rbp), %rdi
callq 0x40f0
leaq -0x248(%rbp), %rdi
callq 0x40f0
jmp 0x4e76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x46a8
jmp 0x4e97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x46a8
jmp 0x4e97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4d36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x490(%rbp), %rdi
callq 0x46a8
jmp 0x4d36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x470(%rbp), %rdi
callq 0x40f0
leaq -0x248(%rbp), %rdi
callq 0x40f0
jmp 0x4e97
leaq 0x3777a(%rip), %rsi     # 0x3c4c8
leaq 0x22e5d(%rip), %rdx     # 0x27bb2
leaq -0x6b8(%rbp), %rdi
movq %rdi, -0x900(%rbp)
callq 0x61e0
movq -0x900(%rbp), %rsi
leaq -0x698(%rbp), %rdi
movl $0x8, %edx
callq 0x4580
jmp 0x4d82
leaq -0x6b8(%rbp), %rdi
callq 0x46a8
leaq 0x376f3(%rip), %rsi     # 0x3c488
leaq 0x22e16(%rip), %rdx     # 0x27bb2
leaq -0x8e0(%rbp), %rdi
callq 0x61e0
jmp 0x4daa
leaq -0x8c0(%rbp), %rdi
leaq -0x8e0(%rbp), %rsi
movl $0x8, %edx
callq 0x4580
jmp 0x4dc4
leaq -0x8e0(%rbp), %rdi
callq 0x46a8
leaq -0x698(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0x40d0
jmp 0x4de2
leaq -0x8c0(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x40d0
jmp 0x4df4
leaq -0x8c0(%rbp), %rdi
callq 0x40f0
leaq -0x698(%rbp), %rdi
callq 0x40f0
jmp 0x4e76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x6b8(%rbp), %rdi
callq 0x46a8
jmp 0x4e97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4e68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x8e0(%rbp), %rdi
callq 0x46a8
jmp 0x4e68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x40f0
leaq -0x698(%rbp), %rdi
callq 0x40f0
jmp 0x4e97
movss -0xc(%rbp), %xmm0
movss -0x10(%rbp), %xmm1
leaq -0x8(%rbp), %rdi
callq 0x6260
movsd -0x8(%rbp), %xmm0
addq $0x900, %rsp            # imm = 0x900
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x4630