#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__ calloc(int, unsigned int);
int /*<<< orphan*/ exit(int);
double *array_sub(double *arr1, double *arr2, unsigned int length, double k) {
  double *ret = (double *)calloc(sizeof(double), length);
  if (ret == NULL)
    exit(202020);
  for (unsigned int i = 0; i < length; i++)
    ret[i] = arr1[i] - k * arr2[i];
  return ret;
}


x86 assembly (clang, -O0):
<array_sub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    $0x8,%edi
call   1030 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115e <array_sub+0x3e>
mov    $0x31524,%edi
call   1040 <exit@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11c7 <array_sub+0xa7>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1165 <array_sub+0x45>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_sub>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movapd %xmm0,(%rsp)
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x8,%edi
mov    %edx,%esi
call   1030 <calloc@plt>
test   %rax,%rax
je     130b <array_sub+0x1eb>
test   %ebp,%ebp
movapd (%rsp),%xmm5
je     12f4 <array_sub+0x1d4>
xorpd  0xea1(%rip),%xmm5
mov    %ebp,%ecx
cmp    $0x4,%ebp
jae    116d <array_sub+0x4d>
xor    %edx,%edx
jmp    1291 <array_sub+0x171>
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    1291 <array_sub+0x171>
and    %dil,%sil
jne    1291 <array_sub+0x171>
mov    %ecx,%edx
and    $0xfffffffc,%edx
movapd %xmm5,%xmm0
unpcklpd %xmm5,%xmm0
lea    -0x4(%rdx),%rsi
mov    %rsi,%rbp
shr    $0x2,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     12fd <array_sub+0x1dd>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movupd (%rbx,%rsi,8),%xmm1
movupd 0x10(%rbx,%rsi,8),%xmm2
movupd (%r14,%rsi,8),%xmm3
movupd 0x10(%r14,%rsi,8),%xmm4
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm0,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm3,(%rax,%rsi,8)
movupd %xmm4,0x10(%rax,%rsi,8)
movupd 0x20(%rbx,%rsi,8),%xmm1
movupd 0x30(%rbx,%rsi,8),%xmm2
movupd 0x20(%r14,%rsi,8),%xmm3
movupd 0x30(%r14,%rsi,8),%xmm4
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm0,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm3,0x20(%rax,%rsi,8)
movupd %xmm4,0x30(%rax,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    11e0 <array_sub+0xc0>
test   $0x1,%bpl
je     128c <array_sub+0x16c>
movupd (%rbx,%rsi,8),%xmm1
movupd 0x10(%rbx,%rsi,8),%xmm2
movupd (%r14,%rsi,8),%xmm3
movupd 0x10(%r14,%rsi,8),%xmm4
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm0,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm3,(%rax,%rsi,8)
movupd %xmm4,0x10(%rax,%rsi,8)
cmp    %rcx,%rdx
je     12f4 <array_sub+0x1d4>
mov    %rdx,%rsi
not    %rsi
test   $0x1,%cl
je     12b4 <array_sub+0x194>
movsd  (%r14,%rdx,8),%xmm0
mulsd  %xmm5,%xmm0
addsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
or     $0x1,%rdx
add    %rcx,%rsi
je     12f4 <array_sub+0x1d4>
nopl   0x0(%rax)
movsd  (%r14,%rdx,8),%xmm0
mulsd  %xmm5,%xmm0
addsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
movsd  0x8(%r14,%rdx,8),%xmm0
mulsd  %xmm5,%xmm0
addsd  0x8(%rbx,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rdx,8)
add    $0x2,%rdx
cmp    %rdx,%rcx
jne    12c0 <array_sub+0x1a0>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%bpl
jne    1259 <array_sub+0x139>
jmp    128c <array_sub+0x16c>
mov    $0x31524,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define double* @array_sub(double* %0, double* %1, i32 %2, double %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double*
%10 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double %3, double* %8
%11 = load i32, i32* %7
%12 = call i64 @calloc(i32 8, i32 %11)
%13 = inttoptr i64 %12 to double*
store double* %13, double** %9
%14 = load double*, double** %9
%15 = icmp eq double* %14, null
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = call i32 @exit(i32 202020)
unreachable
18: ; preds = %4
store i32 0, i32* %10
br label %19
19: ; preds = %41, %18
%20 = load i32, i32* %10
%21 = load i32, i32* %7
%22 = icmp ult i32 %20, %21
br i1 %22, label %23, label %44
23: ; preds = %19
%24 = load double*, double** %5
%25 = load i32, i32* %10
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double, double* %8
%30 = load double*, double** %6
%31 = load i32, i32* %10
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = fneg double %29
%36 = call double @llvm.fmuladd.f64(double %35, double %34, double %28)
%37 = load double*, double** %9
%38 = load i32, i32* %10
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %36, double* %40
br label %41
41: ; preds = %23
%42 = load i32, i32* %10
%43 = add i32 %42, 1
store i32 %43, i32* %10
br label %19
44: ; preds = %19
%45 = load double*, double** %9
ret double* %45
}

LLVM IR (-O2):
define double* @array_sub(double* nocapture %0, double* nocapture %1, i32 %2, double %3) {
%5 = tail call i64 @calloc(i32 8, i32 %2)
%6 = inttoptr i64 %5 to double*
%7 = inttoptr i64 %5 to i8*
%8 = icmp eq i64 %5, 0
br i1 %8, label %125, label %9
9: ; preds = %4
%10 = icmp eq i32 %2, 0
br i1 %10, label %127, label %11
11: ; preds = %9
%12 = fneg double %3
%13 = zext i32 %2 to i64
%14 = icmp ult i32 %2, 4
br i1 %14, label %108, label %15
15: ; preds = %11
%16 = getelementptr double, double* %6, i64 %13
%17 = getelementptr double, double* %0, i64 %13
%18 = bitcast double* %17 to i8*
%19 = getelementptr double, double* %1, i64 %13
%20 = bitcast double* %19 to i8*
%21 = icmp ult i8* %7, %18
%22 = icmp ugt double* %16, %0
%23 = and i1 %21, %22
%24 = icmp ult i8* %7, %20
%25 = icmp ugt double* %16, %1
%26 = and i1 %24, %25
%27 = or i1 %23, %26
br i1 %27, label %108, label %28
28: ; preds = %15
%29 = and i64 %13, 4294967292
%30 = insertelement <2 x double> poison, double %12, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = insertelement <2 x double> poison, double %12, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = add nsw i64 %29, -4
%35 = lshr exact i64 %34, 2
%36 = add nuw nsw i64 %35, 1
%37 = and i64 %36, 1
%38 = icmp eq i64 %34, 0
br i1 %38, label %84, label %39
39: ; preds = %28
%40 = and i64 %36, 9223372036854775806
br label %41
41: ; preds = %41, %39
%42 = phi i64 [ 0, %39 ], [ %81, %41 ]
%43 = phi i64 [ 0, %39 ], [ %82, %41 ]
%44 = getelementptr inbounds double, double* %0, i64 %42
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = getelementptr inbounds double, double* %1, i64 %42
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds double, double* %50, i64 2
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %52, <2 x double> %46)
%57 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %55, <2 x double> %49)
%58 = getelementptr inbounds double, double* %6, i64 %42
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %56, <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 %42, 4
%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* %1, i64 %62
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %69, i64 2
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %71, <2 x double> %65)
%76 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %74, <2 x double> %68)
%77 = getelementptr inbounds double, double* %6, i64 %62
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %75, <2 x double>* %78
%79 = getelementptr inbounds double, double* %77, i64 2
%80 = bitcast double* %79 to <2 x double>*
store <2 x double> %76, <2 x double>* %80
%81 = add nuw i64 %42, 8
%82 = add i64 %43, 2
%83 = icmp eq i64 %82, %40
br i1 %83, label %84, label %41
84: ; preds = %41, %28
%85 = phi i64 [ 0, %28 ], [ %81, %41 ]
%86 = icmp eq i64 %37, 0
br i1 %86, label %106, label %87
87: ; preds = %84
%88 = getelementptr inbounds double, double* %0, i64 %85
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = getelementptr inbounds double, double* %88, i64 2
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = getelementptr inbounds double, double* %1, i64 %85
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = getelementptr inbounds double, double* %94, i64 2
%98 = bitcast double* %97 to <2 x double>*
%99 = load <2 x double>, <2 x double>* %98
%100 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %96, <2 x double> %90)
%101 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %99, <2 x double> %93)
%102 = getelementptr inbounds double, double* %6, i64 %85
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> %100, <2 x double>* %103
%104 = getelementptr inbounds double, double* %102, i64 2
%105 = bitcast double* %104 to <2 x double>*
store <2 x double> %101, <2 x double>* %105
br label %106
106: ; preds = %84, %87
%107 = icmp eq i64 %29, %13
br i1 %107, label %127, label %108
108: ; preds = %15, %11, %106
%109 = phi i64 [ 0, %15 ], [ 0, %11 ], [ %29, %106 ]
%110 = xor i64 %109, -1
%111 = and i64 %13, 1
%112 = icmp eq i64 %111, 0
br i1 %112, label %121, label %113
113: ; preds = %108
%114 = getelementptr inbounds double, double* %0, i64 %109
%115 = load double, double* %114
%116 = getelementptr inbounds double, double* %1, i64 %109
%117 = load double, double* %116
%118 = tail call double @llvm.fmuladd.f64(double %12, double %117, double %115)
%119 = getelementptr inbounds double, double* %6, i64 %109
store double %118, double* %119
%120 = or i64 %109, 1
br label %121
121: ; preds = %113, %108
%122 = phi i64 [ %109, %108 ], [ %120, %113 ]
%123 = sub nsw i64 0, %13
%124 = icmp eq i64 %110, %123
br i1 %124, label %127, label %128
125: ; preds = %4
%126 = tail call i32 @exit(i32 202020)
unreachable
127: ; preds = %121, %128, %106, %9
ret double* %6
128: ; preds = %121, %128
%129 = phi i64 [ %143, %128 ], [ %122, %121 ]
%130 = getelementptr inbounds double, double* %0, i64 %129
%131 = load double, double* %130
%132 = getelementptr inbounds double, double* %1, i64 %129
%133 = load double, double* %132
%134 = tail call double @llvm.fmuladd.f64(double %12, double %133, double %131)
%135 = getelementptr inbounds double, double* %6, i64 %129
store double %134, double* %135
%136 = add nuw nsw i64 %129, 1
%137 = getelementptr inbounds double, double* %0, i64 %136
%138 = load double, double* %137
%139 = getelementptr inbounds double, double* %1, i64 %136
%140 = load double, double* %139
%141 = tail call double @llvm.fmuladd.f64(double %12, double %140, double %138)
%142 = getelementptr inbounds double, double* %6, i64 %136
store double %141, double* %142
%143 = add nuw nsw i64 %129, 2
%144 = icmp eq i64 %143, %13
br i1 %144, label %127, label %128
}