#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 ENDSWAP_32(int);
void bei2d_array(int *src, int count, double *dest, double normfact) {
  int value;
  while (--count >= 0) {
    value = src[count];
    value = ENDSWAP_32(value);
    dest[count] = ((double)value) * normfact;
  };
}


x86 assembly (clang, -O0):
<bei2d_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jl     116f <bei2d_array+0x5f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <ENDSWAP_32@plt>
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1128 <bei2d_array+0x18>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bei2d_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    115d <bei2d_array+0x4d>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%ebx
add    $0x1,%rbx
movsd  %xmm0,(%rsp)
nopl   (%rax)
lea    -0x2(%rbx),%r12d
mov    (%r15,%r12,4),%edi
call   1030 <ENDSWAP_32@plt>
movsd  (%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%r12,8)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1130 <bei2d_array+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @bei2d_array(i32* %0, i32 %1, double* %2, double %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store double* %2, double** %7
store double %3, double* %8
br label %10
10: ; preds = %14, %4
%11 = load i32, i32* %6
%12 = add nsw i32 %11, -1
store i32 %12, i32* %6
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = call i32 @ENDSWAP_32(i32 %20)
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = sitofp i32 %22 to double
%24 = load double, double* %8
%25 = fmul double %23, %24
%26 = load double*, double** %7
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
store double %25, double* %29
br label %10
30: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @bei2d_array(i32* nocapture %0, i32 %1, double* nocapture writeonly %2, double %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %19
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ %7, %6 ], [ %10, %8 ]
%10 = add nsw i64 %9, -1
%11 = and i64 %10, 4294967295
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = tail call i32 @ENDSWAP_32(i32 %13)
%15 = sitofp i32 %14 to double
%16 = fmul double %15, %3
%17 = getelementptr inbounds double, double* %2, i64 %11
store double %16, double* %17
%18 = icmp ugt i64 %9, 1
br i1 %18, label %8, label %19
19: ; preds = %8, %4
ret void
}