#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 *create_nvector(long);
double *copy_nvector(double *vec, long n) {
  register long i;
  double *copy;
  copy = create_nvector(n);
  for (i = 0; i <= n; i++)
    copy[i] = vec[i];
  return (copy);
}


x86 assembly (clang, -O0):
<copy_nvector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <create_nvector@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     116e <copy_nvector+0x5e>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1135 <copy_nvector+0x25>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_nvector>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <create_nvector@plt>
test   %r14,%r14
js     12c4 <copy_nvector+0x1b4>
lea    0x1(%r14),%r8
cmp    $0x4,%r8
jb     1157 <copy_nvector+0x47>
lea    (%rbx,%r14,8),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jae    11ec <copy_nvector+0xdc>
lea    (%rax,%r14,8),%rcx
add    $0x8,%rcx
cmp    %rbx,%rcx
jbe    11ec <copy_nvector+0xdc>
xor    %ecx,%ecx
lea    0x1(%r14),%esi
mov    %r14,%rdx
sub    %rcx,%rdx
and    $0x3,%rsi
je     1184 <copy_nvector+0x74>
nopl   0x0(%rax)
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1170 <copy_nvector+0x60>
cmp    $0x3,%rdx
jb     12c4 <copy_nvector+0x1b4>
sub    %rcx,%r14
lea    (%rax,%rcx,8),%rdx
add    $0x18,%rdx
lea    (%rbx,%rcx,8),%rcx
add    $0x18,%rcx
mov    $0xffffffffffffffff,%rsi
nopl   0x0(%rax,%rax,1)
movsd  -0x10(%rcx,%rsi,8),%xmm0
movsd  %xmm0,-0x10(%rdx,%rsi,8)
movsd  -0x8(%rcx,%rsi,8),%xmm0
movsd  %xmm0,-0x8(%rdx,%rsi,8)
movsd  (%rcx,%rsi,8),%xmm0
movsd  %xmm0,(%rdx,%rsi,8)
movsd  0x8(%rcx,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rdx,%rsi,8)
add    $0x4,%rsi
cmp    %rsi,%r14
jne    11b0 <copy_nvector+0xa0>
jmp    12c4 <copy_nvector+0x1b4>
mov    %r8,%rcx
and    $0xfffffffffffffffc,%rcx
lea    -0x4(%rcx),%rdx
mov    %rdx,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%r9d
and    $0x3,%r9d
cmp    $0xc,%rdx
jae    1213 <copy_nvector+0x103>
xor    %edx,%edx
jmp    1278 <copy_nvector+0x168>
and    $0xfffffffffffffffc,%rdi
xor    %edx,%edx
nopl   0x0(%rax)
movups (%rbx,%rdx,8),%xmm0
movups 0x10(%rbx,%rdx,8),%xmm1
movups %xmm0,(%rax,%rdx,8)
movups %xmm1,0x10(%rax,%rdx,8)
movups 0x20(%rbx,%rdx,8),%xmm0
movups 0x30(%rbx,%rdx,8),%xmm1
movups %xmm0,0x20(%rax,%rdx,8)
movups %xmm1,0x30(%rax,%rdx,8)
movups 0x40(%rbx,%rdx,8),%xmm0
movups 0x50(%rbx,%rdx,8),%xmm1
movups %xmm0,0x40(%rax,%rdx,8)
movups %xmm1,0x50(%rax,%rdx,8)
movups 0x60(%rbx,%rdx,8),%xmm0
movups 0x70(%rbx,%rdx,8),%xmm1
movups %xmm0,0x60(%rax,%rdx,8)
movups %xmm1,0x70(%rax,%rdx,8)
add    $0x10,%rdx
add    $0xfffffffffffffffc,%rdi
jne    1220 <copy_nvector+0x110>
test   %r9,%r9
je     12bb <copy_nvector+0x1ab>
lea    (%rax,%rdx,8),%rdi
add    $0x10,%rdi
lea    (%rbx,%rdx,8),%rdx
add    $0x10,%rdx
shl    $0x5,%r9
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rdx,%rsi,1),%xmm0
movups (%rdx,%rsi,1),%xmm1
movups %xmm0,-0x10(%rdi,%rsi,1)
movups %xmm1,(%rdi,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%r9
jne    12a0 <copy_nvector+0x190>
cmp    %rcx,%r8
jne    1159 <copy_nvector+0x49>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @copy_nvector(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca i64
%6 = alloca double*
store double* %0, double** %3
store i64 %1, i64* %4
%7 = load i64, i64* %4
%8 = call double* @create_nvector(i64 %7)
store double* %8, double** %6
store i64 0, i64* %5
br label %9
9: ; preds = %21, %2
%10 = load i64, i64* %5
%11 = load i64, i64* %4
%12 = icmp sle i64 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load double*, double** %3
%15 = load i64, i64* %5
%16 = getelementptr inbounds double, double* %14, i64 %15
%17 = load double, double* %16
%18 = load double*, double** %6
%19 = load i64, i64* %5
%20 = getelementptr inbounds double, double* %18, i64 %19
store double %17, double* %20
br label %21
21: ; preds = %13
%22 = load i64, i64* %5
%23 = add nsw i64 %22, 1
store i64 %23, i64* %5
br label %9
24: ; preds = %9
%25 = load double*, double** %6
ret double* %25
}

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