#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 polar_to_rect(double r, double th, const int a[2], int b[2]) {
  b[0] = a[0] + r * sin(th);
  b[1] = a[1] + r * cos(th);
}


x86 assembly (clang, -O0):
<polar_to_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cvtsi2sdl 0x4(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<polar_to_rect>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdl (%rdi),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm1,%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%r14)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rbx),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x4(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @polar_to_rect(double %0, double %1, i32* %2, i32* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i32*
%8 = alloca i32*
store double %0, double* %5
store double %1, double* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%9 = load i32*, i32** %7
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
%12 = sitofp i32 %11 to double
%13 = load double, double* %5
%14 = load double, double* %6
%15 = call double @sin(double %14)
%16 = call double @llvm.fmuladd.f64(double %13, double %15, double %12)
%17 = fptosi double %16 to i32
%18 = load i32*, i32** %8
%19 = getelementptr inbounds i32, i32* %18, i64 0
store i32 %17, i32* %19
%20 = load i32*, i32** %7
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = sitofp i32 %22 to double
%24 = load double, double* %5
%25 = load double, double* %6
%26 = call double @cos(double %25)
%27 = call double @llvm.fmuladd.f64(double %24, double %26, double %23)
%28 = fptosi double %27 to i32
%29 = load i32*, i32** %8
%30 = getelementptr inbounds i32, i32* %29, i64 1
store i32 %28, i32* %30
ret void
}

LLVM IR (-O2):
define void @polar_to_rect(double %0, double %1, i32* nocapture %2, i32* nocapture writeonly %3) {
%5 = load i32, i32* %2
%6 = sitofp i32 %5 to double
%7 = tail call double @sin(double %1)
%8 = tail call double @llvm.fmuladd.f64(double %0, double %7, double %6)
%9 = fptosi double %8 to i32
store i32 %9, i32* %3
%10 = getelementptr inbounds i32, i32* %2, i64 1
%11 = load i32, i32* %10
%12 = sitofp i32 %11 to double
%13 = tail call double @cos(double %1)
%14 = tail call double @llvm.fmuladd.f64(double %0, double %13, double %12)
%15 = fptosi double %14 to i32
%16 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %15, i32* %16
ret void
}