#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*/ _IONBF;
int adc_open();
double adc_read_voltage(int, int /*<<< orphan*/);
int /*<<< orphan*/ clearscreen();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  setvbuf(stdout, NULL, _IONBF, 0);
  if (adc_open() != 1) {
    exit(1);
  }
  while (1) {
    clearscreen();
    printf("Pin 1: %G \n", adc_read_voltage(1, 0));
    printf("Pin 2: %G \n", adc_read_voltage(2, 0));
    printf("Pin 3: %G \n", adc_read_voltage(3, 0));
    printf("Pin 4: %G \n", adc_read_voltage(4, 0));
    printf("Pin 5: %G \n", adc_read_voltage(5, 0));
    printf("Pin 6: %G \n", adc_read_voltage(6, 0));
    printf("Pin 7: %G \n", adc_read_voltage(7, 0));
    printf("Pin 8: %G \n", adc_read_voltage(8, 0));
    usleep(200000);
  }
  (void)argc;
  (void)argv;
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
mov    0x2e52(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1060 <setvbuf@plt>
mov    $0x0,%al
call   1050 <adc_open@plt>
cmp    $0x1,%eax
je     11bd <main+0x4d>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11c2 <main+0x52>
mov    $0x0,%al
call   1030 <clearscreen@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xe18(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
mov    $0x6,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
mov    $0x7,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xdd0(%rip),%rdi
call   1040 <printf@plt>
mov    $0x30d40,%edi
call   1090 <usleep@plt>
jmp    11c2 <main+0x52>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1060 <setvbuf@plt>
xor    %eax,%eax
call   1050 <adc_open@plt>
cmp    $0x1,%eax
jne    128e <main+0x11e>
lea    0xe6b(%rip),%r12
lea    0xe70(%rip),%r13
lea    0xe75(%rip),%rbx
lea    0xe7a(%rip),%rbp
lea    0xe7f(%rip),%r14
lea    0xe84(%rip),%r15
xor    %eax,%eax
call   1030 <clearscreen@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    $0x6,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    $0x7,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1080 <adc_read_voltage@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    $0x30d40,%edi
call   1090 <usleep@plt>
jmp    11d0 <main+0x60>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [12 x i8] c"Pin 1: %G \0A\00"
@.str.1 = [12 x i8] c"Pin 2: %G \0A\00"
@.str.2 = [12 x i8] c"Pin 3: %G \0A\00"
@.str.3 = [12 x i8] c"Pin 4: %G \0A\00"
@.str.4 = [12 x i8] c"Pin 5: %G \0A\00"
@.str.5 = [12 x i8] c"Pin 6: %G \0A\00"
@.str.6 = [12 x i8] c"Pin 7: %G \0A\00"
@.str.7 = [12 x i8] c"Pin 8: %G \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 0)
%9 = call i32 (...) @adc_open()
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
br label %14
14: ; preds = %13, %14
%15 = call i32 (...) @clearscreen()
%16 = call double @adc_read_voltage(i32 1, i32 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %16)
%18 = call double @adc_read_voltage(i32 2, i32 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %18)
%20 = call double @adc_read_voltage(i32 3, i32 0)
%21 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %20)
%22 = call double @adc_read_voltage(i32 4, i32 0)
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %22)
%24 = call double @adc_read_voltage(i32 5, i32 0)
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %24)
%26 = call double @adc_read_voltage(i32 6, i32 0)
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %26)
%28 = call double @adc_read_voltage(i32 7, i32 0)
%29 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %28)
%30 = call double @adc_read_voltage(i32 8, i32 0)
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %30)
%32 = call i32 @usleep(i32 200000)
br label %14
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [12 x i8] c"Pin 1: %G \0A\00"
@.str.1 = [12 x i8] c"Pin 2: %G \0A\00"
@.str.2 = [12 x i8] c"Pin 3: %G \0A\00"
@.str.3 = [12 x i8] c"Pin 4: %G \0A\00"
@.str.4 = [12 x i8] c"Pin 5: %G \0A\00"
@.str.5 = [12 x i8] c"Pin 6: %G \0A\00"
@.str.6 = [12 x i8] c"Pin 7: %G \0A\00"
@.str.7 = [12 x i8] c"Pin 8: %G \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdout
%4 = load i32, i32* @_IONBF
%5 = tail call i32 @setvbuf(i32 %3, i32* null, i32 %4, i32 0)
%6 = tail call i32 (...) @adc_open()
%7 = icmp eq i32 %6, 1
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2, %10
%11 = tail call i32 (...) @clearscreen()
%12 = tail call double @adc_read_voltage(i32 1, i32 0)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %12)
%14 = tail call double @adc_read_voltage(i32 2, i32 0)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %14)
%16 = tail call double @adc_read_voltage(i32 3, i32 0)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %16)
%18 = tail call double @adc_read_voltage(i32 4, i32 0)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = tail call double @adc_read_voltage(i32 5, i32 0)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %20)
%22 = tail call double @adc_read_voltage(i32 6, i32 0)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %22)
%24 = tail call double @adc_read_voltage(i32 7, i32 0)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %24)
%26 = tail call double @adc_read_voltage(i32 8, i32 0)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %26)
%28 = tail call i32 @usleep(i32 200000)
br label %10
}