#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 atan2(double, double);
double cos(double);
double sin(double);
double sqrt(double);
void roots3(double d[3], double c0, double c1, double c2) {
  double c2Div3, aDiv3, mbDiv2, q, magnitude, angle, cs, sn;
  c2Div3 = -c2 * 0.3333333333333333;
  aDiv3 = (c1 + c2 * c2Div3) * 0.3333333333333333;
  if (aDiv3 > 0.0) {
    aDiv3 = 0.0;
  }
  mbDiv2 = 0.5 * (-c0 + c2Div3 * (2.0 * c2Div3 * c2Div3 - c1));
  q = mbDiv2 * mbDiv2 + aDiv3 * aDiv3 * aDiv3;
  if (q > 0.0) {
    q = 0.0;
  }
  magnitude = sqrt(-aDiv3);
  angle = atan2(sqrt(-q), mbDiv2) * 0.3333333333333333;
  cs = cos(angle);
  sn = sin(angle);
  d[0] = c2Div3 + 2.0 * magnitude * cs;
  d[1] = c2Div3 - magnitude * (cs + 1.7320508075688772 * sn);
  d[2] = c2Div3 - magnitude * (cs - 1.7320508075688772 * sn);
}


x86 assembly (clang, -O0):
<roots3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe81(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe59(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ca <roots3+0x8a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe1d(%rip),%xmm2
mulsd  -0x28(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm4
movsd  -0x18(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdd7(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    127a <roots3+0x13a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1060 <sqrt@plt>
movsd  -0x38(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  0xd2d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xd09(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm2
movsd  0xce3(%rip),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm2
movsd  0xc8f(%rip),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roots3>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
movsd  0xeb0(%rip),%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
mulsd  0xea4(%rip),%xmm2
xorpd  %xmm5,%xmm5
xorpd  %xmm3,%xmm3
minsd  %xmm2,%xmm3
movapd %xmm4,%xmm2
addsd  %xmm4,%xmm2
mulsd  %xmm4,%xmm2
subsd  %xmm1,%xmm2
movapd %xmm4,0x30(%rsp)
mulsd  %xmm4,%xmm2
subsd  %xmm0,%xmm2
mulsd  0xe7a(%rip),%xmm2
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm3,%xmm0
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
minsd  %xmm1,%xmm5
movapd 0xe70(%rip),%xmm0
xorpd  %xmm3,%xmm0
movsd  0xe4c(%rip),%xmm1
ucomisd %xmm3,%xmm1
jb     11d8 <roots3+0x98>
sqrtsd %xmm0,%xmm0
jmp    11ef <roots3+0xaf>
movapd %xmm5,(%rsp)
call   1060 <sqrt@plt>
movsd  0xe2e(%rip),%xmm1
movapd (%rsp),%xmm5
movapd %xmm0,0x20(%rsp)
ucomisd %xmm5,%xmm1
xorpd  0xe2f(%rip),%xmm5
jb     120c <roots3+0xcc>
xorps  %xmm0,%xmm0
sqrtsd %xmm5,%xmm0
jmp    1215 <roots3+0xd5>
movapd %xmm5,%xmm0
call   1060 <sqrt@plt>
movaps 0x10(%rsp),%xmm1
call   1030 <atan2@plt>
mulsd  0xde1(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <cos@plt>
movapd %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movapd 0x20(%rsp),%xmm4
movapd %xmm4,%xmm1
addsd  %xmm4,%xmm1
movsd  0xdc9(%rip),%xmm2
mulsd  %xmm0,%xmm2
movapd 0x10(%rsp),%xmm5
addsd  %xmm5,%xmm2
movapd 0xdc3(%rip),%xmm3
xorpd  %xmm4,%xmm3
unpcklpd %xmm3,%xmm1
movapd %xmm5,%xmm3
unpcklpd %xmm2,%xmm3
mulpd  %xmm1,%xmm3
movapd 0x30(%rsp),%xmm2
movapd %xmm2,%xmm1
unpcklpd %xmm2,%xmm1
addpd  %xmm3,%xmm1
movupd %xmm1,(%rbx)
mulsd  0xd89(%rip),%xmm0
addsd  %xmm5,%xmm0
mulsd  %xmm4,%xmm0
subsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rbx)
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @roots3(double* %0, double %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%17 = load double, double* %8
%18 = fneg double %17
%19 = fmul double %18, 0x3FD5555555555555
store double %19, double* %9
%20 = load double, double* %7
%21 = load double, double* %8
%22 = load double, double* %9
%23 = call double @llvm.fmuladd.f64(double %21, double %22, double %20)
%24 = fmul double %23, 0x3FD5555555555555
store double %24, double* %10
%25 = load double, double* %10
%26 = fcmp ogt double %25, 0.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %4
store double 0.000000e+00, double* %10
br label %28
28: ; preds = %27, %4
%29 = load double, double* %6
%30 = fneg double %29
%31 = load double, double* %9
%32 = load double, double* %9
%33 = fmul double 2.000000e+00, %32
%34 = load double, double* %9
%35 = load double, double* %7
%36 = fneg double %35
%37 = call double @llvm.fmuladd.f64(double %33, double %34, double %36)
%38 = call double @llvm.fmuladd.f64(double %31, double %37, double %30)
%39 = fmul double 5.000000e-01, %38
store double %39, double* %11
%40 = load double, double* %11
%41 = load double, double* %11
%42 = load double, double* %10
%43 = load double, double* %10
%44 = fmul double %42, %43
%45 = load double, double* %10
%46 = fmul double %44, %45
%47 = call double @llvm.fmuladd.f64(double %40, double %41, double %46)
store double %47, double* %12
%48 = load double, double* %12
%49 = fcmp ogt double %48, 0.000000e+00
br i1 %49, label %50, label %51
50: ; preds = %28
store double 0.000000e+00, double* %12
br label %51
51: ; preds = %50, %28
%52 = load double, double* %10
%53 = fneg double %52
%54 = call double @sqrt(double %53)
store double %54, double* %13
%55 = load double, double* %12
%56 = fneg double %55
%57 = call double @sqrt(double %56)
%58 = load double, double* %11
%59 = call double @atan2(double %57, double %58)
%60 = fmul double %59, 0x3FD5555555555555
store double %60, double* %14
%61 = load double, double* %14
%62 = call double @cos(double %61)
store double %62, double* %15
%63 = load double, double* %14
%64 = call double @sin(double %63)
store double %64, double* %16
%65 = load double, double* %9
%66 = load double, double* %13
%67 = fmul double 2.000000e+00, %66
%68 = load double, double* %15
%69 = call double @llvm.fmuladd.f64(double %67, double %68, double %65)
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 0
store double %69, double* %71
%72 = load double, double* %9
%73 = load double, double* %13
%74 = load double, double* %15
%75 = load double, double* %16
%76 = call double @llvm.fmuladd.f64(double 0x3FFBB67AE8584CAA, double %75, double %74)
%77 = fneg double %73
%78 = call double @llvm.fmuladd.f64(double %77, double %76, double %72)
%79 = load double*, double** %5
%80 = getelementptr inbounds double, double* %79, i64 1
store double %78, double* %80
%81 = load double, double* %9
%82 = load double, double* %13
%83 = load double, double* %15
%84 = load double, double* %16
%85 = call double @llvm.fmuladd.f64(double 0xBFFBB67AE8584CAA, double %84, double %83)
%86 = fneg double %82
%87 = call double @llvm.fmuladd.f64(double %86, double %85, double %81)
%88 = load double*, double** %5
%89 = getelementptr inbounds double, double* %88, i64 2
store double %87, double* %89
ret void
}

LLVM IR (-O2):
define void @roots3(double* nocapture writeonly %0, double %1, double %2, double %3) {
%5 = fmul double %3, 0xBFD5555555555555
%6 = tail call double @llvm.fmuladd.f64(double %3, double %5, double %2)
%7 = fmul double %6, 0x3FD5555555555555
%8 = fcmp ogt double %7, 0.000000e+00
%9 = select i1 %8, double 0.000000e+00, double %7
%10 = fneg double %1
%11 = fmul double %5, 2.000000e+00
%12 = fneg double %2
%13 = tail call double @llvm.fmuladd.f64(double %11, double %5, double %12)
%14 = tail call double @llvm.fmuladd.f64(double %5, double %13, double %10)
%15 = fmul double %14, 5.000000e-01
%16 = fmul double %9, %9
%17 = fmul double %9, %16
%18 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %17)
%19 = fcmp ogt double %18, 0.000000e+00
%20 = select i1 %19, double 0.000000e+00, double %18
%21 = fneg double %9
%22 = tail call double @sqrt(double %21)
%23 = fneg double %20
%24 = tail call double @sqrt(double %23)
%25 = tail call double @atan2(double %24, double %15)
%26 = fmul double %25, 0x3FD5555555555555
%27 = tail call double @cos(double %26)
%28 = tail call double @sin(double %26)
%29 = fmul double %22, 2.000000e+00
%30 = tail call double @llvm.fmuladd.f64(double %28, double 0x3FFBB67AE8584CAA, double %27)
%31 = fneg double %22
%32 = insertelement <2 x double> poison, double %29, i64 0
%33 = insertelement <2 x double> %32, double %31, i64 1
%34 = insertelement <2 x double> poison, double %27, i64 0
%35 = insertelement <2 x double> %34, double %30, i64 1
%36 = insertelement <2 x double> poison, double %5, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %35, <2 x double> %37)
%39 = bitcast double* %0 to <2 x double>*
store <2 x double> %38, <2 x double>* %39
%40 = tail call double @llvm.fmuladd.f64(double %28, double 0xBFFBB67AE8584CAA, double %27)
%41 = tail call double @llvm.fmuladd.f64(double %31, double %40, double %5)
%42 = getelementptr inbounds double, double* %0, i64 2
store double %41, double* %42
ret void
}