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


x86 assembly (clang, -O0):
<copyVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <allocateDoubleVector@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1166 <copyVector+0x56>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%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    1132 <copyVector+0x22>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyVector>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1030 <allocateDoubleVector@plt>
test   %ebp,%ebp
jle    1295 <copyVector+0x185>
mov    %ebp,%ecx
cmp    $0x4,%ebp
jb     1144 <copyVector+0x34>
lea    (%rbx,%rcx,8),%rdx
cmp    %rdx,%rax
jae    11bc <copyVector+0xac>
lea    (%rax,%rcx,8),%rdx
cmp    %rbx,%rdx
jbe    11bc <copyVector+0xac>
xor    %edx,%edx
mov    %rdx,%rsi
not    %rsi
add    %rcx,%rsi
mov    %rcx,%rdi
and    $0x3,%rdi
je     1174 <copyVector+0x64>
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rdi
jne    1160 <copyVector+0x50>
cmp    $0x3,%rsi
jb     1295 <copyVector+0x185>
xchg   %ax,%ax
movsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
movsd  0x8(%rbx,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rdx,8)
movsd  0x10(%rbx,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rax,%rdx,8)
movsd  0x18(%rbx,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rax,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rcx
jne    1180 <copyVector+0x70>
jmp    1295 <copyVector+0x185>
mov    %ecx,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rsi
mov    %rsi,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%r8d
and    $0x3,%r8d
cmp    $0xc,%rsi
jae    11e1 <copyVector+0xd1>
xor    %ebp,%ebp
jmp    1248 <copyVector+0x138>
and    $0xfffffffffffffffc,%rdi
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movups (%rbx,%rbp,8),%xmm0
movups 0x10(%rbx,%rbp,8),%xmm1
movups %xmm0,(%rax,%rbp,8)
movups %xmm1,0x10(%rax,%rbp,8)
movups 0x20(%rbx,%rbp,8),%xmm0
movups 0x30(%rbx,%rbp,8),%xmm1
movups %xmm0,0x20(%rax,%rbp,8)
movups %xmm1,0x30(%rax,%rbp,8)
movups 0x40(%rbx,%rbp,8),%xmm0
movups 0x50(%rbx,%rbp,8),%xmm1
movups %xmm0,0x40(%rax,%rbp,8)
movups %xmm1,0x50(%rax,%rbp,8)
movups 0x60(%rbx,%rbp,8),%xmm0
movups 0x70(%rbx,%rbp,8),%xmm1
movups %xmm0,0x60(%rax,%rbp,8)
movups %xmm1,0x70(%rax,%rbp,8)
add    $0x10,%rbp
add    $0xfffffffffffffffc,%rdi
jne    11f0 <copyVector+0xe0>
test   %r8,%r8
je     128c <copyVector+0x17c>
lea    (%rax,%rbp,8),%rdi
add    $0x10,%rdi
lea    (%rbx,%rbp,8),%rbp
add    $0x10,%rbp
shl    $0x5,%r8
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rbp,%rsi,1),%xmm0
movups 0x0(%rbp,%rsi,1),%xmm1
movups %xmm0,-0x10(%rdi,%rsi,1)
movups %xmm1,(%rdi,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%r8
jne    1270 <copyVector+0x160>
cmp    %rcx,%rdx
jne    1146 <copyVector+0x36>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double* @copyVector(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 = call double* @allocateDoubleVector(i32 %7)
store double* %8, double** %6
store i32 0, i32* %5
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load double*, double** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = load double*, double** %6
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
store double %18, double* %22
br label %23
23: ; preds = %13
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %9
26: ; preds = %9
%27 = load double*, double** %6
ret double* %27
}

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