#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 */
double cos(double);
double sin(double);
void sms_PolarToRect(int sizeSpec, double *pRect, double *pMag,
                     double *pPhase) {
  int i, it2;
  double fMag;
  for (i = 0; i < sizeSpec; i++) {
    it2 = i << 1;
    fMag = pMag[i];
    pRect[it2] = fMag * cos(pPhase[i]);
    pRect[it2 + 1] = fMag * sin(pPhase[i]);
  }
}


x86 assembly (clang, -O0):
<sms_PolarToRect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e2 <sms_PolarToRect+0xc2>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <sms_PolarToRect+0x1e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sms_PolarToRect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11ab <sms_PolarToRect+0x8b>
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r13
mov    %edi,%r12d
add    %r12,%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r14,%rbp,4),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r15,%rbp,4),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
mov    %rbx,%rax
sar    $0x1d,%rax
movsd  %xmm0,0x0(%r13,%rax,1)
movsd  (%r15,%rbp,4),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
lea    0x1(%rbp),%eax
cltq
movsd  %xmm0,0x0(%r13,%rax,8)
add    $0x2,%rbp
movabs $0x200000000,%rax
add    %rax,%rbx
cmp    %rbp,%r12
jne    1150 <sms_PolarToRect+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sms_PolarToRect(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store i32 0, i32* %9
br label %12
12: ; preds = %49, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %52
16: ; preds = %12
%17 = load i32, i32* %9
%18 = shl i32 %17, 1
store i32 %18, i32* %10
%19 = load double*, double** %7
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
store double %23, double* %11
%24 = load double, double* %11
%25 = load double*, double** %8
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = call double @cos(double %29)
%31 = fmul double %24, %30
%32 = load double*, double** %6
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
store double %31, double* %35
%36 = load double, double* %11
%37 = load double*, double** %8
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = call double @sin(double %41)
%43 = fmul double %36, %42
%44 = load double*, double** %6
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %44, i64 %47
store double %43, double* %48
br label %49
49: ; preds = %16
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %12
52: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @sms_PolarToRect(i32 %0, double* nocapture writeonly %1, double* nocapture %2, double* nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %29
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %27, %8 ]
%10 = getelementptr inbounds double, double* %2, i64 %9
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %3, i64 %9
%13 = load double, double* %12
%14 = tail call double @cos(double %13)
%15 = fmul double %11, %14
%16 = shl i64 %9, 33
%17 = ashr exact i64 %16, 32
%18 = getelementptr inbounds double, double* %1, i64 %17
store double %15, double* %18
%19 = load double, double* %12
%20 = tail call double @sin(double %19)
%21 = fmul double %11, %20
%22 = trunc i64 %9 to i32
%23 = shl i32 %22, 1
%24 = or i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %1, i64 %25
store double %21, double* %26
%27 = add nuw nsw i64 %9, 1
%28 = icmp eq i64 %27, %7
br i1 %28, label %29, label %8
29: ; preds = %8, %4
ret void
}