#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 M_PI;
scalar_t__ cos(int);
scalar_t__ sin(int);
void compute(double val, double f, double *re, double *im) {
  *re += cos(2 * M_PI * f * val / 1000000.0);
  *im += sin(2 * M_PI * f * val / 1000000.0);
}


x86 assembly (clang, -O0):
<compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xea4(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
cvtsi2sd %rax,%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xe64(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
cvtsi2sd %rax,%xmm0
mov    -0x20(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    0x2ea7(%rip),%r15
mov    (%r15),%eax
add    %eax,%eax
cvtsi2sd %eax,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
divsd  0xea6(%rip),%xmm2
cvttsd2si %xmm2,%edi
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rbx),%xmm0
movsd  %xmm0,(%rbx)
mov    (%r15),%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  0xe6e(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%r14),%xmm0
movsd  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @compute(double %0, double %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%9 = load i32, i32* @M_PI
%10 = mul nsw i32 2, %9
%11 = sitofp i32 %10 to double
%12 = load double, double* %6
%13 = fmul double %11, %12
%14 = load double, double* %5
%15 = fmul double %13, %14
%16 = fdiv double %15, 1.000000e+06
%17 = fptosi double %16 to i32
%18 = call i64 @cos(i32 %17)
%19 = sitofp i64 %18 to double
%20 = load double*, double** %7
%21 = load double, double* %20
%22 = fadd double %21, %19
store double %22, double* %20
%23 = load i32, i32* @M_PI
%24 = mul nsw i32 2, %23
%25 = sitofp i32 %24 to double
%26 = load double, double* %6
%27 = fmul double %25, %26
%28 = load double, double* %5
%29 = fmul double %27, %28
%30 = fdiv double %29, 1.000000e+06
%31 = fptosi double %30 to i32
%32 = call i64 @sin(i32 %31)
%33 = sitofp i64 %32 to double
%34 = load double*, double** %8
%35 = load double, double* %34
%36 = fadd double %35, %33
store double %36, double* %34
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @compute(double %0, double %1, double* nocapture %2, double* nocapture %3) {
%5 = load i32, i32* @M_PI
%6 = shl nsw i32 %5, 1
%7 = sitofp i32 %6 to double
%8 = fmul double %7, %1
%9 = fmul double %8, %0
%10 = fdiv double %9, 1.000000e+06
%11 = fptosi double %10 to i32
%12 = tail call i64 @cos(i32 %11)
%13 = sitofp i64 %12 to double
%14 = load double, double* %2
%15 = fadd double %14, %13
store double %15, double* %2
%16 = load i32, i32* @M_PI
%17 = shl nsw i32 %16, 1
%18 = sitofp i32 %17 to double
%19 = fmul double %18, %1
%20 = fmul double %19, %0
%21 = fdiv double %20, 1.000000e+06
%22 = fptosi double %21 to i32
%23 = tail call i64 @sin(i32 %22)
%24 = sitofp i64 %23 to double
%25 = load double, double* %3
%26 = fadd double %25, %24
store double %26, double* %3
ret void
}