#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 *array_double_copy(double *arr, unsigned long long len) {
  double *copy = (double *)malloc(sizeof(double) * len);
  for (unsigned long i = 0; i < len; ++i) {
    copy[i] = arr[i];
  }
  return copy;
}


x86 assembly (clang, -O0):
<array_double_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1174 <array_double_copy+0x64>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113b <array_double_copy+0x2b>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_double_copy>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x0(,%rsi,8),%edi
call   1030 <malloc@plt>
test   %r14,%r14
je     1294 <array_double_copy+0x184>
cmp    $0x4,%r14
jb     1147 <array_double_copy+0x37>
lea    (%rbx,%r14,8),%rcx
cmp    %rcx,%rax
jae    11bc <array_double_copy+0xac>
lea    (%rax,%r14,8),%rcx
cmp    %rbx,%rcx
jbe    11bc <array_double_copy+0xac>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %r14,%rdx
mov    %r14,%rsi
and    $0x3,%rsi
je     1174 <array_double_copy+0x64>
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1160 <array_double_copy+0x50>
cmp    $0x3,%rdx
jb     1294 <array_double_copy+0x184>
xchg   %ax,%ax
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    1180 <array_double_copy+0x70>
jmp    1294 <array_double_copy+0x184>
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    11e3 <array_double_copy+0xd3>
xor    %edi,%edi
jmp    1248 <array_double_copy+0x138>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
nopl   0x0(%rax)
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    11f0 <array_double_copy+0xe0>
test   %r8,%r8
je     128b <array_double_copy+0x17b>
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    1270 <array_double_copy+0x160>
cmp    %r14,%rcx
jne    1149 <array_double_copy+0x39>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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