#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*/ a_d_init();
double analog_to_digital();
int /*<<< orphan*/ map_io_ports();
int /*<<< orphan*/ output_to_stm(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ request_io_access_permission();
int /*<<< orphan*/ scale_converted_signal(double);
int main(void) {
  double converted_signal = 0.0;
  request_io_access_permission();
  map_io_ports();
  a_d_init();
  while (1) {
    converted_signal = analog_to_digital();
    if (converted_signal > 5.0 || converted_signal < -5.0) {
      printf("Voltage has gone over/under +/-5V\n");
    }
    output_to_stm(scale_converted_signal(converted_signal));
  }
  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   1030 <request_io_access_permission@plt>
mov    $0x0,%al
call   1080 <map_io_ports@plt>
mov    $0x0,%al
call   1060 <a_d_init@plt>
mov    $0x0,%al
call   1090 <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   1050 <printf@plt>
movsd  -0x10(%rbp),%xmm0
call   1070 <scale_converted_signal@plt>
mov    %eax,%edi
call   1040 <output_to_stm@plt>
jmp    119c <main+0x2c>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <request_io_access_permission@plt>
xor    %eax,%eax
call   1080 <map_io_ports@plt>
xor    %eax,%eax
call   1060 <a_d_init@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   1070 <scale_converted_signal@plt>
mov    %eax,%edi
call   1050 <output_to_stm@plt>
xor    %eax,%eax
call   1090 <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_io_access_permission()
%4 = call i32 (...) @map_io_ports()
%5 = call i32 (...) @a_d_init()
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_converted_signal(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_io_access_permission()
%2 = tail call i32 (...) @map_io_ports()
%3 = tail call i32 (...) @a_d_init()
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_converted_signal(double %5)
%13 = tail call i32 @output_to_stm(i32 %12)
br label %4
}