#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 */
long double acos(long double);
int cos(double);
long double fabs(long double);
long double sqrt(long double);
int gl3grades(long double a, long double b, long double c, double *x) {
  long double p, q, phi;
  p = (b - a * a / 3.) / 3.;
  q = (a * a * a / 13.5 - a * b / 3. + c) * .5;
  p = sqrt(fabs(p)) * fabs(q) / q;
  phi = q / (p * p * p);
  if (phi > 1.0)
    phi = 0.;
  else if (phi < -1.0)
    phi = 3.14159265358979323846264338327950288;
  else
    phi = acos(phi);
  x[0] = -2 * p * cos(phi / 3.) - a / 3.;
  x[1] = 2 * p * cos(3.14159265358979323846264338327950288 / 3. - phi / 3.) -
         a / 3.;
  x[2] = 2 * p * cos(3.14159265358979323846264338327950288 / 3. + phi / 3.) -
         a / 3.;
  return (1);
}


x86 assembly (clang, -O0):
<gl3grades>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
fldt   0x30(%rbp)
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
mov    %rdi,-0x38(%rbp)
fldt   -0x20(%rbp)
fldt   -0x10(%rbp)
fmul   %st,%st(0)
flds   0xe91(%rip)
fdivr  %st,%st(1)
fxch   %st(2)
fsubp  %st,%st(1)
fdiv   %st(1),%st
fstpt  -0x50(%rbp)
fldt   -0x10(%rbp)
fld    %st(0)
fmul   %st(1),%st
fmul   %st(1),%st
flds   0xe7b(%rip)
fdivrp %st,%st(1)
fldt   -0x20(%rbp)
fmulp  %st,%st(2)
fxch   %st(1)
fdivp  %st,%st(2)
fsubp  %st,%st(1)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
flds   0xe67(%rip)
fmulp  %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fabs@plt>
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <sqrt@plt>
fstpt  -0xac(%rbp)
fldt   -0x60(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fabs@plt>
fldt   -0xac(%rbp)
fmulp  %st,%st(1)
fldt   -0x60(%rbp)
fdivrp %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x60(%rbp)
fldt   -0x50(%rbp)
fld    %st(0)
fmul   %st(1),%st
fmulp  %st,%st(1)
fdivrp %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x70(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1211 <gl3grades+0xd1>
jmp    1207 <gl3grades+0xc7>
fldz
fstpt  -0x70(%rbp)
jmp    124a <gl3grades+0x10a>
fldt   -0x70(%rbp)
fld1
fchs
fucomip %st(1),%st
fstp   %st(0)
jbe    1235 <gl3grades+0xf5>
jmp    1227 <gl3grades+0xe7>
fldl   0xde3(%rip)
fstpt  -0x70(%rbp)
jmp    1245 <gl3grades+0x105>
fldt   -0x70(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <acos@plt>
fstpt  -0x70(%rbp)
jmp    124a <gl3grades+0x10a>
fldt   -0x50(%rbp)
flds   0xdb9(%rip)
fmulp  %st,%st(1)
fstpt  -0xe8(%rbp)
fldt   -0x70(%rbp)
flds   0xd9c(%rip)
fld    %st(0)
fstpt  -0xc4(%rbp)
fdivrp %st,%st(1)
fstpl  -0x88(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
call   1050 <cos@plt>
fldt   -0xe8(%rbp)
fldt   -0xc4(%rbp)
mov    %eax,-0x7c(%rbp)
fildl  -0x7c(%rbp)
fldt   -0x10(%rbp)
fdiv   %st(2),%st
fxch   %st(3)
fmulp  %st,%st(1)
fsubp  %st,%st(2)
mov    -0x38(%rbp),%rax
fxch   %st(1)
fstpl  (%rax)
fldt   -0x50(%rbp)
fadd   %st,%st(0)
fstpt  -0xdc(%rbp)
fldt   -0x70(%rbp)
fdivp  %st,%st(1)
fldl   0xd5c(%rip)
fld    %st(0)
fstpt  -0xd0(%rbp)
fsubp  %st,%st(1)
fstpl  -0x90(%rbp)
movsd  -0x90(%rbp),%xmm0
ff
call   1050 <cos@plt>
fldt   -0xdc(%rbp)
fldt   -0xd0(%rbp)
fldt   -0xc4(%rbp)
mov    %eax,-0x78(%rbp)
fildl  -0x78(%rbp)
fldt   -0x10(%rbp)
fdiv   %st(2),%st
fxch   %st(4)
fmulp  %st,%st(1)
fsubp  %st,%st(3)
mov    -0x38(%rbp),%rax
fxch   %st(2)
fstpl  0x8(%rax)
fldt   -0x50(%rbp)
fadd   %st,%st(0)
fstpt  -0xb8(%rbp)
fldt   -0x70(%rbp)
fdivp  %st,%st(2)
faddp  %st,%st(1)
fstpl  -0x98(%rbp)
movsd  -0x98(%rbp),%xmm0
ff
call   1050 <cos@plt>
fldt   -0xc4(%rbp)
fldt   -0xb8(%rbp)
mov    %eax,-0x74(%rbp)
fildl  -0x74(%rbp)
fldt   -0x10(%rbp)
fdivp  %st,%st(3)
fmulp  %st,%st(1)
fsubp  %st,%st(1)
fstpl  -0xa0(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    $0x1,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gl3grades>:
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%rbx
fldt   0x80(%rsp)
fldt   0xa0(%rsp)
fldt   0x90(%rsp)
fld    %st(2)
fmul   %st(3),%st
flds   0xea9(%rip)
fld    %st(1)
fdiv   %st(1),%st
fsubr  %st(3),%st
fdiv   %st(1),%st
fxch   %st(2)
fmul   %st(5),%st
fdivs  0xe9b(%rip)
fld    %st(5)
fstpt  0x34(%rsp)
fxch   %st(5)
fmulp  %st,%st(3)
fdivrp %st,%st(2)
fxch   %st(3)
fsubp  %st,%st(1)
faddp  %st,%st(1)
fmuls  0xe87(%rip)
fxch   %st(1)
fabs
fld    %st(0)
fsqrt
fldz
fxch   %st(2)
fucomi %st(2),%st
jae    11b5 <gl3grades+0x85>
fstp   %st(1)
fstpt  (%rsp)
fstpt  0x28(%rsp)
fstpt  0x1c(%rsp)
call   1050 <sqrt@plt>
fldt   0x1c(%rsp)
fldt   0x28(%rsp)
fldz
fxch   %st(2)
fxch   %st(3)
fxch   %st(1)
fxch   %st(2)
fstp   %st(0)
fld    %st(2)
fabs
fmulp  %st,%st(1)
fdiv   %st(2),%st
fld    %st(0)
fmul   %st(1),%st
fmul   %st(1),%st
fdivrp %st,%st(3)
fld1
fxch   %st(3)
fucomi %st(3),%st
fld    %st(1)
fstpt  0x1c(%rsp)
ja     1207 <gl3grades+0xd7>
fstp   %st(2)
fldl   0xe3b(%rip)
fxch   %st(3)
fchs
fucomip %st(2),%st
fldz
fxch   %st(3)
fxch   %st(2)
ja     1207 <gl3grades+0xd7>
fstp   %st(3)
fstp   %st(0)
fstp   %st(0)
fstpt  (%rsp)
call   1030 <acos@plt>
fldt   0x1c(%rsp)
fldz
fldz
fxch   %st(3)
fxch   %st(2)
fxch   %st(1)
fstp   %st(0)
fstp   %st(2)
fxch   %st(1)
fmuls  0xdf9(%rip)
fstpt  0x4c(%rsp)
fdivs  0xde3(%rip)
fld    %st(0)
fstpt  0x28(%rsp)
fstpl  0x68(%rsp)
movsd  0x68(%rsp),%xmm0
call   1040 <cos@plt>
mov    %eax,0x40(%rsp)
fldt   0x34(%rsp)
fdivs  0xdd0(%rip)
fld    %st(0)
fstpt  0x34(%rsp)
fldt   0x4c(%rsp)
fimull 0x40(%rsp)
faddp  %st,%st(1)
fstpl  (%rbx)
fldt   0x1c(%rsp)
fadd   %st,%st(0)
fstpt  0x1c(%rsp)
fldl   0xdbe(%rip)
fld    %st(0)
fstpt  0x4c(%rsp)
fldt   0x28(%rsp)
fsubrp %st,%st(1)
fstpl  0x58(%rsp)
movsd  0x58(%rsp),%xmm0
call   1040 <cos@plt>
mov    %eax,0x44(%rsp)
fldt   0x1c(%rsp)
fimull 0x44(%rsp)
fldt   0x34(%rsp)
faddp  %st,%st(1)
fstpl  0x8(%rbx)
fldt   0x28(%rsp)
fldt   0x4c(%rsp)
faddp  %st,%st(1)
fstpl  0x60(%rsp)
movsd  0x60(%rsp),%xmm0
call   1040 <cos@plt>
mov    %eax,0x48(%rsp)
fldt   0x1c(%rsp)
fimull 0x48(%rsp)
fldt   0x34(%rsp)
faddp  %st,%st(1)
fstpl  0x10(%rbx)
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @gl3grades(x86_fp80 %0, x86_fp80 %1, x86_fp80 %2, double* %3) {
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca x86_fp80
%8 = alloca double*
%9 = alloca x86_fp80
%10 = alloca x86_fp80
%11 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %5
store x86_fp80 %1, x86_fp80* %6
store x86_fp80 %2, x86_fp80* %7
store double* %3, double** %8
%12 = load x86_fp80, x86_fp80* %6
%13 = load x86_fp80, x86_fp80* %5
%14 = load x86_fp80, x86_fp80* %5
%15 = fmul x86_fp80 %13, %14
%16 = fdiv x86_fp80 %15, 0xK4000C000000000000000
%17 = fsub x86_fp80 %12, %16
%18 = fdiv x86_fp80 %17, 0xK4000C000000000000000
store x86_fp80 %18, x86_fp80* %9
%19 = load x86_fp80, x86_fp80* %5
%20 = load x86_fp80, x86_fp80* %5
%21 = fmul x86_fp80 %19, %20
%22 = load x86_fp80, x86_fp80* %5
%23 = fmul x86_fp80 %21, %22
%24 = fdiv x86_fp80 %23, 0xK4002D800000000000000
%25 = load x86_fp80, x86_fp80* %5
%26 = load x86_fp80, x86_fp80* %6
%27 = fmul x86_fp80 %25, %26
%28 = fdiv x86_fp80 %27, 0xK4000C000000000000000
%29 = fsub x86_fp80 %24, %28
%30 = load x86_fp80, x86_fp80* %7
%31 = fadd x86_fp80 %29, %30
%32 = fmul x86_fp80 %31, 0xK3FFE8000000000000000
store x86_fp80 %32, x86_fp80* %10
%33 = load x86_fp80, x86_fp80* %9
%34 = call x86_fp80 @fabs(x86_fp80 %33)
%35 = call x86_fp80 @sqrt(x86_fp80 %34)
%36 = load x86_fp80, x86_fp80* %10
%37 = call x86_fp80 @fabs(x86_fp80 %36)
%38 = fmul x86_fp80 %35, %37
%39 = load x86_fp80, x86_fp80* %10
%40 = fdiv x86_fp80 %38, %39
store x86_fp80 %40, x86_fp80* %9
%41 = load x86_fp80, x86_fp80* %10
%42 = load x86_fp80, x86_fp80* %9
%43 = load x86_fp80, x86_fp80* %9
%44 = fmul x86_fp80 %42, %43
%45 = load x86_fp80, x86_fp80* %9
%46 = fmul x86_fp80 %44, %45
%47 = fdiv x86_fp80 %41, %46
store x86_fp80 %47, x86_fp80* %11
%48 = load x86_fp80, x86_fp80* %11
%49 = fcmp ogt x86_fp80 %48, 0xK3FFF8000000000000000
br i1 %49, label %50, label %51
50: ; preds = %4
store x86_fp80 0xK00000000000000000000, x86_fp80* %11
br label %59
51: ; preds = %4
%52 = load x86_fp80, x86_fp80* %11
%53 = fcmp olt x86_fp80 %52, 0xKBFFF8000000000000000
br i1 %53, label %54, label %55
54: ; preds = %51
store x86_fp80 0xK4000C90FDAA22168C000, x86_fp80* %11
br label %58
55: ; preds = %51
%56 = load x86_fp80, x86_fp80* %11
%57 = call x86_fp80 @acos(x86_fp80 %56)
store x86_fp80 %57, x86_fp80* %11
br label %58
58: ; preds = %55, %54
br label %59
59: ; preds = %58, %50
%60 = load x86_fp80, x86_fp80* %9
%61 = fmul x86_fp80 0xKC0008000000000000000, %60
%62 = load x86_fp80, x86_fp80* %11
%63 = fdiv x86_fp80 %62, 0xK4000C000000000000000
%64 = fptrunc x86_fp80 %63 to double
%65 = call i32 @cos(double %64)
%66 = sitofp i32 %65 to x86_fp80
%67 = load x86_fp80, x86_fp80* %5
%68 = fdiv x86_fp80 %67, 0xK4000C000000000000000
%69 = fneg x86_fp80 %68
%70 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %61, x86_fp80 %66, x86_fp80 %69)
%71 = fptrunc x86_fp80 %70 to double
%72 = load double*, double** %8
%73 = getelementptr inbounds double, double* %72, i64 0
store double %71, double* %73
%74 = load x86_fp80, x86_fp80* %9
%75 = fmul x86_fp80 0xK40008000000000000000, %74
%76 = load x86_fp80, x86_fp80* %11
%77 = fdiv x86_fp80 %76, 0xK4000C000000000000000
%78 = fsub x86_fp80 0xK3FFF860A91C16B9B2800, %77
%79 = fptrunc x86_fp80 %78 to double
%80 = call i32 @cos(double %79)
%81 = sitofp i32 %80 to x86_fp80
%82 = load x86_fp80, x86_fp80* %5
%83 = fdiv x86_fp80 %82, 0xK4000C000000000000000
%84 = fneg x86_fp80 %83
%85 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %75, x86_fp80 %81, x86_fp80 %84)
%86 = fptrunc x86_fp80 %85 to double
%87 = load double*, double** %8
%88 = getelementptr inbounds double, double* %87, i64 1
store double %86, double* %88
%89 = load x86_fp80, x86_fp80* %9
%90 = fmul x86_fp80 0xK40008000000000000000, %89
%91 = load x86_fp80, x86_fp80* %11
%92 = fdiv x86_fp80 %91, 0xK4000C000000000000000
%93 = fadd x86_fp80 0xK3FFF860A91C16B9B2800, %92
%94 = fptrunc x86_fp80 %93 to double
%95 = call i32 @cos(double %94)
%96 = sitofp i32 %95 to x86_fp80
%97 = load x86_fp80, x86_fp80* %5
%98 = fdiv x86_fp80 %97, 0xK4000C000000000000000
%99 = fneg x86_fp80 %98
%100 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %90, x86_fp80 %96, x86_fp80 %99)
%101 = fptrunc x86_fp80 %100 to double
%102 = load double*, double** %8
%103 = getelementptr inbounds double, double* %102, i64 2
store double %101, double* %103
ret i32 1
}

LLVM IR (-O2):
define i32 @gl3grades(x86_fp80 %0, x86_fp80 %1, x86_fp80 %2, double* nocapture writeonly %3) {
%5 = fmul x86_fp80 %0, %0
%6 = fdiv x86_fp80 %5, 0xK4000C000000000000000
%7 = fsub x86_fp80 %1, %6
%8 = fdiv x86_fp80 %7, 0xK4000C000000000000000
%9 = fmul x86_fp80 %5, %0
%10 = fdiv x86_fp80 %9, 0xK4002D800000000000000
%11 = fmul x86_fp80 %0, %1
%12 = fdiv x86_fp80 %11, 0xK4000C000000000000000
%13 = fsub x86_fp80 %10, %12
%14 = fadd x86_fp80 %13, %2
%15 = fmul x86_fp80 %14, 0xK3FFE8000000000000000
%16 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %8)
%17 = tail call x86_fp80 @sqrt(x86_fp80 %16)
%18 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %15)
%19 = fmul x86_fp80 %18, %17
%20 = fdiv x86_fp80 %19, %15
%21 = fmul x86_fp80 %20, %20
%22 = fmul x86_fp80 %20, %21
%23 = fdiv x86_fp80 %15, %22
%24 = fcmp ogt x86_fp80 %23, 0xK3FFF8000000000000000
br i1 %24, label %29, label %25
25: ; preds = %4
%26 = fcmp olt x86_fp80 %23, 0xKBFFF8000000000000000
br i1 %26, label %29, label %27
27: ; preds = %25
%28 = tail call x86_fp80 @acos(x86_fp80 %23)
br label %29
29: ; preds = %25, %4, %27
%30 = phi x86_fp80 [ %28, %27 ], [ 0xK00000000000000000000, %4 ], [ 0xK4000C90FDAA22168C000, %25 ]
%31 = fmul x86_fp80 %20, 0xKC0008000000000000000
%32 = fdiv x86_fp80 %30, 0xK4000C000000000000000
%33 = fptrunc x86_fp80 %32 to double
%34 = tail call i32 @cos(double %33)
%35 = sitofp i32 %34 to x86_fp80
%36 = fdiv x86_fp80 %0, 0xKC000C000000000000000
%37 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %31, x86_fp80 %35, x86_fp80 %36)
%38 = fptrunc x86_fp80 %37 to double
store double %38, double* %3
%39 = fmul x86_fp80 %20, 0xK40008000000000000000
%40 = fsub x86_fp80 0xK3FFF860A91C16B9B2800, %32
%41 = fptrunc x86_fp80 %40 to double
%42 = tail call i32 @cos(double %41)
%43 = sitofp i32 %42 to x86_fp80
%44 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %39, x86_fp80 %43, x86_fp80 %36)
%45 = fptrunc x86_fp80 %44 to double
%46 = getelementptr inbounds double, double* %3, i64 1
store double %45, double* %46
%47 = fadd x86_fp80 %32, 0xK3FFF860A91C16B9B2800
%48 = fptrunc x86_fp80 %47 to double
%49 = tail call i32 @cos(double %48)
%50 = sitofp i32 %49 to x86_fp80
%51 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %39, x86_fp80 %50, x86_fp80 %36)
%52 = fptrunc x86_fp80 %51 to double
%53 = getelementptr inbounds double, double* %3, i64 2
store double %52, double* %53
ret i32 1
}