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


x86 assembly (clang, -O0):
<integrateEq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jae    1197 <integrateEq+0x87>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <integrateEq+0x37>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integrateEq>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x1(%rsi),%rdi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %r14,%r8
movq   $0x0,(%rax)
inc    %r8
je     11b2 <integrateEq+0xa2>
test   %r14,%r14
je     118b <integrateEq+0x7b>
mov    %r8,%rdx
and    $0xfffffffffffffffe,%rdx
mov    %rdx,%rsi
neg    %rsi
mov    $0x1,%edi
nopl   (%rax)
movupd -0x8(%rbx,%rdi,8),%xmm0
movd   %edi,%xmm1
lea    0x1(%rdi),%ecx
movd   %ecx,%xmm2
punpckldq %xmm2,%xmm1
cvtdq2pd %xmm1,%xmm1
divpd  %xmm1,%xmm0
movupd %xmm0,(%rax,%rdi,8)
lea    (%rsi,%rdi,1),%rcx
add    $0x2,%rcx
add    $0x2,%rdi
cmp    $0x1,%rcx
jne    1150 <integrateEq+0x40>
cmp    %rdx,%r8
jne    1190 <integrateEq+0x80>
jmp    11b2 <integrateEq+0xa2>
xor    %edx,%edx
nopl   (%rax)
lea    0x1(%rdx),%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  (%rbx,%rdx,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rax,%rdx,8)
mov    %rcx,%rdx
cmp    %rcx,%r8
jne    1190 <integrateEq+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @integrateEq(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca double*
%6 = alloca i32
store double* %0, double** %3
store i64 %1, i64* %4
%7 = load i64, i64* %4
%8 = add i64 %7, 1
%9 = mul i64 %8, 8
%10 = call double* @malloc(i64 %9)
store double* %10, double** %5
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 0
store double 0.000000e+00, double* %12
store i32 0, i32* %6
br label %13
13: ; preds = %34, %2
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = load i64, i64* %4
%17 = add i64 %16, 1
%18 = icmp ult i64 %15, %17
br i1 %18, label %19, label %37
19: ; preds = %13
%20 = load double*, double** %3
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
%27 = sitofp i32 %26 to double
%28 = fdiv double %24, %27
%29 = load double*, double** %5
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %29, i64 %32
store double %28, double* %33
br label %34
34: ; preds = %19
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %13
37: ; preds = %13
%38 = load double*, double** %5
ret double* %38
}

LLVM IR (-O2):
define noalias double* @integrateEq(double* nocapture %0, i64 %1) {
%3 = add i64 %1, 1
%4 = shl i64 %3, 3
%5 = tail call double* @malloc(i64 %4)
store double 0.000000e+00, double* %5
%6 = icmp eq i64 %3, 0
br i1 %6, label %31, label %7
7: ; preds = %2
%8 = icmp eq i64 %1, 0
br i1 %8, label %29, label %9
9: ; preds = %7
%10 = and i64 %3, -2
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %25, %11 ]
%13 = getelementptr inbounds double, double* %0, i64 %12
%14 = bitcast double* %13 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = or i64 %12, 1
%17 = add i64 %12, 2
%18 = insertelement <2 x i64> poison, i64 %16, i64 0
%19 = insertelement <2 x i64> %18, i64 %17, i64 1
%20 = trunc <2 x i64> %19 to <2 x i32>
%21 = sitofp <2 x i32> %20 to <2 x double>
%22 = fdiv <2 x double> %15, %21
%23 = getelementptr inbounds double, double* %5, i64 %16
%24 = bitcast double* %23 to <2 x double>*
store <2 x double> %22, <2 x double>* %24
%25 = add nuw i64 %12, 2
%26 = icmp eq i64 %25, %10
br i1 %26, label %27, label %11
27: ; preds = %11
%28 = icmp eq i64 %3, %10
br i1 %28, label %31, label %29
29: ; preds = %7, %27
%30 = phi i64 [ 0, %7 ], [ %10, %27 ]
br label %32
31: ; preds = %32, %27, %2
ret double* %5
32: ; preds = %29, %32
%33 = phi i64 [ %36, %32 ], [ %30, %29 ]
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = load double, double* %34
%36 = add nuw nsw i64 %33, 1
%37 = trunc i64 %36 to i32
%38 = sitofp i32 %37 to double
%39 = fdiv double %35, %38
%40 = getelementptr inbounds double, double* %5, i64 %36
store double %39, double* %40
%41 = icmp eq i64 %33, %1
br i1 %41, label %31, label %32
}