#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__ malloc(int);
double *math_vector_copy(const double *vector, size_t size) {
  double *copy = (double *)malloc(sizeof(double) * size);
  if (!copy) {
    return NULL;
  }
  for (size_t i = 0; i != size; ++i) {
    copy[i] = vector[i];
  }
  return copy;
}


x86 assembly (clang, -O0):
<math_vector_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    114b <math_vector_copy+0x3b>
movq   $0x0,-0x8(%rbp)
jmp    1194 <math_vector_copy+0x84>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     118c <math_vector_copy+0x7c>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1153 <math_vector_copy+0x43>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<math_vector_copy>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x0(,%rsi,8),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     11c9 <math_vector_copy+0xb9>
test   %r14,%r14
je     11cb <math_vector_copy+0xbb>
cmp    $0x4,%r14
jb     1154 <math_vector_copy+0x44>
lea    (%rbx,%r14,8),%rcx
cmp    %rcx,%rax
jae    11d3 <math_vector_copy+0xc3>
lea    (%rax,%r14,8),%rcx
cmp    %rbx,%rcx
jbe    11d3 <math_vector_copy+0xc3>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %r14,%rdx
mov    %r14,%rsi
and    $0x3,%rsi
je     1184 <math_vector_copy+0x74>
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1170 <math_vector_copy+0x60>
cmp    $0x3,%rdx
jb     11cb <math_vector_copy+0xbb>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  0x8(%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rcx,8)
movsd  0x10(%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rax,%rcx,8)
movsd  0x18(%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rax,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r14
jne    1190 <math_vector_copy+0x80>
jmp    11cb <math_vector_copy+0xbb>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rcx
and    $0xfffffffffffffffc,%rcx
lea    -0x4(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%r8d
and    $0x3,%r8d
cmp    $0xc,%rdx
jae    11fa <math_vector_copy+0xea>
xor    %edi,%edi
jmp    1258 <math_vector_copy+0x148>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
movups (%rbx,%rdi,8),%xmm0
movups 0x10(%rbx,%rdi,8),%xmm1
movups %xmm0,(%rax,%rdi,8)
movups %xmm1,0x10(%rax,%rdi,8)
movups 0x20(%rbx,%rdi,8),%xmm0
movups 0x30(%rbx,%rdi,8),%xmm1
movups %xmm0,0x20(%rax,%rdi,8)
movups %xmm1,0x30(%rax,%rdi,8)
movups 0x40(%rbx,%rdi,8),%xmm0
movups 0x50(%rbx,%rdi,8),%xmm1
movups %xmm0,0x40(%rax,%rdi,8)
movups %xmm1,0x50(%rax,%rdi,8)
movups 0x60(%rbx,%rdi,8),%xmm0
movups 0x70(%rbx,%rdi,8),%xmm1
movups %xmm0,0x60(%rax,%rdi,8)
movups %xmm1,0x70(%rax,%rdi,8)
add    $0x10,%rdi
add    $0xfffffffffffffffc,%rsi
jne    1200 <math_vector_copy+0xf0>
test   %r8,%r8
je     129b <math_vector_copy+0x18b>
lea    (%rax,%rdi,8),%rsi
add    $0x10,%rsi
lea    (%rbx,%rdi,8),%rdi
add    $0x10,%rdi
shl    $0x5,%r8
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rdi,%rdx,1),%xmm0
movups (%rdi,%rdx,1),%xmm1
movups %xmm0,-0x10(%rsi,%rdx,1)
movups %xmm1,(%rsi,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%r8
jne    1280 <math_vector_copy+0x170>
cmp    %r14,%rcx
je     11cb <math_vector_copy+0xbb>
jmp    1156 <math_vector_copy+0x46>

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

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