#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 *malloc(size_t);
double *divideBy(double *equation, size_t degree, double root) {
  double *quotient = malloc(degree * sizeof(double));
  quotient[degree - 1] = equation[degree];
  for (int i = degree - 2; i >= 0; i--)
    quotient[i] = root * quotient[i + 1] + equation[i + 1];
  return quotient;
}


x86 assembly (clang, -O0):
<divideBy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
sub    $0x2,%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11b5 <divideBy+0xa5>
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <divideBy+0x4f>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divideBy>:
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x0(,%rsi,8),%rdi
call   1030 <malloc@plt>
movsd  (%rsp),%xmm1
movsd  (%rbx,%r14,8),%xmm0
movsd  %xmm0,-0x8(%rax,%r14,8)
add    $0xfffffffe,%r14d
js     119a <divideBy+0x8a>
mov    %r14d,%ecx
test   $0x1,%r14b
jne    1166 <divideBy+0x56>
movsd  0x8(%rax,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  0x8(%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0xffffffffffffffff,%rcx
test   %r14d,%r14d
je     119a <divideBy+0x8a>
add    $0x1,%rcx
nop
movsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rax,%rcx,8)
mulsd  %xmm1,%xmm0
addsd  -0x8(%rbx,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rax,%rcx,8)
add    $0xfffffffffffffffe,%rcx
jne    1170 <divideBy+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @divideBy(double* %0, i64 %1, double %2) {
%4 = alloca double*
%5 = alloca i64
%6 = alloca double
%7 = alloca double*
%8 = alloca i32
store double* %0, double** %4
store i64 %1, i64* %5
store double %2, double* %6
%9 = load i64, i64* %5
%10 = mul i64 %9, 8
%11 = call double* @malloc(i64 %10)
store double* %11, double** %7
%12 = load double*, double** %4
%13 = load i64, i64* %5
%14 = getelementptr inbounds double, double* %12, i64 %13
%15 = load double, double* %14
%16 = load double*, double** %7
%17 = load i64, i64* %5
%18 = sub i64 %17, 1
%19 = getelementptr inbounds double, double* %16, i64 %18
store double %15, double* %19
%20 = load i64, i64* %5
%21 = sub i64 %20, 2
%22 = trunc i64 %21 to i32
store i32 %22, i32* %8
br label %23
23: ; preds = %45, %3
%24 = load i32, i32* %8
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %48
26: ; preds = %23
%27 = load double, double* %6
%28 = load double*, double** %7
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %28, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %4
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %34, i64 %37
%39 = load double, double* %38
%40 = call double @llvm.fmuladd.f64(double %27, double %33, double %39)
%41 = load double*, double** %7
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
store double %40, double* %44
br label %45
45: ; preds = %26
%46 = load i32, i32* %8
%47 = add nsw i32 %46, -1
store i32 %47, i32* %8
br label %23
48: ; preds = %23
%49 = load double*, double** %7
ret double* %49
}

LLVM IR (-O2):
define noalias double* @divideBy(double* nocapture %0, i64 %1, double %2) {
%4 = shl i64 %1, 3
%5 = tail call double* @malloc(i64 %4)
%6 = getelementptr inbounds double, double* %0, i64 %1
%7 = load double, double* %6
%8 = add i64 %1, -1
%9 = getelementptr inbounds double, double* %5, i64 %8
store double %7, double* %9
%10 = trunc i64 %1 to i32
%11 = add i32 %10, -2
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %29
13: ; preds = %3
%14 = zext i32 %11 to i64
%15 = and i64 %14, 1
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = add nuw nsw i64 %14, 1
%19 = getelementptr inbounds double, double* %5, i64 %18
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %0, i64 %18
%22 = load double, double* %21
%23 = tail call double @llvm.fmuladd.f64(double %2, double %20, double %22)
%24 = getelementptr inbounds double, double* %5, i64 %14
store double %23, double* %24
%25 = add nsw i64 %14, -1
br label %26
26: ; preds = %17, %13
%27 = phi i64 [ %14, %13 ], [ %25, %17 ]
%28 = icmp eq i32 %11, 0
br i1 %28, label %29, label %30
29: ; preds = %26, %30, %3
ret double* %5
30: ; preds = %26, %30
%31 = phi i64 [ %44, %30 ], [ %27, %26 ]
%32 = add nuw nsw i64 %31, 1
%33 = getelementptr inbounds double, double* %5, i64 %32
%34 = load double, double* %33
%35 = getelementptr inbounds double, double* %0, i64 %32
%36 = load double, double* %35
%37 = tail call double @llvm.fmuladd.f64(double %2, double %34, double %36)
%38 = getelementptr inbounds double, double* %5, i64 %31
store double %37, double* %38
%39 = add nsw i64 %31, -1
%40 = getelementptr inbounds double, double* %0, i64 %31
%41 = load double, double* %40
%42 = tail call double @llvm.fmuladd.f64(double %2, double %37, double %41)
%43 = getelementptr inbounds double, double* %5, i64 %39
store double %42, double* %43
%44 = add nsw i64 %31, -2
%45 = icmp eq i64 %39, 0
br i1 %45, label %29, label %30
}