#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 ceil(float);
int /*<<< orphan*/ medusa_dsp_resample(float *, float *, int, int, float,
                                       float);
int /*<<< orphan*/ memcpy(float *, float *, int);
int medusa_dsp_change_sample_rate(float from, float to, float *src, float *dest,
                                  int data_size) {
  if (from == to) {
    memcpy(dest, src, data_size);
    return data_size;
  }
  data_size = data_size / sizeof(float);
  int new_size = ceil(to / from * data_size);
  to = new_size * from / data_size;
  medusa_dsp_resample(src, dest, data_size, new_size, from, to);
  return new_size * sizeof(float);
}


x86 assembly (clang, -O0):
<medusa_dsp_change_sample_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    117d <medusa_dsp_change_sample_rate+0x4d>
jp     117d <medusa_dsp_change_sample_rate+0x4d>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <medusa_dsp_change_sample_rate+0xb3>
movslq -0x24(%rbp),%rax
shr    $0x2,%rax
mov    %eax,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x28(%rbp)
cvtsi2ssl -0x28(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1050 <medusa_dsp_resample@plt>
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<medusa_dsp_change_sample_rate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
ucomiss %xmm1,%xmm0
jne    1155 <medusa_dsp_change_sample_rate+0x25>
jp     1155 <medusa_dsp_change_sample_rate+0x25>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
jmp    11a3 <medusa_dsp_change_sample_rate+0x73>
sar    $0x2,%ebx
divss  %xmm0,%xmm1
cvtsi2ss %ebx,%xmm2
movss  %xmm2,0x4(%rsp)
mulss  %xmm2,%xmm1
movss  %xmm0,(%rsp)
movaps %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,%ebp
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movss  (%rsp),%xmm0
mulss  %xmm0,%xmm1
divss  0x4(%rsp),%xmm1
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
call   1050 <medusa_dsp_resample@plt>
shl    $0x2,%ebp
mov    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @medusa_dsp_change_sample_rate(float %0, float %1, float* %2, float* %3, i32 %4) {
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float*
%10 = alloca float*
%11 = alloca i32
%12 = alloca i32
store float %0, float* %7
store float %1, float* %8
store float* %2, float** %9
store float* %3, float** %10
store i32 %4, i32* %11
%13 = load float, float* %7
%14 = load float, float* %8
%15 = fcmp oeq float %13, %14
br i1 %15, label %16, label %22
16: ; preds = %5
%17 = load float*, float** %10
%18 = load float*, float** %9
%19 = load i32, i32* %11
%20 = call i32 @memcpy(float* %17, float* %18, i32 %19)
%21 = load i32, i32* %11
store i32 %21, i32* %6
br label %52
22: ; preds = %5
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = udiv i64 %24, 4
%26 = trunc i64 %25 to i32
store i32 %26, i32* %11
%27 = load float, float* %8
%28 = load float, float* %7
%29 = fdiv float %27, %28
%30 = load i32, i32* %11
%31 = sitofp i32 %30 to float
%32 = fmul float %29, %31
%33 = call i32 @ceil(float %32)
store i32 %33, i32* %12
%34 = load i32, i32* %12
%35 = sitofp i32 %34 to float
%36 = load float, float* %7
%37 = fmul float %35, %36
%38 = load i32, i32* %11
%39 = sitofp i32 %38 to float
%40 = fdiv float %37, %39
store float %40, float* %8
%41 = load float*, float** %9
%42 = load float*, float** %10
%43 = load i32, i32* %11
%44 = load i32, i32* %12
%45 = load float, float* %7
%46 = load float, float* %8
%47 = call i32 @medusa_dsp_resample(float* %41, float* %42, i32 %43, i32 %44, float %45, float %46)
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = mul i64 %49, 4
%51 = trunc i64 %50 to i32
store i32 %51, i32* %6
br label %52
52: ; preds = %22, %16
%53 = load i32, i32* %6
ret i32 %53
}

LLVM IR (-O2):
define i32 @medusa_dsp_change_sample_rate(float %0, float %1, float* %2, float* %3, i32 %4) {
%6 = fcmp oeq float %0, %1
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @memcpy(float* %3, float* %2, i32 %4)
br label %20
9: ; preds = %5
%10 = ashr i32 %4, 2
%11 = fdiv float %1, %0
%12 = sitofp i32 %10 to float
%13 = fmul float %11, %12
%14 = tail call i32 @ceil(float %13)
%15 = sitofp i32 %14 to float
%16 = fmul float %15, %0
%17 = fdiv float %16, %12
%18 = tail call i32 @medusa_dsp_resample(float* %2, float* %3, i32 %10, i32 %14, float %0, float %17)
%19 = shl i32 %14, 2
br label %20
20: ; preds = %9, %7
%21 = phi i32 [ %4, %7 ], [ %19, %9 ]
ret i32 %21
}