#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 */
float atan2f(float, float);
float sqrtf(float);
void get_info_from_bins(float *fft_p2, float *fft_magnitude, float *fft_phase,
                        int fft_size_2, int fft_size, float *fft_buffer) {
  int k;
  float real_p, imag_n, mag, p2, phase;
  real_p = fft_buffer[0];
  imag_n = 0.f;
  fft_p2[0] = real_p * real_p;
  fft_magnitude[0] = real_p;
  fft_phase[0] = atan2f(real_p, 0.f);
  for (k = 1; k <= fft_size_2; k++) {
    real_p = fft_buffer[k];
    imag_n = fft_buffer[fft_size - k];
    if (k < fft_size_2) {
      p2 = (real_p * real_p + imag_n * imag_n);
      mag = sqrtf(p2);
      phase = atan2f(real_p, imag_n);
    } else {
      p2 = real_p * real_p;
      mag = real_p;
      phase = atan2f(real_p, 0.f);
    }
    fft_p2[k] = p2;
    fft_magnitude[k] = mag;
    fft_phase[k] = phase;
  }
}


x86 assembly (clang, -O0):
<get_info_from_bins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x30(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1040 <atan2f@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1288 <get_info_from_bins+0x168>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1219 <get_info_from_bins+0xf9>
movss  -0x30(%rbp),%xmm0
movss  -0x30(%rbp),%xmm2
movss  -0x34(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
call   1040 <atan2f@plt>
movss  %xmm0,-0x40(%rbp)
jmp    1244 <get_info_from_bins+0x124>
movss  -0x30(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1040 <atan2f@plt>
movss  %xmm0,-0x40(%rbp)
movss  -0x3c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118f <get_info_from_bins+0x6f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_info_from_bins>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %rdx,%rbp
mov    %rdi,%r13
mov    %r9,0x18(%rsp)
movss  (%r9),%xmm0
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rdi)
mov    %rsi,0x20(%rsp)
movss  %xmm0,(%rsi)
xorps  %xmm1,%xmm1
call   1040 <atan2f@plt>
movss  %xmm0,0x0(%rbp)
test   %ebx,%ebx
jle    1258 <get_info_from_bins+0x138>
mov    %rbp,%r12
movslq %r14d,%rax
mov    %ebx,%ebp
add    $0x1,%ebx
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,4),%r15
add    $0xfffffffffffffffc,%r15
mov    $0x1,%r14d
jmp    11df <get_info_from_bins+0xbf>
nopl   0x0(%rax)
movaps %xmm3,%xmm0
mulss  %xmm3,%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm1,%xmm1
movss  %xmm3,0x8(%rsp)
movaps %xmm3,%xmm0
call   1040 <atan2f@plt>
movss  0xc(%rsp),%xmm1
movss  %xmm1,0x0(%r13,%r14,4)
mov    0x20(%rsp),%rax
movss  0x8(%rsp),%xmm1
movss  %xmm1,(%rax,%r14,4)
movss  %xmm0,(%r12,%r14,4)
add    $0x1,%r14
add    $0xfffffffffffffffc,%r15
cmp    %r14,%rbx
je     1258 <get_info_from_bins+0x138>
mov    0x18(%rsp),%rax
movss  (%rax,%r14,4),%xmm3
cmp    %rbp,%r14
jae    1190 <get_info_from_bins+0x70>
movss  (%r15),%xmm1
movaps %xmm1,%xmm2
mulss  %xmm1,%xmm2
movaps %xmm3,%xmm0
mulss  %xmm3,%xmm0
addss  %xmm2,%xmm0
ucomiss 0xdf3(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
jb     1230 <get_info_from_bins+0x110>
sqrtss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
jmp    11a6 <get_info_from_bins+0x86>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm3,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
call   1030 <sqrtf@plt>
movss  0x10(%rsp),%xmm1
movss  0x14(%rsp),%xmm3
movss  %xmm0,0x8(%rsp)
jmp    11a6 <get_info_from_bins+0x86>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @get_info_from_bins(float* %0, float* %1, float* %2, i32 %3, i32 %4, float* %5) {
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca i32
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
store float* %0, float** %7
store float* %1, float** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store float* %5, float** %12
%19 = load float*, float** %12
%20 = getelementptr inbounds float, float* %19, i64 0
%21 = load float, float* %20
store float %21, float* %14
store float 0.000000e+00, float* %15
%22 = load float, float* %14
%23 = load float, float* %14
%24 = fmul float %22, %23
%25 = load float*, float** %7
%26 = getelementptr inbounds float, float* %25, i64 0
store float %24, float* %26
%27 = load float, float* %14
%28 = load float*, float** %8
%29 = getelementptr inbounds float, float* %28, i64 0
store float %27, float* %29
%30 = load float, float* %14
%31 = call float @atan2f(float %30, float 0.000000e+00)
%32 = load float*, float** %9
%33 = getelementptr inbounds float, float* %32, i64 0
store float %31, float* %33
store i32 1, i32* %13
br label %34
34: ; preds = %89, %6
%35 = load i32, i32* %13
%36 = load i32, i32* %10
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %92
38: ; preds = %34
%39 = load float*, float** %12
%40 = load i32, i32* %13
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %39, i64 %41
%43 = load float, float* %42
store float %43, float* %14
%44 = load float*, float** %12
%45 = load i32, i32* %11
%46 = load i32, i32* %13
%47 = sub nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %44, i64 %48
%50 = load float, float* %49
store float %50, float* %15
%51 = load i32, i32* %13
%52 = load i32, i32* %10
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %66
54: ; preds = %38
%55 = load float, float* %14
%56 = load float, float* %14
%57 = load float, float* %15
%58 = load float, float* %15
%59 = fmul float %57, %58
%60 = call float @llvm.fmuladd.f32(float %55, float %56, float %59)
store float %60, float* %17
%61 = load float, float* %17
%62 = call float @sqrtf(float %61)
store float %62, float* %16
%63 = load float, float* %14
%64 = load float, float* %15
%65 = call float @atan2f(float %63, float %64)
store float %65, float* %18
br label %73
66: ; preds = %38
%67 = load float, float* %14
%68 = load float, float* %14
%69 = fmul float %67, %68
store float %69, float* %17
%70 = load float, float* %14
store float %70, float* %16
%71 = load float, float* %14
%72 = call float @atan2f(float %71, float 0.000000e+00)
store float %72, float* %18
br label %73
73: ; preds = %66, %54
%74 = load float, float* %17
%75 = load float*, float** %7
%76 = load i32, i32* %13
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %75, i64 %77
store float %74, float* %78
%79 = load float, float* %16
%80 = load float*, float** %8
%81 = load i32, i32* %13
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds float, float* %80, i64 %82
store float %79, float* %83
%84 = load float, float* %18
%85 = load float*, float** %9
%86 = load i32, i32* %13
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds float, float* %85, i64 %87
store float %84, float* %88
br label %89
89: ; preds = %73
%90 = load i32, i32* %13
%91 = add nsw i32 %90, 1
store i32 %91, i32* %13
br label %34
92: ; preds = %34
ret void
}

LLVM IR (-O2):
define void @get_info_from_bins(float* nocapture writeonly %0, float* nocapture writeonly %1, float* nocapture writeonly %2, i32 %3, i32 %4, float* nocapture %5) {
%7 = load float, float* %5
%8 = fmul float %7, %7
store float %8, float* %0
store float %7, float* %1
%9 = tail call float @atan2f(float %7, float 0.000000e+00)
store float %9, float* %2
%10 = icmp slt i32 %3, 1
br i1 %10, label %40, label %11
11: ; preds = %6
%12 = sext i32 %4 to i64
%13 = zext i32 %3 to i64
%14 = add nuw i32 %3, 1
%15 = zext i32 %14 to i64
br label %16
16: ; preds = %11, %30
%17 = phi i64 [ 1, %11 ], [ %38, %30 ]
%18 = getelementptr inbounds float, float* %5, i64 %17
%19 = load float, float* %18
%20 = sub nsw i64 %12, %17
%21 = getelementptr inbounds float, float* %5, i64 %20
%22 = load float, float* %21
%23 = icmp ult i64 %17, %13
br i1 %23, label %24, label %28
24: ; preds = %16
%25 = fmul float %22, %22
%26 = tail call float @llvm.fmuladd.f32(float %19, float %19, float %25)
%27 = tail call float @sqrtf(float %26)
br label %30
28: ; preds = %16
%29 = fmul float %19, %19
br label %30
30: ; preds = %28, %24
%31 = phi float [ 0.000000e+00, %28 ], [ %22, %24 ]
%32 = phi float [ %19, %28 ], [ %27, %24 ]
%33 = phi float [ %29, %28 ], [ %26, %24 ]
%34 = tail call float @atan2f(float %19, float %31)
%35 = getelementptr inbounds float, float* %0, i64 %17
store float %33, float* %35
%36 = getelementptr inbounds float, float* %1, i64 %17
store float %32, float* %36
%37 = getelementptr inbounds float, float* %2, i64 %17
store float %34, float* %37
%38 = add nuw nsw i64 %17, 1
%39 = icmp eq i64 %38, %15
br i1 %39, label %40, label %16
40: ; preds = %30, %6
ret void
}