// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/lib/rra.c
// Function: rra2fft
double *
rra2fft(RRA *h,int channel,int *length)
    {
    int i;
    double *data = 0;
    double max;

    if (channel >= h->channels)
        Fatal("not enough channels (channel zero is the first channel)\n");

    *length = (int) pow(2,ceil(log((double)h->samples)/log(2.0)));
    //printf("h->channels is %d\n",h->channels);
    //printf("samples is %d\n",h->samples);
    //printf("fftLength is %d\n",*length);

    /* fft uses one-based counting! */

    data = (double *) New(2*((*length)+1) * sizeof(double));

    /* fill the data array data here */

    max = pow(2,h->bitsPerSample - 1);
    //printf("max is %f\n",max);

    for (i = 0; i < h->samples && i < *length; ++i)
        {
        data[i * 2 + 1] = h->data[channel][i] / max;
        data[i * 2 + 2] = 0.0;
        }

    /* fill the remainder of the data array with zeros */

    for ( ; i < *length; ++i)
        {
        data[i * 2 + 1] = 0.0;
        data[i * 2 + 2] = 0.0;
        }

    /* call the fft */

    fft(data,*length,1);

    return data;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x3744
leaq 0xd26(%rip), %rdi       # 0x4463
movb $0x0, %al
callq 0x1580
movq -0x8(%rbp), %rax
cvtsi2sdl 0xc(%rax), %xmm0
callq 0x10d0
movsd %xmm0, -0x38(%rbp)
movsd 0x9d9(%rip), %xmm0      # 0x4138
callq 0x10d0
movaps %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
divsd %xmm1, %xmm0
callq 0x11f0
movaps %xmm0, %xmm1
movsd 0x9b8(%rip), %xmm0      # 0x4138
callq 0x1060
cvttsd2si %xmm0, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
shll %eax
cltq
shlq $0x3, %rax
movl %eax, %edi
callq 0x17d0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x977(%rip), %xmm0      # 0x4138
callq 0x1060
movsd %xmm0, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0xc(%rdx), %ecx
movb %al, -0x39(%rbp)
jge 0x37f2
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
setl %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x37fb
jmp 0x384f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
divsd -0x30(%rbp), %xmm0
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x37d2
jmp 0x3851
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x3895
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3851
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
movl $0x1, %edx
callq 0x38c0
movq -0x28(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)