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


x86 assembly (clang, -O0):
<trans_polar2rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11db <trans_polar2rect+0xbb>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <trans_polar2rect+0x17>
add    $0x40,%rsp
pop    %rbp
ret

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

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

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