#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 *allocateDoubleVector(int);
double *vectorSubtract(double *a, double *b, int n) {
  int i;
  double *c;
  c = allocateDoubleVector(n);
  for (i = 0; i < n; i++)
    c[i] = a[i] - b[i];
  return c;
}


x86 assembly (clang, -O0):
<vectorSubtract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <allocateDoubleVector@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1177 <vectorSubtract+0x67>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1136 <vectorSubtract+0x26>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectorSubtract>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%edi
call   1030 <allocateDoubleVector@plt>
test   %ebp,%ebp
jle    12dd <vectorSubtract+0x1cd>
mov    %ebp,%ecx
cmp    $0x4,%ebp
jae    11d7 <vectorSubtract+0xc7>
xor    %edx,%edx
mov    %rdx,%rsi
not    %rsi
add    %rcx,%rsi
mov    %rcx,%rdi
and    $0x3,%rdi
je     116a <vectorSubtract+0x5a>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rdx,8),%xmm0
subsd  (%r14,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rdi
jne    1150 <vectorSubtract+0x40>
cmp    $0x3,%rsi
jb     12dd <vectorSubtract+0x1cd>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rdx,8),%xmm0
subsd  (%r14,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
movsd  0x8(%rbx,%rdx,8),%xmm0
subsd  0x8(%r14,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rdx,8)
movsd  0x10(%rbx,%rdx,8),%xmm0
subsd  0x10(%r14,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rax,%rdx,8)
movsd  0x18(%rbx,%rdx,8),%xmm0
subsd  0x18(%r14,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rax,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rcx
jne    1180 <vectorSubtract+0x70>
jmp    12dd <vectorSubtract+0x1cd>
lea    (%rax,%rcx,8),%rdx
lea    (%rbx,%rcx,8),%rsi
cmp    %rsi,%rax
setb   %r8b
cmp    %rbx,%rdx
seta   %r9b
lea    (%r14,%rcx,8),%rsi
cmp    %rsi,%rax
setb   %sil
cmp    %r14,%rdx
seta   %dil
xor    %edx,%edx
test   %r9b,%r8b
jne    1138 <vectorSubtract+0x28>
and    %dil,%sil
jne    1138 <vectorSubtract+0x28>
mov    %ecx,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rsi
mov    %rsi,%rbp
shr    $0x2,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     12e2 <vectorSubtract+0x1d2>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopl   0x0(%rax)
movupd (%rbx,%rsi,8),%xmm0
movupd 0x10(%rbx,%rsi,8),%xmm1
movupd (%r14,%rsi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%r14,%rsi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rax,%rsi,8)
movupd %xmm1,0x10(%rax,%rsi,8)
movupd 0x20(%rbx,%rsi,8),%xmm0
movupd 0x30(%rbx,%rsi,8),%xmm1
movupd 0x20(%r14,%rsi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x30(%r14,%rsi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,0x20(%rax,%rsi,8)
movupd %xmm1,0x30(%rax,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1240 <vectorSubtract+0x130>
test   $0x1,%bpl
je     12d4 <vectorSubtract+0x1c4>
movupd (%rbx,%rsi,8),%xmm0
movupd 0x10(%rbx,%rsi,8),%xmm1
movupd (%r14,%rsi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%r14,%rsi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rax,%rsi,8)
movupd %xmm1,0x10(%rax,%rsi,8)
cmp    %rcx,%rdx
jne    1138 <vectorSubtract+0x28>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%bpl
jne    12a9 <vectorSubtract+0x199>
jmp    12d4 <vectorSubtract+0x1c4>

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

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