#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 /*<<< orphan*/ close_dac();
int /*<<< orphan*/ exit(int);
int open_dac();
int /*<<< orphan*/ set_dac_gain(int);
int /*<<< orphan*/ set_dac_voltage(double, int);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  setvbuf(stdout, NULL, _IONBF, 0);
  if (open_dac() != 1) {
    exit(1);
  }
  set_dac_gain(2);
  set_dac_voltage(1.2, 1);
  set_dac_voltage(2.5, 2);
  close_dac();
  (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    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1050 <setvbuf@plt>
mov    $0x0,%al
call   1030 <open_dac@plt>
cmp    $0x1,%eax
je     11ad <main+0x4d>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0x2,%edi
call   1060 <set_dac_gain@plt>
movsd  0xe49(%rip),%xmm0
mov    $0x1,%edi
call   1080 <set_dac_voltage@plt>
movsd  0xe2f(%rip),%xmm0
mov    $0x2,%edi
call   1080 <set_dac_voltage@plt>
mov    $0x0,%al
call   1040 <close_dac@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1050 <setvbuf@plt>
xor    %eax,%eax
call   1030 <open_dac@plt>
cmp    $0x1,%eax
jne    11c1 <main+0x61>
mov    $0x2,%edi
call   1060 <set_dac_gain@plt>
movsd  0xe66(%rip),%xmm0
mov    $0x1,%edi
call   1080 <set_dac_voltage@plt>
movsd  0xe5c(%rip),%xmm0
mov    $0x2,%edi
call   1080 <set_dac_voltage@plt>
xor    %eax,%eax
call   1040 <close_dac@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
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 (...) @open_dac()
%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
%14 = call i32 @set_dac_gain(i32 2)
%15 = call i32 @set_dac_voltage(double 1.200000e+00, i32 1)
%16 = call i32 @set_dac_voltage(double 2.500000e+00, i32 2)
%17 = call i32 (...) @close_dac()
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
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 (...) @open_dac()
%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
%11 = tail call i32 @set_dac_gain(i32 2)
%12 = tail call i32 @set_dac_voltage(double 1.200000e+00, i32 1)
%13 = tail call i32 @set_dac_voltage(double 2.500000e+00, i32 2)
%14 = tail call i32 (...) @close_dac()
ret i32 0
}