#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 */
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ _IONBF;
scalar_t__ close_adc();
scalar_t__ close_dac();
int errno;
int open_adc();
int open_dac();
int /*<<< orphan*/ printf(char *, ...);
int read_adc_raw(int, int /*<<< orphan*/);
double read_adc_voltage(int, int);
int /*<<< orphan*/ set_adc_refvoltage(double);
int /*<<< orphan*/ set_dac_gain(int);
int /*<<< orphan*/ set_dac_raw(int, int);
int /*<<< orphan*/ set_dac_voltage(double, int);
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);
  int passed = 1;
  uint16_t adcraw_error = 20;
  double adcvolt_error = 0.1;
  printf("Starting Test\n");
  if (open_adc() == 1) {
    printf("open_adc(): PASSED\n");
  } else {
    printf("open_adc(): FAILED\n");
    passed = 0;
  }
  if (open_dac() == 1) {
    printf("open_dac(): PASSED\n");
  } else {
    printf("open_dac(): FAILED\n");
    passed = 0;
  }
  set_dac_gain(1);
  set_adc_refvoltage(3.3);
  set_dac_raw(4095, 1);
  set_dac_raw(2047, 2);
  usleep(200000);
  uint16_t adcval1 = read_adc_raw(1, 0);
  if (adcval1 > (2542 - adcraw_error) && adcval1 < (2542 + adcraw_error)) {
    printf("set_dac_raw() channel 1: PASSED\n");
    printf("read_adc_raw() channel 1: PASSED\n");
  } else {
    printf("set_dac_raw() channel 1: FAILED\n");
    printf("read_adc_raw() channel 1: FAILED\n");
    passed = 0;
  }
  uint16_t adcval2 = read_adc_raw(2, 0);
  if (adcval2 > (1271 - adcraw_error) && adcval2 < (1271 + adcraw_error)) {
    printf("set_dac_raw() channel 2: PASSED\n");
    printf("read_adc_raw() channel 2: PASSED\n");
  } else {
    printf("set_dac_raw() channel 2: FAILED\n");
    printf("read_adc_raw() channel 2: FAILED\n");
    passed = 0;
  }
  set_dac_gain(2);
  set_dac_voltage(1.8, 1);
  set_dac_voltage(3.0, 2);
  double adcvolt1 = read_adc_voltage(1, 0);
  if (adcvolt1 > (1.8 - adcvolt_error) && adcvolt1 < (1.8 + adcvolt_error)) {
    printf("set_dac_voltage() channel 1: PASSED\n");
    printf("read_adc_voltage() channel 1: PASSED\n");
  } else {
    printf("set_dac_voltage() channel 1: FAILED\n");
    printf("read_adc_voltage() channel 1: FAILED\n");
    passed = 0;
  }
  double adcvolt2 = read_adc_voltage(2, 0);
  if (adcvolt2 > (3.0 - adcvolt_error) && adcvolt2 < (3.0 + adcvolt_error)) {
    printf("set_dac_voltage() channel 2: PASSED\n");
    printf("read_adc_voltage() channel 2: PASSED\n");
  } else {
    printf("set_dac_voltage() channel 2: FAILED\n");
    printf("read_adc_voltage() channel 2: FAILED\n");
    passed = 0;
  }
  double adcdiffvolt = read_adc_voltage(2, 1);
  if (adcdiffvolt > (1.2 - adcvolt_error) &&
      adcdiffvolt < (1.2 + adcvolt_error)) {
    printf("read_adc_voltage() Differential Mode Channel 2 - 1: PASSED\n");
  } else {
    printf("read_adc_voltage() Differential Mode Channel 2 - 1: FAILED\n");
    passed = 0;
  }
  set_dac_voltage(1.2, 2);
  set_dac_voltage(3.0, 1);
  adcdiffvolt = read_adc_voltage(1, 1);
  if (adcdiffvolt > (1.8 - adcvolt_error) &&
      adcdiffvolt < (1.8 + adcvolt_error)) {
    printf("read_adc_voltage() Differential Mode Channel 1 - 2: PASSED\n");
  } else {
    printf("read_adc_voltage() Differential Mode Channel 1 - 2: FAILED\n");
    passed = 0;
  }
  if (close_adc() == 0) {
    printf("close_adc(): PASSED\n");
  } else {
    printf("close_adc(): FAILED - Error %d\n", errno);
    passed = 0;
  }
  if (close_dac() == 0) {
    printf("close_dac(): PASSED\n");
  } else {
    printf("close_dac(): FAILED - Error %d\n", errno);
    passed = 0;
  }
  if (passed == 1) {
    printf("All Tests: PASSED\n");
  } else {
    printf("One or more Tests FAILED\n");
  }
  (void)argc;
  (void)argv;
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10b0 <setvbuf@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x14,-0x18(%rbp)
movsd  0xde7(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10d0 <open_adc@plt>
cmp    $0x1,%eax
jne    124f <main+0x7f>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1264 <main+0x94>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1060 <open_dac@plt>
cmp    $0x1,%eax
jne    1287 <main+0xb7>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    129c <main+0xcc>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x1,%edi
call   10c0 <set_dac_gain@plt>
movsd  0xd5a(%rip),%xmm0
call   1050 <set_adc_refvoltage@plt>
mov    $0xfff,%edi
mov    $0x1,%esi
call   10a0 <set_dac_raw@plt>
mov    $0x7ff,%edi
mov    $0x2,%esi
call   10a0 <set_dac_raw@plt>
mov    $0x30d40,%edi
call   10f0 <usleep@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <read_adc_raw@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x9ee,%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jle    1332 <main+0x162>
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x9ee,%ecx
cmp    %ecx,%eax
jge    1332 <main+0x162>
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1355 <main+0x185>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x2,%edi
xor    %esi,%esi
call   1090 <read_adc_raw@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x4f7,%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jle    13ac <main+0x1dc>
mov    -0x28(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x4f7,%ecx
cmp    %ecx,%eax
jge    13ac <main+0x1dc>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    13cf <main+0x1ff>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x2,%edi
call   10c0 <set_dac_gain@plt>
movsd  0xc2f(%rip),%xmm0
mov    $0x1,%edi
call   10e0 <set_dac_voltage@plt>
movsd  0xc25(%rip),%xmm0
mov    $0x2,%edi
call   10e0 <set_dac_voltage@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <read_adc_voltage@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xbf5(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1467 <main+0x297>
movsd  -0x30(%rbp),%xmm1
movsd  0xbd9(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1467 <main+0x297>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    148a <main+0x2ba>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <read_adc_voltage@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xb70(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    14f4 <main+0x324>
movsd  -0x38(%rbp),%xmm1
movsd  0xb54(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    14f4 <main+0x324>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1517 <main+0x347>
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <read_adc_voltage@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xae8(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1576 <main+0x3a6>
movsd  -0x40(%rbp),%xmm1
movsd  0xacc(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1576 <main+0x3a6>
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    158b <main+0x3bb>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
movsd  0xa8d(%rip),%xmm0
mov    $0x2,%edi
call   10e0 <set_dac_voltage@plt>
movsd  0xa73(%rip),%xmm0
mov    $0x1,%edi
call   10e0 <set_dac_voltage@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <read_adc_voltage@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xa43(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    160b <main+0x43b>
movsd  -0x40(%rbp),%xmm1
movsd  0xa27(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    160b <main+0x43b>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1620 <main+0x450>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <close_adc@plt>
cmp    $0x0,%rax
jne    1644 <main+0x474>
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1662 <main+0x492>
mov    0x298d(%rip),%rax
mov    (%rax),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1070 <close_dac@plt>
cmp    $0x0,%rax
jne    1686 <main+0x4b6>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    16a4 <main+0x4d4>
mov    0x294b(%rip),%rax
mov    (%rax),%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    16c1 <main+0x4f1>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    16cf <main+0x4ff>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    0x2ded(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   10c0 <setvbuf@plt>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10e0 <open_adc@plt>
mov    %eax,0x4(%rsp)
cmp    $0x1,%eax
lea    0x1217(%rip),%rax
lea    0xe70(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1070 <open_dac@plt>
mov    %eax,(%rsp)
cmp    $0x1,%eax
lea    0x11e0(%rip),%rax
lea    0xe5f(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10d0 <set_dac_gain@plt>
movsd  0xd93(%rip),%xmm0
call   1060 <set_adc_refvoltage@plt>
mov    $0xfff,%edi
mov    $0x1,%esi
call   10b0 <set_dac_raw@plt>
mov    $0x7ff,%edi
mov    $0x2,%esi
call   10b0 <set_dac_raw@plt>
mov    $0x30d40,%edi
call   1100 <usleep@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   10a0 <read_adc_raw@plt>
mov    %eax,%r12d
add    $0xfffff625,%r12d
cmp    $0x27,%r12d
lea    0x112f(%rip),%rax
lea    0xe02(%rip),%rdi
cmovb  %rax,%rdi
lea    0x113d(%rip),%rax
lea    0xe10(%rip),%rbp
cmovb  %rax,%rbp
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   10a0 <read_adc_raw@plt>
mov    %eax,%ebp
add    $0xfffffb1c,%ebp
cmp    $0x27,%ebp
lea    0x10a6(%rip),%rax
lea    0xdfb(%rip),%rdi
cmovb  %rax,%rdi
lea    0x10b4(%rip),%rax
lea    0xe09(%rip),%rbx
cmovb  %rax,%rbx
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x2,%edi
call   10d0 <set_dac_gain@plt>
movsd  0xcc9(%rip),%xmm0
mov    $0x1,%edi
call   10f0 <set_dac_voltage@plt>
movsd  0xcbf(%rip),%xmm0
mov    $0x2,%edi
call   10f0 <set_dac_voltage@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <read_adc_voltage@plt>
ucomisd 0xca9(%rip),%xmm0
seta   %al
movsd  0xca6(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %r13b
and    %al,%r13b
lea    0xfd4(%rip),%rax
lea    0xdb3(%rip),%rdi
cmovne %rax,%rdi
lea    0xfe6(%rip),%rax
lea    0xdc5(%rip),%rbx
cmovne %rax,%rbx
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <read_adc_voltage@plt>
ucomisd 0xc5e(%rip),%xmm0
seta   %al
movsd  0xc5b(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %r14b
and    %al,%r14b
lea    0xf30(%rip),%rax
lea    0xda1(%rip),%rdi
cmovne %rax,%rdi
lea    0xf42(%rip),%rax
lea    0xdb3(%rip),%rbx
cmovne %rax,%rbx
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <read_adc_voltage@plt>
ucomisd 0xc10(%rip),%xmm0
seta   %al
movsd  0xc0d(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %bl
and    %al,%bl
lea    0xe99(%rip),%rax
lea    0xd8e(%rip),%rdi
cmovne %rax,%rdi
call   1040 <puts@plt>
movsd  0xbed(%rip),%xmm0
mov    $0x2,%edi
call   10f0 <set_dac_voltage@plt>
movsd  0xba3(%rip),%xmm0
mov    $0x1,%edi
call   10f0 <set_dac_voltage@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <read_adc_voltage@plt>
ucomisd 0xb8a(%rip),%xmm0
seta   %al
movsd  0xb87(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %r15b
and    %al,%r15b
lea    0xdf6(%rip),%rax
lea    0xd61(%rip),%rdi
cmovne %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <close_adc@plt>
test   %rax,%rax
je     14e2 <main+0x302>
mov    0x2b0a(%rip),%rax
mov    (%rax),%esi
lea    0xb79(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %ebx,%ebx
jmp    1521 <main+0x341>
cmp    $0x27,%ebp
setb   %sil
cmp    $0x27,%r12d
setb   %cl
cmpl   $0x1,(%rsp)
sete   %dl
cmpl   $0x1,0x4(%rsp)
sete   %al
and    %bl,%r15b
and    %r14b,%r15b
and    %r13b,%r15b
and    %sil,%cl
and    %dl,%cl
and    %al,%cl
and    %r15b,%cl
movzbl %cl,%ebx
lea    0xd71(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <close_dac@plt>
test   %rax,%rax
je     1546 <main+0x366>
mov    0x2aa4(%rip),%rax
mov    (%rax),%esi
lea    0xb33(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    155f <main+0x37f>
lea    0xd2c(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
je     155f <main+0x37f>
lea    0xd0a(%rip),%rdi
jmp    1566 <main+0x386>
lea    0xce8(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [15 x i8] c"Starting Test\0A\00"
@.str.1 = [20 x i8] c"open_adc(): PASSED\0A\00"
@.str.2 = [20 x i8] c"open_adc(): FAILED\0A\00"
@.str.3 = [20 x i8] c"open_dac(): PASSED\0A\00"
@.str.4 = [20 x i8] c"open_dac(): FAILED\0A\00"
@.str.5 = [33 x i8] c"set_dac_raw() channel 1: PASSED\0A\00"
@.str.6 = [34 x i8] c"read_adc_raw() channel 1: PASSED\0A\00"
@.str.7 = [33 x i8] c"set_dac_raw() channel 1: FAILED\0A\00"
@.str.8 = [34 x i8] c"read_adc_raw() channel 1: FAILED\0A\00"
@.str.9 = [33 x i8] c"set_dac_raw() channel 2: PASSED\0A\00"
@.str.10 = [34 x i8] c"read_adc_raw() channel 2: PASSED\0A\00"
@.str.11 = [33 x i8] c"set_dac_raw() channel 2: FAILED\0A\00"
@.str.12 = [34 x i8] c"read_adc_raw() channel 2: FAILED\0A\00"
@.str.13 = [37 x i8] c"set_dac_voltage() channel 1: PASSED\0A\00"
@.str.14 = [38 x i8] c"read_adc_voltage() channel 1: PASSED\0A\00"
@.str.15 = [37 x i8] c"set_dac_voltage() channel 1: FAILED\0A\00"
@.str.16 = [38 x i8] c"read_adc_voltage() channel 1: FAILED\0A\00"
@.str.17 = [37 x i8] c"set_dac_voltage() channel 2: PASSED\0A\00"
@.str.18 = [38 x i8] c"read_adc_voltage() channel 2: PASSED\0A\00"
@.str.19 = [37 x i8] c"set_dac_voltage() channel 2: FAILED\0A\00"
@.str.20 = [38 x i8] c"read_adc_voltage() channel 2: FAILED\0A\00"
@.str.21 = [60 x i8] c"read_adc_voltage() Differential Mode Channel 2 - 1: PASSED\0A\00"
@.str.22 = [60 x i8] c"read_adc_voltage() Differential Mode Channel 2 - 1: FAILED\0A\00"
@.str.23 = [60 x i8] c"read_adc_voltage() Differential Mode Channel 1 - 2: PASSED\0A\00"
@.str.24 = [60 x i8] c"read_adc_voltage() Differential Mode Channel 1 - 2: FAILED\0A\00"
@.str.25 = [21 x i8] c"close_adc(): PASSED\0A\00"
@.str.26 = [32 x i8] c"close_adc(): FAILED - Error %d\0A\00"
@errno = global i32 0
@.str.27 = [21 x i8] c"close_dac(): PASSED\0A\00"
@.str.28 = [32 x i8] c"close_dac(): FAILED - Error %d\0A\00"
@.str.29 = [19 x i8] c"All Tests: PASSED\0A\00"
@.str.30 = [26 x i8] c"One or more Tests FAILED\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* @stdout
%15 = load i32, i32* @_IONBF
%16 = call i32 @setvbuf(i32 %14, i32* null, i32 %15, i32 0)
store i32 1, i32* %6
store i32 20, i32* %7
store double 1.000000e-01, double* %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (...) @open_adc()
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %24
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %24
24: ; preds = %22, %20
%25 = call i32 (...) @open_dac()
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %31
31: ; preds = %29, %27
%32 = call i32 @set_dac_gain(i32 1)
%33 = call i32 @set_adc_refvoltage(double 3.300000e+00)
%34 = call i32 @set_dac_raw(i32 4095, i32 1)
%35 = call i32 @set_dac_raw(i32 2047, i32 2)
%36 = call i32 @usleep(i32 200000)
%37 = call i32 @read_adc_raw(i32 1, i32 0)
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = load i32, i32* %7
%40 = sub nsw i32 2542, %39
%41 = icmp sgt i32 %38, %40
br i1 %41, label %42, label %50
42: ; preds = %31
%43 = load i32, i32* %9
%44 = load i32, i32* %7
%45 = add nsw i32 2542, %44
%46 = icmp slt i32 %43, %45
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %53
50: ; preds = %42, %31
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %6
br label %53
53: ; preds = %50, %47
%54 = call i32 @read_adc_raw(i32 2, i32 0)
store i32 %54, i32* %10
%55 = load i32, i32* %10
%56 = load i32, i32* %7
%57 = sub nsw i32 1271, %56
%58 = icmp sgt i32 %55, %57
br i1 %58, label %59, label %67
59: ; preds = %53
%60 = load i32, i32* %10
%61 = load i32, i32* %7
%62 = add nsw i32 1271, %61
%63 = icmp slt i32 %60, %62
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
br label %70
67: ; preds = %59, %53
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %6
br label %70
70: ; preds = %67, %64
%71 = call i32 @set_dac_gain(i32 2)
%72 = call i32 @set_dac_voltage(double 1.800000e+00, i32 1)
%73 = call i32 @set_dac_voltage(double 3.000000e+00, i32 2)
%74 = call double @read_adc_voltage(i32 1, i32 0)
store double %74, double* %11
%75 = load double, double* %11
%76 = load double, double* %8
%77 = fsub double 1.800000e+00, %76
%78 = fcmp ogt double %75, %77
br i1 %78, label %79, label %87
79: ; preds = %70
%80 = load double, double* %11
%81 = load double, double* %8
%82 = fadd double 1.800000e+00, %81
%83 = fcmp olt double %80, %82
br i1 %83, label %84, label %87
84: ; preds = %79
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0))
br label %90
87: ; preds = %79, %70
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0))
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.16, i64 0, i64 0))
store i32 0, i32* %6
br label %90
90: ; preds = %87, %84
%91 = call double @read_adc_voltage(i32 2, i32 0)
store double %91, double* %12
%92 = load double, double* %12
%93 = load double, double* %8
%94 = fsub double 3.000000e+00, %93
%95 = fcmp ogt double %92, %94
br i1 %95, label %96, label %104
96: ; preds = %90
%97 = load double, double* %12
%98 = load double, double* %8
%99 = fadd double 3.000000e+00, %98
%100 = fcmp olt double %97, %99
br i1 %100, label %101, label %104
101: ; preds = %96
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.17, i64 0, i64 0))
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0))
br label %107
104: ; preds = %96, %90
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.19, i64 0, i64 0))
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.20, i64 0, i64 0))
store i32 0, i32* %6
br label %107
107: ; preds = %104, %101
%108 = call double @read_adc_voltage(i32 2, i32 1)
store double %108, double* %13
%109 = load double, double* %13
%110 = load double, double* %8
%111 = fsub double 1.200000e+00, %110
%112 = fcmp ogt double %109, %111
br i1 %112, label %113, label %120
113: ; preds = %107
%114 = load double, double* %13
%115 = load double, double* %8
%116 = fadd double 1.200000e+00, %115
%117 = fcmp olt double %114, %116
br i1 %117, label %118, label %120
118: ; preds = %113
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.21, i64 0, i64 0))
br label %122
120: ; preds = %113, %107
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.22, i64 0, i64 0))
store i32 0, i32* %6
br label %122
122: ; preds = %120, %118
%123 = call i32 @set_dac_voltage(double 1.200000e+00, i32 2)
%124 = call i32 @set_dac_voltage(double 3.000000e+00, i32 1)
%125 = call double @read_adc_voltage(i32 1, i32 1)
store double %125, double* %13
%126 = load double, double* %13
%127 = load double, double* %8
%128 = fsub double 1.800000e+00, %127
%129 = fcmp ogt double %126, %128
br i1 %129, label %130, label %137
130: ; preds = %122
%131 = load double, double* %13
%132 = load double, double* %8
%133 = fadd double 1.800000e+00, %132
%134 = fcmp olt double %131, %133
br i1 %134, label %135, label %137
135: ; preds = %130
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.23, i64 0, i64 0))
br label %139
137: ; preds = %130, %122
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.24, i64 0, i64 0))
store i32 0, i32* %6
br label %139
139: ; preds = %137, %135
%140 = call i64 (...) @close_adc()
%141 = icmp eq i64 %140, 0
br i1 %141, label %142, label %144
142: ; preds = %139
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.25, i64 0, i64 0))
br label %147
144: ; preds = %139
%145 = load i32, i32* @errno
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.26, i64 0, i64 0), i32 %145)
store i32 0, i32* %6
br label %147
147: ; preds = %144, %142
%148 = call i64 (...) @close_dac()
%149 = icmp eq i64 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %147
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.27, i64 0, i64 0))
br label %155
152: ; preds = %147
%153 = load i32, i32* @errno
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.28, i64 0, i64 0), i32 %153)
store i32 0, i32* %6
br label %155
155: ; preds = %152, %150
%156 = load i32, i32* %6
%157 = icmp eq i32 %156, 1
br i1 %157, label %158, label %160
158: ; preds = %155
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.29, i64 0, i64 0))
br label %162
160: ; preds = %155
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.30, i64 0, i64 0))
br label %162
162: ; preds = %160, %158
%163 = load i32, i32* %4
%164 = load i8**, i8*** %5
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@.str.26 = [32 x i8] c"close_adc(): FAILED - Error %d\0A\00"
@errno = global i32 0
@.str.28 = [32 x i8] c"close_dac(): FAILED - Error %d\0A\00"
@str = [14 x i8] c"Starting Test\00"
@str.31 = [19 x i8] c"open_adc(): FAILED\00"
@str.32 = [19 x i8] c"open_dac(): FAILED\00"
@str.33 = [32 x i8] c"set_dac_raw() channel 1: FAILED\00"
@str.34 = [33 x i8] c"read_adc_raw() channel 1: FAILED\00"
@str.35 = [32 x i8] c"set_dac_raw() channel 2: FAILED\00"
@str.36 = [33 x i8] c"read_adc_raw() channel 2: FAILED\00"
@str.37 = [36 x i8] c"set_dac_voltage() channel 1: FAILED\00"
@str.38 = [37 x i8] c"read_adc_voltage() channel 1: FAILED\00"
@str.39 = [36 x i8] c"set_dac_voltage() channel 2: FAILED\00"
@str.40 = [37 x i8] c"read_adc_voltage() channel 2: FAILED\00"
@str.41 = [59 x i8] c"read_adc_voltage() Differential Mode Channel 2 - 1: FAILED\00"
@str.42 = [59 x i8] c"read_adc_voltage() Differential Mode Channel 1 - 2: FAILED\00"
@str.43 = [25 x i8] c"One or more Tests FAILED\00"
@str.44 = [18 x i8] c"All Tests: PASSED\00"
@str.45 = [20 x i8] c"close_dac(): PASSED\00"
@str.46 = [20 x i8] c"close_adc(): PASSED\00"
@str.47 = [59 x i8] c"read_adc_voltage() Differential Mode Channel 1 - 2: PASSED\00"
@str.48 = [59 x i8] c"read_adc_voltage() Differential Mode Channel 2 - 1: PASSED\00"
@str.49 = [36 x i8] c"set_dac_voltage() channel 2: PASSED\00"
@str.50 = [37 x i8] c"read_adc_voltage() channel 2: PASSED\00"
@str.51 = [36 x i8] c"set_dac_voltage() channel 1: PASSED\00"
@str.52 = [37 x i8] c"read_adc_voltage() channel 1: PASSED\00"
@str.53 = [32 x i8] c"set_dac_raw() channel 2: PASSED\00"
@str.54 = [33 x i8] c"read_adc_raw() channel 2: PASSED\00"
@str.55 = [32 x i8] c"set_dac_raw() channel 1: PASSED\00"
@str.56 = [33 x i8] c"read_adc_raw() channel 1: PASSED\00"
@str.57 = [19 x i8] c"open_dac(): PASSED\00"
@str.58 = [19 x i8] c"open_adc(): PASSED\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (...) @open_adc()
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.58, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.31, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
%11 = tail call i32 (...) @open_dac()
%12 = icmp eq i32 %11, 1
%13 = select i1 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.57, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.32, i64 0, i64 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = tail call i32 @set_dac_gain(i32 1)
%16 = tail call i32 @set_adc_refvoltage(double 3.300000e+00)
%17 = tail call i32 @set_dac_raw(i32 4095, i32 1)
%18 = tail call i32 @set_dac_raw(i32 2047, i32 2)
%19 = tail call i32 @usleep(i32 200000)
%20 = tail call i32 @read_adc_raw(i32 1, i32 0)
%21 = add i32 %20, -2523
%22 = icmp ult i32 %21, 39
%23 = select i1 %22, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.55, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.33, i64 0, i64 0)
%24 = select i1 %22, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.56, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.34, i64 0, i64 0)
%25 = tail call i32 @puts(i8* dereferenceable(1) %23)
%26 = tail call i32 @puts(i8* dereferenceable(1) %24)
%27 = tail call i32 @read_adc_raw(i32 2, i32 0)
%28 = add i32 %27, -1252
%29 = icmp ult i32 %28, 39
%30 = select i1 %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.53, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.35, i64 0, i64 0)
%31 = select i1 %29, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.54, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.36, i64 0, i64 0)
%32 = tail call i32 @puts(i8* dereferenceable(1) %30)
%33 = tail call i32 @puts(i8* dereferenceable(1) %31)
%34 = tail call i32 @set_dac_gain(i32 2)
%35 = tail call i32 @set_dac_voltage(double 1.800000e+00, i32 1)
%36 = tail call i32 @set_dac_voltage(double 3.000000e+00, i32 2)
%37 = tail call double @read_adc_voltage(i32 1, i32 0)
%38 = fcmp ogt double %37, 1.700000e+00
%39 = fcmp olt double %37, 0x3FFE666666666667
%40 = and i1 %38, %39
%41 = select i1 %40, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.51, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.37, i64 0, i64 0)
%42 = select i1 %40, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.52, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.38, i64 0, i64 0)
%43 = tail call i32 @puts(i8* dereferenceable(1) %41)
%44 = tail call i32 @puts(i8* dereferenceable(1) %42)
%45 = tail call double @read_adc_voltage(i32 2, i32 0)
%46 = fcmp ogt double %45, 2.900000e+00
%47 = fcmp olt double %45, 3.100000e+00
%48 = and i1 %46, %47
%49 = select i1 %48, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.49, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.39, i64 0, i64 0)
%50 = select i1 %48, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.50, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.40, i64 0, i64 0)
%51 = tail call i32 @puts(i8* dereferenceable(1) %49)
%52 = tail call i32 @puts(i8* dereferenceable(1) %50)
%53 = tail call double @read_adc_voltage(i32 2, i32 1)
%54 = fcmp ogt double %53, 0x3FF1999999999999
%55 = fcmp olt double %53, 1.300000e+00
%56 = and i1 %54, %55
%57 = select i1 %56, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @str.48, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @str.41, i64 0, i64 0)
%58 = tail call i32 @puts(i8* dereferenceable(1) %57)
%59 = tail call i32 @set_dac_voltage(double 1.200000e+00, i32 2)
%60 = tail call i32 @set_dac_voltage(double 3.000000e+00, i32 1)
%61 = tail call double @read_adc_voltage(i32 1, i32 1)
%62 = fcmp ogt double %61, 1.700000e+00
%63 = fcmp olt double %61, 0x3FFE666666666667
%64 = and i1 %62, %63
%65 = select i1 %64, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @str.47, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @str.42, i64 0, i64 0)
%66 = tail call i32 @puts(i8* dereferenceable(1) %65)
%67 = tail call i64 (...) @close_adc()
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %79
69: ; preds = %2
%70 = select i1 %64, i1 %56, i1 false
%71 = select i1 %70, i1 %48, i1 false
%72 = select i1 %71, i1 %40, i1 false
%73 = select i1 %72, i1 %29, i1 false
%74 = select i1 %73, i1 %22, i1 false
%75 = select i1 %74, i1 %12, i1 false
%76 = select i1 %75, i1 %8, i1 false
%77 = zext i1 %76 to i32
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.46, i64 0, i64 0))
br label %82
79: ; preds = %2
%80 = load i32, i32* @errno
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.26, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %79, %69
%83 = phi i32 [ %77, %69 ], [ 0, %79 ]
%84 = tail call i64 (...) @close_dac()
%85 = icmp eq i64 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %82
%87 = load i32, i32* @errno
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.28, i64 0, i64 0), i32 %87)
br label %92
89: ; preds = %82
%90 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.45, i64 0, i64 0))
%91 = icmp eq i32 %83, 1
br i1 %91, label %93, label %92
92: ; preds = %86, %89
br label %93
93: ; preds = %89, %92
%94 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.43, i64 0, i64 0), %92 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.44, i64 0, i64 0), %89 ]
%95 = tail call i32 @puts(i8* dereferenceable(1) %94)
ret i32 0
}