#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);
double *speed_correction(double sspd, double sdir, double r, double rmaxw) {
  double magnitude;
  static double correction[2];
  magnitude = sspd * (rmaxw * r / (r * r + rmaxw * rmaxw));
  correction[0] = magnitude * cos(sdir);
  correction[1] = magnitude * sin(sdir);
  return correction;
}


x86 assembly (clang, -O0):
<speed_correction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm4
movsd  -0x20(%rbp),%xmm3
mulsd  -0x20(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2ea4(%rip)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2e84(%rip)
lea    0x2e75(%rip),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speed_correction>:
push   %rbx
sub    $0x10,%rsp
movapd %xmm1,%xmm4
movsd  %xmm1,0x8(%rsp)
movapd %xmm2,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm3
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm4,%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x2eda(%rip)
lea    0x2ed3(%rip),%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x2ec3(%rip)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@speed_correction.correction = internal global [2 x double] zeroinitializer
define double* @speed_correction(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%10 = load double, double* %5
%11 = load double, double* %8
%12 = load double, double* %7
%13 = fmul double %11, %12
%14 = load double, double* %7
%15 = load double, double* %7
%16 = load double, double* %8
%17 = load double, double* %8
%18 = fmul double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %15, double %18)
%20 = fdiv double %13, %19
%21 = fmul double %10, %20
store double %21, double* %9
%22 = load double, double* %9
%23 = load double, double* %6
%24 = call double @cos(double %23)
%25 = fmul double %22, %24
store double %25, double* getelementptr inbounds ([2 x double], [2 x double]* @speed_correction.correction, i64 0, i64 0)
%26 = load double, double* %9
%27 = load double, double* %6
%28 = call double @sin(double %27)
%29 = fmul double %26, %28
store double %29, double* getelementptr inbounds ([2 x double], [2 x double]* @speed_correction.correction, i64 0, i64 1)
ret double* getelementptr inbounds ([2 x double], [2 x double]* @speed_correction.correction, i64 0, i64 0)
}

LLVM IR (-O2):
@speed_correction.correction = internal global [2 x double] zeroinitializer
define double* @speed_correction(double %0, double %1, double %2, double %3) {
%5 = fmul double %2, %3
%6 = fmul double %3, %3
%7 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %6)
%8 = fdiv double %5, %7
%9 = fmul double %8, %0
%10 = tail call double @cos(double %1)
%11 = fmul double %9, %10
store double %11, double* getelementptr inbounds ([2 x double], [2 x double]* @speed_correction.correction, i64 0, i64 0)
%12 = tail call double @sin(double %1)
%13 = fmul double %9, %12
store double %13, double* getelementptr inbounds ([2 x double], [2 x double]* @speed_correction.correction, i64 0, i64 1)
ret double* getelementptr inbounds ([2 x double], [2 x double]* @speed_correction.correction, i64 0, i64 0)
}