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


x86 assembly (clang, -O0):
<bes2i_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jl     117a <bes2i_array+0x5a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movswl (%rax,%rcx,2),%edi
call   1030 <ENDSWAP_16@plt>
mov    %ax,-0x1a(%rbp)
mov    $0x10,%esi
movswl -0x1a(%rbp),%edi
call   1040 <arith_shift_left@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1133 <bes2i_array+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bes2i_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1169 <bes2i_array+0x49>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%ebx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%r12d
movswl (%r15,%r12,2),%edi
call   1030 <ENDSWAP_16@plt>
movswl %ax,%edi
mov    $0x10,%esi
call   1040 <arith_shift_left@plt>
mov    %eax,(%r14,%r12,4)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1140 <bes2i_array+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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