#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 convert(int);
int a52_resample_STEREO_to_2_C(float *_f, signed short *s16) {
  int i;
  signed int *f = (signed int *)_f;
  for (i = 0; i < 256; i++) {
    s16[2 * i] = convert(f[i]);
    s16[2 * i + 1] = convert(f[i + 256]);
  }
  return 2 * 256;
}


x86 assembly (clang, -O0):
<a52_resample_STEREO_to_2_C>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    119d <a52_resample_STEREO_to_2_C+0x8d>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <convert@plt>
mov    %ax,%dx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x100,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <convert@plt>
mov    %ax,%dx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <a52_resample_STEREO_to_2_C+0x1f>
mov    $0x200,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a52_resample_STEREO_to_2_C>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15,%rbx,4),%edi
call   1030 <convert@plt>
mov    %ax,(%r14,%rbx,4)
mov    0x400(%r15,%rbx,4),%edi
call   1030 <convert@plt>
mov    %ax,0x2(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1120 <a52_resample_STEREO_to_2_C+0x10>
mov    $0x200,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @a52_resample_STEREO_to_2_C(float* %0, i16* %1) {
%3 = alloca float*
%4 = alloca i16*
%5 = alloca i32
%6 = alloca i32*
store float* %0, float** %3
store i16* %1, i16** %4
%7 = load float*, float** %3
%8 = bitcast float* %7 to i32*
store i32* %8, i32** %6
store i32 0, i32* %5
br label %9
9: ; preds = %37, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 256
br i1 %11, label %12, label %40
12: ; preds = %9
%13 = load i32*, i32** %6
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = call signext i16 @convert(i32 %17)
%19 = load i16*, i16** %4
%20 = load i32, i32* %5
%21 = mul nsw i32 2, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i16, i16* %19, i64 %22
store i16 %18, i16* %23
%24 = load i32*, i32** %6
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 256
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %24, i64 %27
%29 = load i32, i32* %28
%30 = call signext i16 @convert(i32 %29)
%31 = load i16*, i16** %4
%32 = load i32, i32* %5
%33 = mul nsw i32 2, %32
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i16, i16* %31, i64 %35
store i16 %30, i16* %36
br label %37
37: ; preds = %12
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %9
40: ; preds = %9
ret i32 512
}

LLVM IR (-O2):
define i32 @a52_resample_STEREO_to_2_C(float* nocapture %0, i16* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %18, %3 ]
%5 = getelementptr inbounds float, float* %0, i64 %4
%6 = bitcast float* %5 to i32*
%7 = load i32, i32* %6
%8 = tail call signext i16 @convert(i32 %7)
%9 = shl nuw nsw i64 %4, 1
%10 = getelementptr inbounds i16, i16* %1, i64 %9
store i16 %8, i16* %10
%11 = add nuw nsw i64 %4, 256
%12 = getelementptr inbounds float, float* %0, i64 %11
%13 = bitcast float* %12 to i32*
%14 = load i32, i32* %13
%15 = tail call signext i16 @convert(i32 %14)
%16 = or i64 %9, 1
%17 = getelementptr inbounds i16, i16* %1, i64 %16
store i16 %15, i16* %17
%18 = add nuw nsw i64 %4, 1
%19 = icmp eq i64 %18, 256
br i1 %19, label %20, label %3
20: ; preds = %3
ret i32 512
}