#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 atan2(int /*<<< orphan*/, int /*<<< orphan*/);
void calculatePhase(float *realdata, float *imagdata, float *phasedata,
                    long npts, float phasestart, float phasescale) {
  long count;
  float radianphase;
  phasescale = 1.0;
  for (count = 0; count < npts; count++) {
    radianphase = atan2(*imagdata++, *realdata++);
    *phasedata++ = (radianphase + phasestart + 3.14159265) * phasescale;
  }
  return;
}


x86 assembly (clang, -O0):
<calculatePhase>:
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)
movss  0xec6(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11d4 <calculatePhase+0xc4>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
cvttss2si (%rax),%edi
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
cvttss2si (%rax),%esi
call   1030 <atan2@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6d(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1147 <calculatePhase+0x37>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculatePhase>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %rcx,%rcx
jle    117b <calculatePhase+0x6b>
movaps %xmm0,%xmm1
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
xor    %ebx,%ebx
movss  %xmm0,0xc(%rsp)
nopl   0x0(%rax)
cvttss2si (%r15,%rbx,4),%edi
cvttss2si 0x0(%r13,%rbx,4),%esi
call   1030 <atan2@plt>
movss  0xc(%rsp),%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xe98(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <calculatePhase+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @calculatePhase(float* %0, float* %1, float* %2, i64 %3, float %4, float %5) {
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca i64
%11 = alloca float
%12 = alloca float
%13 = alloca i64
%14 = alloca float
store float* %0, float** %7
store float* %1, float** %8
store float* %2, float** %9
store i64 %3, i64* %10
store float %4, float* %11
store float %5, float* %12
store float 1.000000e+00, float* %12
store i64 0, i64* %13
br label %15
15: ; preds = %40, %6
%16 = load i64, i64* %13
%17 = load i64, i64* %10
%18 = icmp slt i64 %16, %17
br i1 %18, label %19, label %43
19: ; preds = %15
%20 = load float*, float** %8
%21 = getelementptr inbounds float, float* %20, i32 1
store float* %21, float** %8
%22 = load float, float* %20
%23 = fptosi float %22 to i32
%24 = load float*, float** %7
%25 = getelementptr inbounds float, float* %24, i32 1
store float* %25, float** %7
%26 = load float, float* %24
%27 = fptosi float %26 to i32
%28 = call float @atan2(i32 %23, i32 %27)
store float %28, float* %14
%29 = load float, float* %14
%30 = load float, float* %11
%31 = fadd float %29, %30
%32 = fpext float %31 to double
%33 = fadd double %32, 0x400921FB53C8D4F1
%34 = load float, float* %12
%35 = fpext float %34 to double
%36 = fmul double %33, %35
%37 = fptrunc double %36 to float
%38 = load float*, float** %9
%39 = getelementptr inbounds float, float* %38, i32 1
store float* %39, float** %9
store float %37, float* %38
br label %40
40: ; preds = %19
%41 = load i64, i64* %13
%42 = add nsw i64 %41, 1
store i64 %42, i64* %13
br label %15
43: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @calculatePhase(float* nocapture %0, float* nocapture %1, float* nocapture writeonly %2, i64 %3, float %4, float %5) {
%7 = icmp sgt i64 %3, 0
br i1 %7, label %8, label %27
8: ; preds = %6, %8
%9 = phi float* [ %16, %8 ], [ %0, %6 ]
%10 = phi i64 [ %25, %8 ], [ 0, %6 ]
%11 = phi float* [ %13, %8 ], [ %1, %6 ]
%12 = phi float* [ %24, %8 ], [ %2, %6 ]
%13 = getelementptr inbounds float, float* %11, i64 1
%14 = load float, float* %11
%15 = fptosi float %14 to i32
%16 = getelementptr inbounds float, float* %9, i64 1
%17 = load float, float* %9
%18 = fptosi float %17 to i32
%19 = tail call float @atan2(i32 %15, i32 %18)
%20 = fadd float %19, %4
%21 = fpext float %20 to double
%22 = fadd double %21, 0x400921FB53C8D4F1
%23 = fptrunc double %22 to float
%24 = getelementptr inbounds float, float* %12, i64 1
store float %23, float* %12
%25 = add nuw nsw i64 %10, 1
%26 = icmp eq i64 %25, %3
br i1 %26, label %27, label %8
27: ; preds = %8, %6
ret void
}