#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 */
scalar_t__ calloc(int, int);
double *diff(double *vec, int n) {
  int i;
  double *vec_out;
  vec_out = (double *)calloc((n - 1), sizeof(double));
  for (i = 0; i < (n - 1); i++) {
    vec_out[i] = vec[i + 1] - vec[i];
  }
  return vec_out;
}


x86 assembly (clang, -O0):
<diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1185 <diff+0x75>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <diff+0x2a>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    -0x1(%rbp),%r14d
mov    %r14d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
cmp    $0x2,%ebp
jl     12d3 <diff+0x1c3>
mov    %r14d,%ebp
cmp    $0x4,%r14d
jb     115a <diff+0x4a>
lea    (%rbx,%rbp,8),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jae    1207 <diff+0xf7>
lea    (%rax,%rbp,8),%rcx
cmp    %rbx,%rcx
jbe    1207 <diff+0xf7>
xor    %edx,%edx
mov    %rdx,%rdi
not    %rdi
add    %rbp,%rdi
mov    %rbp,%rcx
and    $0x3,%rcx
je     1199 <diff+0x89>
xchg   %ax,%ax
lea    0x1(%rdx),%rsi
movsd  0x8(%rbx,%rdx,8),%xmm0
subsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
mov    %rsi,%rdx
add    $0xffffffffffffffff,%rcx
jne    1170 <diff+0x60>
cmp    $0x3,%rdi
jb     12d3 <diff+0x1c3>
jmp    11b0 <diff+0xa0>
mov    %rdx,%rsi
cmp    $0x3,%rdi
jb     12d3 <diff+0x1c3>
cs nopw 0x0(%rax,%rax,1)
movsd  0x8(%rbx,%rsi,8),%xmm0
subsd  (%rbx,%rsi,8),%xmm0
movsd  %xmm0,(%rax,%rsi,8)
movsd  0x10(%rbx,%rsi,8),%xmm0
subsd  0x8(%rbx,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rax,%rsi,8)
movsd  0x18(%rbx,%rsi,8),%xmm0
subsd  0x10(%rbx,%rsi,8),%xmm0
movsd  %xmm0,0x10(%rax,%rsi,8)
movsd  0x20(%rbx,%rsi,8),%xmm0
subsd  0x18(%rbx,%rsi,8),%xmm0
movsd  %xmm0,0x18(%rax,%rsi,8)
lea    0x4(%rsi),%rcx
mov    %rcx,%rsi
cmp    %rcx,%rbp
jne    11b0 <diff+0xa0>
jmp    12d3 <diff+0x1c3>
mov    %ebp,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rsi
mov    %rsi,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
test   %rsi,%rsi
je     12d8 <diff+0x1c8>
mov    %rcx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopl   (%rax)
movupd (%rbx,%rsi,8),%xmm0
movupd 0x8(%rbx,%rsi,8),%xmm1
subpd  %xmm0,%xmm1
movupd 0x10(%rbx,%rsi,8),%xmm0
movupd 0x18(%rbx,%rsi,8),%xmm2
subpd  %xmm0,%xmm2
movupd %xmm1,(%rax,%rsi,8)
movupd %xmm2,0x10(%rax,%rsi,8)
movupd 0x20(%rbx,%rsi,8),%xmm0
movupd 0x28(%rbx,%rsi,8),%xmm1
subpd  %xmm0,%xmm1
movupd 0x30(%rbx,%rsi,8),%xmm0
movupd 0x38(%rbx,%rsi,8),%xmm2
subpd  %xmm0,%xmm2
movupd %xmm1,0x20(%rax,%rsi,8)
movupd %xmm2,0x30(%rax,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1230 <diff+0x120>
test   $0x1,%cl
je     12ca <diff+0x1ba>
lea    0x0(,%rsi,8),%rcx
or     $0x8,%rcx
movupd (%rbx,%rcx,1),%xmm0
movupd 0x10(%rbx,%rcx,1),%xmm1
movupd (%rbx,%rsi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rbx,%rsi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rax,%rsi,8)
movupd %xmm1,0x10(%rax,%rsi,8)
cmp    %rbp,%rdx
jne    115c <diff+0x4c>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%cl
jne    1295 <diff+0x185>
jmp    12ca <diff+0x1ba>

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

LLVM IR (-O2):
define double* @diff(double* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = tail call i64 @calloc(i32 %3, i32 8)
%5 = inttoptr i64 %4 to double*
%6 = inttoptr i64 %4 to i8*
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %150
8: ; preds = %2
%9 = zext i32 %3 to i64
%10 = icmp ult i32 %3, 4
br i1 %10, label %98, label %11
11: ; preds = %8
%12 = getelementptr double, double* %5, i64 %9
%13 = add nuw nsw i64 %9, 1
%14 = getelementptr double, double* %0, i64 %13
%15 = bitcast double* %14 to i8*
%16 = icmp ult i8* %6, %15
%17 = icmp ugt double* %12, %0
%18 = and i1 %16, %17
br i1 %18, label %98, label %19
19: ; preds = %11
%20 = and i64 %9, 4294967292
%21 = add nsw i64 %20, -4
%22 = lshr exact i64 %21, 2
%23 = add nuw nsw i64 %22, 1
%24 = and i64 %23, 1
%25 = icmp eq i64 %21, 0
br i1 %25, label %73, label %26
26: ; preds = %19
%27 = and i64 %23, 9223372036854775806
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 0, %26 ], [ %70, %28 ]
%30 = phi i64 [ 0, %26 ], [ %71, %28 ]
%31 = or i64 %29, 1
%32 = getelementptr inbounds double, double* %0, i64 %31
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = getelementptr inbounds double, double* %32, i64 2
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = getelementptr inbounds double, double* %0, i64 %29
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = fsub <2 x double> %34, %40
%45 = fsub <2 x double> %37, %43
%46 = getelementptr inbounds double, double* %5, i64 %29
%47 = bitcast double* %46 to <2 x double>*
store <2 x double> %44, <2 x double>* %47
%48 = getelementptr inbounds double, double* %46, i64 2
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %45, <2 x double>* %49
%50 = or i64 %29, 4
%51 = or i64 %29, 5
%52 = getelementptr inbounds double, double* %0, i64 %51
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = getelementptr inbounds double, double* %52, i64 2
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr inbounds double, double* %0, i64 %50
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %58, i64 2
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = fsub <2 x double> %54, %60
%65 = fsub <2 x double> %57, %63
%66 = getelementptr inbounds double, double* %5, i64 %50
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> %64, <2 x double>* %67
%68 = getelementptr inbounds double, double* %66, i64 2
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> %65, <2 x double>* %69
%70 = add nuw i64 %29, 8
%71 = add i64 %30, 2
%72 = icmp eq i64 %71, %27
br i1 %72, label %73, label %28
73: ; preds = %28, %19
%74 = phi i64 [ 0, %19 ], [ %70, %28 ]
%75 = icmp eq i64 %24, 0
br i1 %75, label %96, label %76
76: ; preds = %73
%77 = or i64 %74, 1
%78 = getelementptr inbounds double, double* %0, i64 %77
%79 = bitcast double* %78 to <2 x double>*
%80 = load <2 x double>, <2 x double>* %79
%81 = getelementptr inbounds double, double* %78, i64 2
%82 = bitcast double* %81 to <2 x double>*
%83 = load <2 x double>, <2 x double>* %82
%84 = getelementptr inbounds double, double* %0, i64 %74
%85 = bitcast double* %84 to <2 x double>*
%86 = load <2 x double>, <2 x double>* %85
%87 = getelementptr inbounds double, double* %84, i64 2
%88 = bitcast double* %87 to <2 x double>*
%89 = load <2 x double>, <2 x double>* %88
%90 = fsub <2 x double> %80, %86
%91 = fsub <2 x double> %83, %89
%92 = getelementptr inbounds double, double* %5, i64 %74
%93 = bitcast double* %92 to <2 x double>*
store <2 x double> %90, <2 x double>* %93
%94 = getelementptr inbounds double, double* %92, i64 2
%95 = bitcast double* %94 to <2 x double>*
store <2 x double> %91, <2 x double>* %95
br label %96
96: ; preds = %73, %76
%97 = icmp eq i64 %20, %9
br i1 %97, label %150, label %98
98: ; preds = %11, %8, %96
%99 = phi i64 [ 0, %11 ], [ 0, %8 ], [ %20, %96 ]
%100 = xor i64 %99, -1
%101 = add nsw i64 %100, %9
%102 = and i64 %9, 3
%103 = icmp eq i64 %102, 0
br i1 %103, label %116, label %104
104: ; preds = %98, %104
%105 = phi i64 [ %107, %104 ], [ %99, %98 ]
%106 = phi i64 [ %114, %104 ], [ 0, %98 ]
%107 = add nuw nsw i64 %105, 1
%108 = getelementptr inbounds double, double* %0, i64 %107
%109 = load double, double* %108
%110 = getelementptr inbounds double, double* %0, i64 %105
%111 = load double, double* %110
%112 = fsub double %109, %111
%113 = getelementptr inbounds double, double* %5, i64 %105
store double %112, double* %113
%114 = add i64 %106, 1
%115 = icmp eq i64 %114, %102
br i1 %115, label %116, label %104
116: ; preds = %104, %98
%117 = phi i64 [ %99, %98 ], [ %107, %104 ]
%118 = icmp ult i64 %101, 3
br i1 %118, label %150, label %119
119: ; preds = %116, %119
%120 = phi i64 [ %142, %119 ], [ %117, %116 ]
%121 = add nuw nsw i64 %120, 1
%122 = getelementptr inbounds double, double* %0, i64 %121
%123 = load double, double* %122
%124 = getelementptr inbounds double, double* %0, i64 %120
%125 = load double, double* %124
%126 = fsub double %123, %125
%127 = getelementptr inbounds double, double* %5, i64 %120
store double %126, double* %127
%128 = add nuw nsw i64 %120, 2
%129 = getelementptr inbounds double, double* %0, i64 %128
%130 = load double, double* %129
%131 = getelementptr inbounds double, double* %0, i64 %121
%132 = load double, double* %131
%133 = fsub double %130, %132
%134 = getelementptr inbounds double, double* %5, i64 %121
store double %133, double* %134
%135 = add nuw nsw i64 %120, 3
%136 = getelementptr inbounds double, double* %0, i64 %135
%137 = load double, double* %136
%138 = getelementptr inbounds double, double* %0, i64 %128
%139 = load double, double* %138
%140 = fsub double %137, %139
%141 = getelementptr inbounds double, double* %5, i64 %128
store double %140, double* %141
%142 = add nuw nsw i64 %120, 4
%143 = getelementptr inbounds double, double* %0, i64 %142
%144 = load double, double* %143
%145 = getelementptr inbounds double, double* %0, i64 %135
%146 = load double, double* %145
%147 = fsub double %144, %146
%148 = getelementptr inbounds double, double* %5, i64 %135
store double %147, double* %148
%149 = icmp eq i64 %142, %9
br i1 %149, label %150, label %119
150: ; preds = %116, %119, %96, %2
ret double* %5
}