#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);
void fit_quadratic(double x0, double y0, double th0, double x1, double y1,
                   double th1, double quad[6]) {
  double th;
  double s0, c0, s1, c1;
  double det, s, c;
  th = atan2(y1 - y0, x1 - x0);
  s0 = sin(th0 - th);
  c0 = cos(th0 - th);
  s1 = sin(th - th1);
  c1 = cos(th - th1);
  det = 1 / (s0 * c1 + s1 * c0);
  s = s0 * s1 * det;
  c = c0 * s1 * det;
  quad[0] = x0;
  quad[1] = y0;
  quad[2] = x0 + (x1 - x0) * c - (y1 - y0) * s;
  quad[3] = y0 + (y1 - y0) * c + (x1 - x0) * s;
  quad[4] = x1;
  quad[5] = y1;
}


x86 assembly (clang, -O0):
<fit_quadratic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %rdi,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe11(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x28(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fit_quadratic>:
push   %rbx
sub    $0xa0,%rsp
mov    %rdi,%rbx
movsd  %xmm5,0x10(%rsp)
movapd %xmm4,0x90(%rsp)
movapd %xmm3,0x80(%rsp)
movsd  %xmm2,0x8(%rsp)
movapd %xmm1,%xmm2
movapd %xmm1,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm3,%xmm1
unpcklpd %xmm4,%xmm1
movapd %xmm0,%xmm3
unpcklpd %xmm2,%xmm3
movapd %xmm3,0x70(%rsp)
subpd  %xmm3,%xmm1
movapd %xmm1,0x40(%rsp)
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movapd %xmm0,0x30(%rsp)
call   1030 <atan2@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <sin@plt>
movapd %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm4
mulsd  %xmm4,%xmm1
movapd 0x20(%rsp),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm1,%xmm2
movsd  0xddc(%rip),%xmm1
divsd  %xmm0,%xmm1
mulsd  %xmm4,%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm1
movaps 0x50(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movaps 0x60(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
movapd 0x30(%rsp),%xmm0
xorpd  0xdbb(%rip),%xmm0
unpcklpd %xmm1,%xmm1
movapd 0x40(%rsp),%xmm2
mulpd  %xmm2,%xmm1
addpd  0x70(%rsp),%xmm1
unpcklpd %xmm2,%xmm0
unpcklpd %xmm3,%xmm3
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
movupd %xmm3,0x10(%rbx)
movaps 0x80(%rsp),%xmm0
movsd  %xmm0,0x20(%rbx)
movaps 0x90(%rsp),%xmm0
movsd  %xmm0,0x28(%rbx)
add    $0xa0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @fit_quadratic(double %0, double %1, double %2, double %3, double %4, double %5, double* %6) {
%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
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double* %6, double** %14
%23 = load double, double* %12
%24 = load double, double* %9
%25 = fsub double %23, %24
%26 = load double, double* %11
%27 = load double, double* %8
%28 = fsub double %26, %27
%29 = call double @atan2(double %25, double %28)
store double %29, double* %15
%30 = load double, double* %10
%31 = load double, double* %15
%32 = fsub double %30, %31
%33 = call double @sin(double %32)
store double %33, double* %16
%34 = load double, double* %10
%35 = load double, double* %15
%36 = fsub double %34, %35
%37 = call double @cos(double %36)
store double %37, double* %17
%38 = load double, double* %15
%39 = load double, double* %13
%40 = fsub double %38, %39
%41 = call double @sin(double %40)
store double %41, double* %18
%42 = load double, double* %15
%43 = load double, double* %13
%44 = fsub double %42, %43
%45 = call double @cos(double %44)
store double %45, double* %19
%46 = load double, double* %16
%47 = load double, double* %19
%48 = load double, double* %18
%49 = load double, double* %17
%50 = fmul double %48, %49
%51 = call double @llvm.fmuladd.f64(double %46, double %47, double %50)
%52 = fdiv double 1.000000e+00, %51
store double %52, double* %20
%53 = load double, double* %16
%54 = load double, double* %18
%55 = fmul double %53, %54
%56 = load double, double* %20
%57 = fmul double %55, %56
store double %57, double* %21
%58 = load double, double* %17
%59 = load double, double* %18
%60 = fmul double %58, %59
%61 = load double, double* %20
%62 = fmul double %60, %61
store double %62, double* %22
%63 = load double, double* %8
%64 = load double*, double** %14
%65 = getelementptr inbounds double, double* %64, i64 0
store double %63, double* %65
%66 = load double, double* %9
%67 = load double*, double** %14
%68 = getelementptr inbounds double, double* %67, i64 1
store double %66, double* %68
%69 = load double, double* %8
%70 = load double, double* %11
%71 = load double, double* %8
%72 = fsub double %70, %71
%73 = load double, double* %22
%74 = call double @llvm.fmuladd.f64(double %72, double %73, double %69)
%75 = load double, double* %12
%76 = load double, double* %9
%77 = fsub double %75, %76
%78 = load double, double* %21
%79 = fneg double %77
%80 = call double @llvm.fmuladd.f64(double %79, double %78, double %74)
%81 = load double*, double** %14
%82 = getelementptr inbounds double, double* %81, i64 2
store double %80, double* %82
%83 = load double, double* %9
%84 = load double, double* %12
%85 = load double, double* %9
%86 = fsub double %84, %85
%87 = load double, double* %22
%88 = call double @llvm.fmuladd.f64(double %86, double %87, double %83)
%89 = load double, double* %11
%90 = load double, double* %8
%91 = fsub double %89, %90
%92 = load double, double* %21
%93 = call double @llvm.fmuladd.f64(double %91, double %92, double %88)
%94 = load double*, double** %14
%95 = getelementptr inbounds double, double* %94, i64 3
store double %93, double* %95
%96 = load double, double* %11
%97 = load double*, double** %14
%98 = getelementptr inbounds double, double* %97, i64 4
store double %96, double* %98
%99 = load double, double* %12
%100 = load double*, double** %14
%101 = getelementptr inbounds double, double* %100, i64 5
store double %99, double* %101
ret void
}

LLVM IR (-O2):
define void @fit_quadratic(double %0, double %1, double %2, double %3, double %4, double %5, double* nocapture writeonly %6) {
%8 = insertelement <2 x double> poison, double %3, i64 0
%9 = insertelement <2 x double> %8, double %4, i64 1
%10 = insertelement <2 x double> poison, double %0, i64 0
%11 = insertelement <2 x double> %10, double %1, i64 1
%12 = fsub <2 x double> %9, %11
%13 = extractelement <2 x double> %12, i64 0
%14 = extractelement <2 x double> %12, i64 1
%15 = tail call double @atan2(double %14, double %13)
%16 = fsub double %2, %15
%17 = tail call double @sin(double %16)
%18 = tail call double @cos(double %16)
%19 = fsub double %15, %5
%20 = tail call double @sin(double %19)
%21 = tail call double @cos(double %19)
%22 = fmul double %18, %20
%23 = tail call double @llvm.fmuladd.f64(double %17, double %21, double %22)
%24 = fdiv double 1.000000e+00, %23
%25 = fmul double %17, %20
%26 = fmul double %25, %24
%27 = fmul double %22, %24
store double %0, double* %6
%28 = getelementptr inbounds double, double* %6, i64 1
store double %1, double* %28
%29 = fneg double %14
%30 = getelementptr inbounds double, double* %6, i64 2
%31 = insertelement <2 x double> poison, double %27, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
%33 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %12, <2 x double> %32, <2 x double> %11)
%34 = insertelement <2 x double> poison, double %29, i64 0
%35 = shufflevector <2 x double> %34, <2 x double> %12, <2 x i32> <i32 0, i32 2>
%36 = insertelement <2 x double> poison, double %26, 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> %35, <2 x double> %37, <2 x double> %33)
%39 = bitcast double* %30 to <2 x double>*
store <2 x double> %38, <2 x double>* %39
%40 = getelementptr inbounds double, double* %6, i64 4
store double %3, double* %40
%41 = getelementptr inbounds double, double* %6, i64 5
store double %4, double* %41
ret void
}