#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 */
int /*<<< orphan*/ pi_sleep(int);
int read_byte();
int /*<<< orphan*/ write_block(int, int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/);
float volt(void) {
  int v[2];
  float voltage;
  write_block(118, 0, 0, 0);
  pi_sleep(100);
  v[0] = read_byte();
  v[1] = read_byte();
  voltage = v[0] * 256 + v[1];
  voltage = (5.0 * voltage / 1024) / .4;
  return voltage;
}


x86 assembly (clang, -O0):
<volt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x76,%edi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1040 <write_block@plt>
mov    $0x64,%edi
call   1050 <pi_sleep@plt>
mov    $0x0,%al
call   1030 <read_byte@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <read_byte@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
add    -0x4(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe87(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe73(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe5f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<volt>:
push   %rbx
mov    $0x76,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <write_block@plt>
mov    $0x64,%edi
call   1050 <pi_sleep@plt>
xor    %eax,%eax
call   1030 <read_byte@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <read_byte@plt>
shl    $0x8,%ebx
add    %eax,%ebx
cvtsi2ss %ebx,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe90(%rip),%xmm0
mulsd  0xe90(%rip),%xmm0
divsd  0xe90(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define float @volt() {
%1 = alloca [2 x i32]
%2 = alloca float
%3 = call i32 @write_block(i32 118, i32 0, i32 0, i32 0)
%4 = call i32 @pi_sleep(i32 100)
%5 = call i32 (...) @read_byte()
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 %5, i32* %6
%7 = call i32 (...) @read_byte()
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
store i32 %7, i32* %8
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 256
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%13 = load i32, i32* %12
%14 = add nsw i32 %11, %13
%15 = sitofp i32 %14 to float
store float %15, float* %2
%16 = load float, float* %2
%17 = fpext float %16 to double
%18 = fmul double 5.000000e+00, %17
%19 = fdiv double %18, 1.024000e+03
%20 = fdiv double %19, 4.000000e-01
%21 = fptrunc double %20 to float
store float %21, float* %2
%22 = load float, float* %2
ret float %22
}

LLVM IR (-O2):
define float @volt() {
%1 = tail call i32 @write_block(i32 118, i32 0, i32 0, i32 0)
%2 = tail call i32 @pi_sleep(i32 100)
%3 = tail call i32 (...) @read_byte()
%4 = tail call i32 (...) @read_byte()
%5 = shl nsw i32 %3, 8
%6 = add nsw i32 %5, %4
%7 = sitofp i32 %6 to float
%8 = fpext float %7 to double
%9 = fmul double %8, 5.000000e+00
%10 = fmul double %9, 0x3F50000000000000
%11 = fdiv double %10, 4.000000e-01
%12 = fptrunc double %11 to float
ret float %12
}