#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 */
double analog_to_digital();
int /*<<< orphan*/ analog_to_digital_setup();
int /*<<< orphan*/ map_ports();
int /*<<< orphan*/ output_to_stm(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ request_access_permission();
int /*<<< orphan*/ scale_0_255(double);
int main(void) {
  double converted_A_D_voltage = 0.0;
  request_access_permission();
  map_ports();
  analog_to_digital_setup();
  while (1) {
    converted_A_D_voltage = analog_to_digital();
    if (converted_A_D_voltage > 5.0 || converted_A_D_voltage < -5.0) {
      printf("Voltage has gone over/under +/-5V\n");
    }
    output_to_stm(scale_0_255(converted_A_D_voltage));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1090 <request_access_permission@plt>
mov    $0x0,%al
call   1070 <map_ports@plt>
mov    $0x0,%al
call   1050 <analog_to_digital_setup@plt>
mov    $0x0,%al
call   1080 <analog_to_digital@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11d2 <main+0x62>
movsd  0xe41(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11de <main+0x6e>
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
call   1060 <scale_0_255@plt>
mov    %eax,%edi
call   1030 <output_to_stm@plt>
jmp    119c <main+0x2c>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1090 <request_access_permission@plt>
xor    %eax,%eax
call   1070 <map_ports@plt>
xor    %eax,%eax
call   1050 <analog_to_digital_setup@plt>
lea    0xe7f(%rip),%rbx
jmp    11c4 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
movsd  %xmm1,0x8(%rsp)
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
call   1060 <scale_0_255@plt>
mov    %eax,%edi
call   1040 <output_to_stm@plt>
xor    %eax,%eax
call   1080 <analog_to_digital@plt>
movapd %xmm0,%xmm1
ucomisd 0xe29(%rip),%xmm0
ja     11a0 <main+0x30>
movsd  0xe27(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b4 <main+0x44>
jmp    11a0 <main+0x30>

LLVM IR (-O0):
@.str = [35 x i8] c"Voltage has gone over/under +/-5V\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
%3 = call i32 (...) @request_access_permission()
%4 = call i32 (...) @map_ports()
%5 = call i32 (...) @analog_to_digital_setup()
br label %6
6: ; preds = %0, %15
%7 = call double (...) @analog_to_digital()
store double %7, double* %2
%8 = load double, double* %2
%9 = fcmp ogt double %8, 5.000000e+00
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load double, double* %2
%12 = fcmp olt double %11, -5.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %10, %6
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = load double, double* %2
%17 = call i32 @scale_0_255(double %16)
%18 = call i32 @output_to_stm(i32 %17)
br label %6
}

LLVM IR (-O2):
@str = [34 x i8] c"Voltage has gone over/under +/-5V\00"
define i32 @main() {
%1 = tail call i32 (...) @request_access_permission()
%2 = tail call i32 (...) @map_ports()
%3 = tail call i32 (...) @analog_to_digital_setup()
br label %4
4: ; preds = %11, %0
%5 = tail call double (...) @analog_to_digital()
%6 = fcmp ogt double %5, 5.000000e+00
%7 = fcmp olt double %5, -5.000000e+00
%8 = or i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %4, %9
%12 = tail call i32 @scale_0_255(double %5)
%13 = tail call i32 @output_to_stm(i32 %12)
br label %4
}