#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*/ mdaq_aout_write_multi(unsigned char *, unsigned char,
                                         float *);
void DACStep(double *dac_data, unsigned char *channels,
             unsigned char channel_count) {
  {
    int count;
    float data[(8)];
    if (channel_count > (8))
      return;
    for (count = 0; count < channel_count; count++)
      data[count] = dac_data[count];
    mdaq_aout_write_multi(channels, channel_count, data);
    return;
  }
}


x86 assembly (clang, -O0):
<DACStep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x8,%eax
jle    1137 <DACStep+0x27>
jmp    1189 <DACStep+0x79>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
movzbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jge    1176 <DACStep+0x66>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x18(%rbp),%rax
movss  %xmm0,-0x40(%rbp,%rax,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <DACStep+0x2e>
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
lea    -0x40(%rbp),%rdx
movzbl %al,%esi
call   1030 <mdaq_aout_write_multi@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DACStep>:
cmp    $0x8,%dl
ja     11d6 <DACStep+0xc6>
sub    $0x28,%rsp
test   %dl,%dl
je     11c2 <DACStep+0xb2>
movsd  (%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rsp)
cmp    $0x1,%dl
je     11c2 <DACStep+0xb2>
movsd  0x8(%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
cmp    $0x2,%dl
je     11c2 <DACStep+0xb2>
movsd  0x10(%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
cmp    $0x3,%dl
je     11c2 <DACStep+0xb2>
movsd  0x18(%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
cmp    $0x4,%dl
je     11c2 <DACStep+0xb2>
movsd  0x20(%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
cmp    $0x5,%dl
je     11c2 <DACStep+0xb2>
movsd  0x28(%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x14(%rsp)
cmp    $0x6,%dl
je     11c2 <DACStep+0xb2>
movsd  0x30(%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
cmp    $0x7,%dl
je     11c2 <DACStep+0xb2>
movsd  0x38(%rdi),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x1c(%rsp)
movzbl %dl,%eax
mov    %rsp,%rdx
mov    %rsi,%rdi
mov    %eax,%esi
call   1030 <mdaq_aout_write_multi@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define void @DACStep(double* %0, i8* %1, i8 zeroext %2) {
%4 = alloca double*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca [8 x float]
store double* %0, double** %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%9 = load i8, i8* %6
%10 = zext i8 %9 to i32
%11 = icmp sgt i32 %10, 8
br i1 %11, label %12, label %13
12: ; preds = %3
br label %37
13: ; preds = %3
store i32 0, i32* %7
br label %14
14: ; preds = %29, %13
%15 = load i32, i32* %7
%16 = load i8, i8* %6
%17 = zext i8 %16 to i32
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %32
19: ; preds = %14
%20 = load double*, double** %4
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = fptrunc double %24 to float
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [8 x float], [8 x float]* %8, i64 0, i64 %27
store float %25, float* %28
br label %29
29: ; preds = %19
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %14
32: ; preds = %14
%33 = load i8*, i8** %5
%34 = load i8, i8* %6
%35 = getelementptr inbounds [8 x float], [8 x float]* %8, i64 0, i64 0
%36 = call i32 @mdaq_aout_write_multi(i8* %33, i8 zeroext %34, float* %35)
br label %37
37: ; preds = %32, %12
ret void
}

LLVM IR (-O2):
define void @DACStep(double* nocapture %0, i8* %1, i8 zeroext %2) {
%4 = alloca [8 x float]
%5 = bitcast [8 x float]* %4 to i8*
%6 = icmp ugt i8 %2, 8
br i1 %6, label %58, label %7
7: ; preds = %3
%8 = icmp eq i8 %2, 0
br i1 %8, label %55, label %9
9: ; preds = %7
%10 = load double, double* %0
%11 = fptrunc double %10 to float
%12 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 0
store float %11, float* %12
%13 = icmp eq i8 %2, 1
br i1 %13, label %55, label %14
14: ; preds = %9
%15 = getelementptr inbounds double, double* %0, i64 1
%16 = load double, double* %15
%17 = fptrunc double %16 to float
%18 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 1
store float %17, float* %18
%19 = icmp eq i8 %2, 2
br i1 %19, label %55, label %20
20: ; preds = %14
%21 = getelementptr inbounds double, double* %0, i64 2
%22 = load double, double* %21
%23 = fptrunc double %22 to float
%24 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 2
store float %23, float* %24
%25 = icmp eq i8 %2, 3
br i1 %25, label %55, label %26
26: ; preds = %20
%27 = getelementptr inbounds double, double* %0, i64 3
%28 = load double, double* %27
%29 = fptrunc double %28 to float
%30 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 3
store float %29, float* %30
%31 = icmp eq i8 %2, 4
br i1 %31, label %55, label %32
32: ; preds = %26
%33 = getelementptr inbounds double, double* %0, i64 4
%34 = load double, double* %33
%35 = fptrunc double %34 to float
%36 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 4
store float %35, float* %36
%37 = icmp eq i8 %2, 5
br i1 %37, label %55, label %38
38: ; preds = %32
%39 = getelementptr inbounds double, double* %0, i64 5
%40 = load double, double* %39
%41 = fptrunc double %40 to float
%42 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 5
store float %41, float* %42
%43 = icmp eq i8 %2, 6
br i1 %43, label %55, label %44
44: ; preds = %38
%45 = getelementptr inbounds double, double* %0, i64 6
%46 = load double, double* %45
%47 = fptrunc double %46 to float
%48 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 6
store float %47, float* %48
%49 = icmp eq i8 %2, 7
br i1 %49, label %55, label %50
50: ; preds = %44
%51 = getelementptr inbounds double, double* %0, i64 7
%52 = load double, double* %51
%53 = fptrunc double %52 to float
%54 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 7
store float %53, float* %54
br label %55
55: ; preds = %9, %14, %20, %26, %32, %38, %44, %50, %7
%56 = getelementptr inbounds [8 x float], [8 x float]* %4, i64 0, i64 0
%57 = call i32 @mdaq_aout_write_multi(i8* %1, i8 zeroext %2, float* %56)
br label %58
58: ; preds = %3, %55
ret void
}