#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 trans_polar2rect(double **toTrans) {
  for (int i = 0; i < 3; i++) {
    double a = toTrans[i][0];
    double b = toTrans[i][1];
    toTrans[i][0] = a * cos(b);
    toTrans[i][1] = a * sin(b);
  }
}


x86 assembly (clang, -O0):
<trans_polar2rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11d7 <trans_polar2rect+0xb7>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x8(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <trans_polar2rect+0x13>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trans_polar2rect>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    (%rdi),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
mov    (%rbx),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
mov    (%rbx),%rax
movsd  %xmm0,0x8(%rax)
mov    0x8(%rbx),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
mov    0x8(%rbx),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
mov    0x8(%rbx),%rax
movsd  %xmm0,0x8(%rax)
mov    0x10(%rbx),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
mov    0x10(%rbx),%rax
movsd  %xmm0,(%rax)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
mov    0x10(%rbx),%rax
movsd  %xmm0,0x8(%rax)
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @trans_polar2rect(double** nocapture %0) {
%2 = load double*, double** %0
%3 = load double, double* %2
%4 = getelementptr inbounds double, double* %2, i64 1
%5 = load double, double* %4
%6 = tail call double @cos(double %5)
%7 = fmul double %3, %6
%8 = load double*, double** %0
store double %7, double* %8
%9 = tail call double @sin(double %5)
%10 = fmul double %3, %9
%11 = load double*, double** %0
%12 = getelementptr inbounds double, double* %11, i64 1
store double %10, double* %12
%13 = getelementptr inbounds double*, double** %0, i64 1
%14 = load double*, double** %13
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %14, i64 1
%17 = load double, double* %16
%18 = tail call double @cos(double %17)
%19 = fmul double %15, %18
%20 = load double*, double** %13
store double %19, double* %20
%21 = tail call double @sin(double %17)
%22 = fmul double %15, %21
%23 = load double*, double** %13
%24 = getelementptr inbounds double, double* %23, i64 1
store double %22, double* %24
%25 = getelementptr inbounds double*, double** %0, i64 2
%26 = load double*, double** %25
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %26, i64 1
%29 = load double, double* %28
%30 = tail call double @cos(double %29)
%31 = fmul double %27, %30
%32 = load double*, double** %25
store double %31, double* %32
%33 = tail call double @sin(double %29)
%34 = fmul double %27, %33
%35 = load double*, double** %25
%36 = getelementptr inbounds double, double* %35, i64 1
store double %34, double* %36
ret void
}