#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 ina219State {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ina219_destroyPowerMonitorState(struct ina219State *);
struct ina219State *ina219_initPowerMonitor(int, int);
int /*<<< orphan*/ ina219_initateVoltageReadingSingle(struct ina219State *);
int ina219_isReadingReady(struct ina219State *);
int ina219_isReadingValid(struct ina219State *);
int /*<<< orphan*/ ina219_powerOff(struct ina219State *);
int /*<<< orphan*/ ina219_powerOn(struct ina219State *);
double ina219_readBusVoltageSingle(struct ina219State *);
double ina219_readCurrentSingle(struct ina219State *);
double ina219_readPowerSingle(struct ina219State *);
double ina219_readShuntVoltageSingle(struct ina219State *);
int /*<<< orphan*/ ina219_setCalibrationRegister(struct ina219State *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ sleep(int);
void ina219_testMeasurement() {
  struct ina219State *ina219 = ina219_initPowerMonitor(1, 0x44);
  ina219_powerOff(ina219);
  sleep(1);
  ina219_powerOn(ina219);
  sleep(1);
  ina219_setCalibrationRegister(ina219);
  ina219_initateVoltageReadingSingle(ina219);
  printf("Is ready? %d\n", ina219_isReadingReady(ina219));
  sleep(1);
  printf("Is ready? %d\n", ina219_isReadingReady(ina219));
  printf("Is valid? %d\n", ina219_isReadingValid(ina219));
  printf("Bus voltage: %f V\n", ina219_readBusVoltageSingle(ina219));
  printf("Shunt voltage: %f mV\n", ina219_readShuntVoltageSingle(ina219));
  printf("Current: %f mA\n", ina219_readCurrentSingle(ina219));
  printf("Power: %f mW\n", ina219_readPowerSingle(ina219));
  ina219_destroyPowerMonitorState(ina219);
}


x86 assembly (clang, -O0):
<ina219_testMeasurement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
mov    $0x44,%esi
call   10a0 <ina219_initPowerMonitor@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1100 <ina219_powerOff@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    -0x8(%rbp),%rdi
call   10d0 <ina219_powerOn@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    -0x8(%rbp),%rdi
call   10b0 <ina219_setCalibrationRegister@plt>
mov    -0x8(%rbp),%rdi
call   10c0 <ina219_initateVoltageReadingSingle@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ina219_isReadingReady@plt>
cvtsi2sd %eax,%xmm0
lea    0xdb9(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ina219_isReadingReady@plt>
cvtsi2sd %eax,%xmm0
lea    0xd96(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   10f0 <ina219_isReadingValid@plt>
cvtsi2sd %eax,%xmm0
lea    0xd8b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <ina219_readBusVoltageSingle@plt>
lea    0xd84(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1090 <ina219_readShuntVoltageSingle@plt>
lea    0xd82(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <ina219_readCurrentSingle@plt>
lea    0xd83(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ina219_readPowerSingle@plt>
lea    0xd7e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <ina219_destroyPowerMonitorState@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ina219_testMeasurement>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x44,%esi
call   10a0 <ina219_initPowerMonitor@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1100 <ina219_powerOff@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    %rbx,%rdi
call   10d0 <ina219_powerOn@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    %rbx,%rdi
call   10b0 <ina219_setCalibrationRegister@plt>
mov    %rbx,%rdi
call   10c0 <ina219_initateVoltageReadingSingle@plt>
mov    %rbx,%rdi
call   1040 <ina219_isReadingReady@plt>
cvtsi2sd %eax,%xmm0
lea    0xdc3(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    %rbx,%rdi
call   1040 <ina219_isReadingReady@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   10f0 <ina219_isReadingValid@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xd92(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <ina219_readBusVoltageSingle@plt>
lea    0xd8c(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1090 <ina219_readShuntVoltageSingle@plt>
lea    0xd8b(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <ina219_readCurrentSingle@plt>
lea    0xd8d(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <ina219_readPowerSingle@plt>
lea    0xd89(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <ina219_destroyPowerMonitorState@plt>

LLVM IR (-O0):
%struct.ina219State = type { i32 }
@.str = [14 x i8] c"Is ready? %d\0A\00"
@.str.1 = [14 x i8] c"Is valid? %d\0A\00"
@.str.2 = [19 x i8] c"Bus voltage: %f V\0A\00"
@.str.3 = [22 x i8] c"Shunt voltage: %f mV\0A\00"
@.str.4 = [16 x i8] c"Current: %f mA\0A\00"
@.str.5 = [14 x i8] c"Power: %f mW\0A\00"
define void @ina219_testMeasurement() {
%1 = alloca %struct.ina219State*
%2 = call %struct.ina219State* @ina219_initPowerMonitor(i32 1, i32 68)
store %struct.ina219State* %2, %struct.ina219State** %1
%3 = load %struct.ina219State*, %struct.ina219State** %1
%4 = call i32 @ina219_powerOff(%struct.ina219State* %3)
%5 = call i32 @sleep(i32 1)
%6 = load %struct.ina219State*, %struct.ina219State** %1
%7 = call i32 @ina219_powerOn(%struct.ina219State* %6)
%8 = call i32 @sleep(i32 1)
%9 = load %struct.ina219State*, %struct.ina219State** %1
%10 = call i32 @ina219_setCalibrationRegister(%struct.ina219State* %9)
%11 = load %struct.ina219State*, %struct.ina219State** %1
%12 = call i32 @ina219_initateVoltageReadingSingle(%struct.ina219State* %11)
%13 = load %struct.ina219State*, %struct.ina219State** %1
%14 = call i32 @ina219_isReadingReady(%struct.ina219State* %13)
%15 = sitofp i32 %14 to double
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %15)
%17 = call i32 @sleep(i32 1)
%18 = load %struct.ina219State*, %struct.ina219State** %1
%19 = call i32 @ina219_isReadingReady(%struct.ina219State* %18)
%20 = sitofp i32 %19 to double
%21 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %20)
%22 = load %struct.ina219State*, %struct.ina219State** %1
%23 = call i32 @ina219_isReadingValid(%struct.ina219State* %22)
%24 = sitofp i32 %23 to double
%25 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %24)
%26 = load %struct.ina219State*, %struct.ina219State** %1
%27 = call double @ina219_readBusVoltageSingle(%struct.ina219State* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = load %struct.ina219State*, %struct.ina219State** %1
%30 = call double @ina219_readShuntVoltageSingle(%struct.ina219State* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = load %struct.ina219State*, %struct.ina219State** %1
%33 = call double @ina219_readCurrentSingle(%struct.ina219State* %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %33)
%35 = load %struct.ina219State*, %struct.ina219State** %1
%36 = call double @ina219_readPowerSingle(%struct.ina219State* %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %36)
%38 = load %struct.ina219State*, %struct.ina219State** %1
%39 = call i32 @ina219_destroyPowerMonitorState(%struct.ina219State* %38)
ret void
}

LLVM IR (-O2):
%struct.ina219State = type { i32 }
@.str = [14 x i8] c"Is ready? %d\0A\00"
@.str.1 = [14 x i8] c"Is valid? %d\0A\00"
@.str.2 = [19 x i8] c"Bus voltage: %f V\0A\00"
@.str.3 = [22 x i8] c"Shunt voltage: %f mV\0A\00"
@.str.4 = [16 x i8] c"Current: %f mA\0A\00"
@.str.5 = [14 x i8] c"Power: %f mW\0A\00"
define void @ina219_testMeasurement() {
%1 = tail call %struct.ina219State* @ina219_initPowerMonitor(i32 1, i32 68)
%2 = tail call i32 @ina219_powerOff(%struct.ina219State* %1)
%3 = tail call i32 @sleep(i32 1)
%4 = tail call i32 @ina219_powerOn(%struct.ina219State* %1)
%5 = tail call i32 @sleep(i32 1)
%6 = tail call i32 @ina219_setCalibrationRegister(%struct.ina219State* %1)
%7 = tail call i32 @ina219_initateVoltageReadingSingle(%struct.ina219State* %1)
%8 = tail call i32 @ina219_isReadingReady(%struct.ina219State* %1)
%9 = sitofp i32 %8 to double
%10 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %9)
%11 = tail call i32 @sleep(i32 1)
%12 = tail call i32 @ina219_isReadingReady(%struct.ina219State* %1)
%13 = sitofp i32 %12 to double
%14 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %13)
%15 = tail call i32 @ina219_isReadingValid(%struct.ina219State* %1)
%16 = sitofp i32 %15 to double
%17 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %16)
%18 = tail call double @ina219_readBusVoltageSingle(%struct.ina219State* %1)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %18)
%20 = tail call double @ina219_readShuntVoltageSingle(%struct.ina219State* %1)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %20)
%22 = tail call double @ina219_readCurrentSingle(%struct.ina219State* %1)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %22)
%24 = tail call double @ina219_readPowerSingle(%struct.ina219State* %1)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %24)
%26 = tail call i32 @ina219_destroyPowerMonitorState(%struct.ina219State* %1)
ret void
}