#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 EXIT_SUCCESS;
float atanf(float);
float sqrt(float);
int complexConvert(float *real, float *imag, float *mag, float *phase, int n) {
  int i;
  for (i = 0; i < n; i++) {
    *(mag + i) = sqrt(*(real + i) * *(real + i) + *(imag + i) * *(imag + i));
    *(phase + i) = atanf(*(imag + i) / *(real + i));
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<complexConvert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11d7 <complexConvert+0xb7>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
divss  (%rax,%rcx,4),%xmm0
call   1030 <atanf@plt>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1143 <complexConvert+0x23>
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<complexConvert>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r8d,%r8d
jle    11a0 <complexConvert+0x80>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %r8d,%r13d
xor    %ebp,%ebp
jmp    117a <complexConvert+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <sqrt@plt>
movss  %xmm0,(%r15,%rbp,4)
movss  (%r12,%rbp,4),%xmm0
divss  (%rbx,%rbp,4),%xmm0
call   1030 <atanf@plt>
movss  %xmm0,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
je     11a0 <complexConvert+0x80>
movss  (%rbx,%rbp,4),%xmm0
movss  (%r12,%rbp,4),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss 0xe68(%rip),%xmm0
jb     1150 <complexConvert+0x30>
sqrtss %xmm0,%xmm0
jmp    1155 <complexConvert+0x35>
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @complexConvert(float* nocapture %0, float* nocapture %1, float* nocapture writeonly %2, float* nocapture writeonly %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %26
7: ; preds = %5
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %24, %9 ]
%11 = getelementptr inbounds float, float* %0, i64 %10
%12 = load float, float* %11
%13 = getelementptr inbounds float, float* %1, i64 %10
%14 = load float, float* %13
%15 = fmul float %14, %14
%16 = tail call float @llvm.fmuladd.f32(float %12, float %12, float %15)
%17 = tail call float @sqrt(float %16)
%18 = getelementptr inbounds float, float* %2, i64 %10
store float %17, float* %18
%19 = load float, float* %13
%20 = load float, float* %11
%21 = fdiv float %19, %20
%22 = tail call float @atanf(float %21)
%23 = getelementptr inbounds float, float* %3, i64 %10
store float %22, float* %23
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %8
br i1 %25, label %26, label %9
26: ; preds = %9, %5
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}