#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 */
short ENDSWAP_16(short);
void bes2f_array(short *src, int count, float *dest, float normfact) {
  short value;
  while (--count >= 0) {
    value = src[count];
    value = ENDSWAP_16(value);
    dest[count] = ((float)value) * normfact;
  };
}


x86 assembly (clang, -O0):
<bes2f_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jl     1176 <bes2f_array+0x66>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,2),%ax
mov    %ax,-0x1e(%rbp)
movswl -0x1e(%rbp),%edi
call   1030 <ENDSWAP_16@plt>
mov    %ax,-0x1e(%rbp)
movswl -0x1e(%rbp),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    1128 <bes2f_array+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bes2f_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1160 <bes2f_array+0x50>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%ebx
add    $0x1,%rbx
movss  %xmm0,0x4(%rsp)
xchg   %ax,%ax
lea    -0x2(%rbx),%r12d
movswl (%r15,%r12,2),%edi
call   1030 <ENDSWAP_16@plt>
movss  0x4(%rsp),%xmm0
cwtl
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r14,%r12,4)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1130 <bes2f_array+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @bes2f_array(i16* %0, i32 %1, float* %2, float %3) {
%5 = alloca i16*
%6 = alloca i32
%7 = alloca float*
%8 = alloca float
%9 = alloca i16
store i16* %0, i16** %5
store i32 %1, i32* %6
store float* %2, float** %7
store float %3, float* %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 i16*, i16** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i16, i16* %15, i64 %17
%19 = load i16, i16* %18
store i16 %19, i16* %9
%20 = load i16, i16* %9
%21 = call signext i16 @ENDSWAP_16(i16 signext %20)
store i16 %21, i16* %9
%22 = load i16, i16* %9
%23 = sitofp i16 %22 to float
%24 = load float, float* %8
%25 = fmul float %23, %24
%26 = load float*, float** %7
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
store float %25, float* %29
br label %10
30: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @bes2f_array(i16* nocapture %0, i32 %1, float* nocapture writeonly %2, float %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 i16, i16* %0, i64 %11
%13 = load i16, i16* %12
%14 = tail call signext i16 @ENDSWAP_16(i16 signext %13)
%15 = sitofp i16 %14 to float
%16 = fmul float %15, %3
%17 = getelementptr inbounds float, float* %2, i64 %11
store float %16, float* %17
%18 = icmp ugt i64 %9, 1
br i1 %18, label %8, label %19
19: ; preds = %8, %4
ret void
}