#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 /*<<< orphan*/ ch_config;

/* Variables and functions */
int /*<<< orphan*/ mdaq_aout_write_multi(unsigned char *, unsigned char,
                                         float *);
void DACTerminate(float *dac_data_term, unsigned char channel_count,
                  unsigned short term_all_ch) {
  int count;
  float term_voltage[] = {0, 0, 0, 0, 0, 0, 0, 0};
  unsigned char ch_config[] = {0, 1, 2, 3, 4, 5, 6, 7};
  if (term_all_ch) {
    if (dac_data_term[0] != 0) {
      for (count = 0; count < (8); count++) {
        term_voltage[count] = dac_data_term[0];
      }
    }
    mdaq_aout_write_multi(ch_config, sizeof(ch_config), term_voltage);
  } else {
    mdaq_aout_write_multi(ch_config, channel_count, dac_data_term);
  }
  return;
}


x86 assembly (clang, -O0):
<DACTerminate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dx,%ax
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %ax,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0xeb0(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpw   $0x0,-0xc(%rbp)
je     11cb <DACTerminate+0xab>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    117e <DACTerminate+0x5e>
jp     117e <DACTerminate+0x5e>
jmp    11b4 <DACTerminate+0x94>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    11af <DACTerminate+0x8f>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movslq -0x10(%rbp),%rax
movss  %xmm0,-0x30(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <DACTerminate+0x65>
jmp    11b4 <DACTerminate+0x94>
lea    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rdx
mov    $0x8,%esi
call   1040 <mdaq_aout_write_multi@plt>
jmp    11de <DACTerminate+0xbe>
lea    -0x38(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rdx
movzbl %al,%esi
call   1040 <mdaq_aout_write_multi@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DACTerminate>:
sub    $0x38,%rsp
mov    %rdi,%rax
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movabs $0x706050403020100,%rcx
05 06 07
mov    %rcx,0x8(%rsp)
test   %edx,%edx
je     1164 <DACTerminate+0x54>
movss  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1145 <DACTerminate+0x35>
jnp    1153 <DACTerminate+0x43>
shufps $0x0,%xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    $0x8,%esi
jmp    1170 <DACTerminate+0x60>
movzbl %sil,%esi
lea    0x8(%rsp),%rdi
mov    %rax,%rdx
call   1030 <mdaq_aout_write_multi@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.DACTerminate.ch_config = [8 x i8] c"\00\01\02\03\04\05\06\07"
define void @DACTerminate(float* %0, i8 zeroext %1, i16 zeroext %2) {
%4 = alloca float*
%5 = alloca i8
%6 = alloca i16
%7 = alloca i32
%8 = alloca [8 x float]
%9 = alloca [8 x i8]
store float* %0, float** %4
store i8 %1, i8* %5
store i16 %2, i16* %6
%10 = bitcast [8 x float]* %8 to i8*
%11 = bitcast [8 x i8]* %9 to i8*
%12 = load i16, i16* %6
%13 = icmp ne i16 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %3
%15 = load float*, float** %4
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
%18 = fcmp une float %17, 0.000000e+00
br i1 %18, label %19, label %34
19: ; preds = %14
store i32 0, i32* %7
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 8
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load float*, float** %4
%25 = getelementptr inbounds float, float* %24, i64 0
%26 = load float, float* %25
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x float], [8 x float]* %8, i64 0, i64 %28
store float %26, float* %29
br label %30
30: ; preds = %23
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %20
33: ; preds = %20
br label %34
34: ; preds = %33, %14
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%36 = getelementptr inbounds [8 x float], [8 x float]* %8, i64 0, i64 0
%37 = call i32 @mdaq_aout_write_multi(i8* %35, i8 zeroext 8, float* %36)
br label %43
38: ; preds = %3
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%40 = load i8, i8* %5
%41 = load float*, float** %4
%42 = call i32 @mdaq_aout_write_multi(i8* %39, i8 zeroext %40, float* %41)
br label %43
43: ; preds = %38, %34
ret void
}

LLVM IR (-O2):
define void @DACTerminate(float* %0, i8 zeroext %1, i16 zeroext %2) {
%4 = alloca [8 x float]
%5 = alloca i64
%6 = bitcast [8 x float]* %4 to i8*
%7 = bitcast i64* %5 to i8*
store i64 506097522914230528, i64* %5
%8 = icmp eq i16 %2, 0
br i1 %8, label %21, label %9
9: ; preds = %3
%10 = load float, float* %0
%11 = fcmp une float %10, 0.000000e+00
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = insertelement <4 x float> poison, float %10, i64 0
%14 = shufflevector <4 x float> %13, <4 x float> poison, <4 x i32> zeroinitializer
%15 = bitcast [8 x float]* %4 to <4 x float>*
store <4 x float> %14, <4 x float>* %15
%16 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 4
%17 = bitcast float* %16 to <4 x float>*
store <4 x float> %14, <4 x float>* %17
br label %18
18: ; preds = %12, %9
%19 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 0
%20 = call i32 @mdaq_aout_write_multi(i8* %7, i8 zeroext 8, float* %19)
br label %23
21: ; preds = %3
%22 = call i32 @mdaq_aout_write_multi(i8* %7, i8 zeroext %1, float* %0)
br label %23
23: ; preds = %21, %18
ret void
}