#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(int);
void deriv2(double **dx, double **dy, int *dn, const double *x, const double *y,
            int n) {
  int i;
  *dn = n - 2;
  *dx = malloc(*dn * sizeof(double));
  *dy = malloc(*dn * sizeof(double));
  double delta = x[1] - x[0];
  for (i = 1; i < n - 1; i++) {
    (*dx)[i - 1] = x[i];
    (*dy)[i - 1] = (y[i + 1] - 2 * y[i] + y[i - 1]) / (delta * delta);
  }
}


x86 assembly (clang, -O0):
<deriv2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
sub    $0x2,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    122e <deriv2+0x11e>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1191 <deriv2+0x81>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deriv2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
lea    -0x2(%r14),%eax
mov    %eax,(%rdx)
lea    -0x10(,%r14,8),%ebp
ff
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    %rax,(%r12)
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    %rax,0x0(%r13)
cmp    $0x3,%r14d
jl     11b9 <deriv2+0xa9>
add    $0xffffffff,%r14d
movsd  0x8(%r15),%xmm1
movapd %xmm1,%xmm0
subsd  (%r15),%xmm0
mov    (%r12),%rcx
mulsd  %xmm0,%xmm0
add    $0xfffffffffffffffe,%r14
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm1,(%rcx,%rdx,8)
movsd  0x8(%rbx,%rdx,8),%xmm1
movsd  0x10(%rbx,%rdx,8),%xmm2
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm2
addsd  (%rbx,%rdx,8),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rax,%rdx,8)
cmp    %rdx,%r14
je     11b9 <deriv2+0xa9>
movsd  0x10(%r15,%rdx,8),%xmm1
add    $0x1,%rdx
jmp    1180 <deriv2+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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