#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 floor(float);
int /*<<< orphan*/ medusa_dsp_lpf(float *, size_t, float, float);
void medusa_dsp_resample(float *input, float *output, size_t input_size,
                         size_t output_size, float input_sr, float output_sr) {
  (void)input_size;
  float j = 0, interpolated_step = input_sr / output_sr;
  int i = 0;
  for (i = 0, j = 0; i < (int)output_size; i++, j += interpolated_step) {
    int my_floor = floor(j);
    float y = j - my_floor;
    output[i] = input[my_floor] * (1.0f - y) + input[my_floor + 1] * y;
  }
  medusa_dsp_lpf(output, output_size, output_sr, output_sr / 2.1f);
}


x86 assembly (clang, -O0):
<medusa_dsp_resample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movss  %xmm0,-0x24(%rbp)
movss  %xmm1,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
divss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x34(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    %ecx,%eax
jge    1201 <medusa_dsp_resample+0xe1>
movss  -0x2c(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x38(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtsi2ssl -0x38(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  0xe51(%rip),%xmm2
subss  -0x3c(%rbp),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
mulss  -0x3c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movss  -0x30(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    116f <medusa_dsp_resample+0x4f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movss  -0x28(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movss  0xde5(%rip),%xmm2
divss  %xmm2,%xmm1
call   1030 <medusa_dsp_lpf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<medusa_dsp_resample>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0x4(%rsp)
mov    %rcx,%r14
mov    %rsi,%r15
test   %r14d,%r14d
jle    11c8 <medusa_dsp_resample+0xa8>
mov    %rdi,%r13
movss  0x4(%rsp),%xmm0
divss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r14d,%r12d
xorps  %xmm1,%xmm1
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movaps %xmm1,%xmm0
movss  %xmm1,0xc(%rsp)
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
addss  %xmm2,%xmm1
subss  %xmm0,%xmm2
cltq
movss  0xe5d(%rip),%xmm0
subss  %xmm2,%xmm0
mulss  0x4(%r13,%rax,4),%xmm2
mulss  0x0(%r13,%rax,4),%xmm0
addss  %xmm2,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <medusa_dsp_resample+0x50>
movss  0x8(%rsp),%xmm0
movaps %xmm0,%xmm1
divss  0xe2b(%rip),%xmm1
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <medusa_dsp_lpf@plt>

LLVM IR (-O0):
define void @medusa_dsp_resample(float* %0, float* %1, i64 %2, i64 %3, float %4, float %5) {
%7 = alloca float*
%8 = alloca float*
%9 = alloca i64
%10 = alloca i64
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca i32
%16 = alloca i32
%17 = alloca float
store float* %0, float** %7
store float* %1, float** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store float %4, float* %11
store float %5, float* %12
%18 = load i64, i64* %9
store float 0.000000e+00, float* %13
%19 = load float, float* %11
%20 = load float, float* %12
%21 = fdiv float %19, %20
store float %21, float* %14
store i32 0, i32* %15
store i32 0, i32* %15
store float 0.000000e+00, float* %13
br label %22
22: ; preds = %54, %6
%23 = load i32, i32* %15
%24 = load i64, i64* %10
%25 = trunc i64 %24 to i32
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %60
27: ; preds = %22
%28 = load float, float* %13
%29 = call i32 @floor(float %28)
store i32 %29, i32* %16
%30 = load float, float* %13
%31 = load i32, i32* %16
%32 = sitofp i32 %31 to float
%33 = fsub float %30, %32
store float %33, float* %17
%34 = load float*, float** %7
%35 = load i32, i32* %16
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %34, i64 %36
%38 = load float, float* %37
%39 = load float, float* %17
%40 = fsub float 1.000000e+00, %39
%41 = load float*, float** %7
%42 = load i32, i32* %16
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds float, float* %41, i64 %44
%46 = load float, float* %45
%47 = load float, float* %17
%48 = fmul float %46, %47
%49 = call float @llvm.fmuladd.f32(float %38, float %40, float %48)
%50 = load float*, float** %8
%51 = load i32, i32* %15
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %50, i64 %52
store float %49, float* %53
br label %54
54: ; preds = %27
%55 = load i32, i32* %15
%56 = add nsw i32 %55, 1
store i32 %56, i32* %15
%57 = load float, float* %14
%58 = load float, float* %13
%59 = fadd float %58, %57
store float %59, float* %13
br label %22
60: ; preds = %22
%61 = load float*, float** %8
%62 = load i64, i64* %10
%63 = load float, float* %12
%64 = load float, float* %12
%65 = fdiv float %64, 0x4000CCCCC0000000
%66 = call i32 @medusa_dsp_lpf(float* %61, i64 %62, float %63, float %65)
ret void
}

LLVM IR (-O2):
define void @medusa_dsp_resample(float* nocapture %0, float* %1, i64 %2, i64 %3, float %4, float %5) {
%7 = fdiv float %4, %5
%8 = trunc i64 %3 to i32
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %6
%11 = and i64 %3, 4294967295
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %29, %12 ]
%14 = phi float [ 0.000000e+00, %10 ], [ %30, %12 ]
%15 = tail call i32 @floor(float %14)
%16 = sitofp i32 %15 to float
%17 = fsub float %14, %16
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds float, float* %0, i64 %18
%20 = load float, float* %19
%21 = fsub float 1.000000e+00, %17
%22 = add nsw i32 %15, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %0, i64 %23
%25 = load float, float* %24
%26 = fmul float %25, %17
%27 = tail call float @llvm.fmuladd.f32(float %20, float %21, float %26)
%28 = getelementptr inbounds float, float* %1, i64 %13
store float %27, float* %28
%29 = add nuw nsw i64 %13, 1
%30 = fadd float %7, %14
%31 = icmp eq i64 %29, %11
br i1 %31, label %32, label %12
32: ; preds = %12, %6
%33 = fdiv float %5, 0x4000CCCCC0000000
%34 = tail call i32 @medusa_dsp_lpf(float* %1, i64 %3, float %5, float %33)
ret void
}