#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 fabs(double);
void calc_diff(int one, double *two, double *three, double *four) {
  int i = 0;
  while (i != one) {
    *(four + i) = fabs(*(two + i) - *(three + i));
    i++;
  }
}


x86 assembly (clang, -O0):
<calc_diff>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     1166 <calc_diff+0x66>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xeb9(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111a <calc_diff+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_diff>:
test   %edi,%edi
je     12b7 <calc_diff+0x1b7>
mov    %edi,%r8d
cmp    $0x4,%edi
jae    1187 <calc_diff+0x87>
xor    %edi,%edi
mov    %rdi,%rax
not    %rax
test   $0x1,%r8b
je     1139 <calc_diff+0x39>
movsd  (%rsi,%rdi,8),%xmm0
subsd  (%rdx,%rdi,8),%xmm0
andpd  0xed0(%rip),%xmm0
movlpd %xmm0,(%rcx,%rdi,8)
or     $0x1,%rdi
add    %r8,%rax
je     12b7 <calc_diff+0x1b7>
movapd 0xeb6(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movsd  (%rsi,%rdi,8),%xmm1
subsd  (%rdx,%rdi,8),%xmm1
andpd  %xmm0,%xmm1
movlpd %xmm1,(%rcx,%rdi,8)
movsd  0x8(%rsi,%rdi,8),%xmm1
subsd  0x8(%rdx,%rdi,8),%xmm1
andpd  %xmm0,%xmm1
movlpd %xmm1,0x8(%rcx,%rdi,8)
add    $0x2,%rdi
cmp    %rdi,%r8
jne    1150 <calc_diff+0x50>
jmp    12b7 <calc_diff+0x1b7>
lea    (%rcx,%r8,8),%rdi
lea    (%rsi,%r8,8),%rax
cmp    %rcx,%rax
seta   %r10b
lea    (%rdx,%r8,8),%rax
cmp    %rsi,%rdi
seta   %r11b
cmp    %rcx,%rax
seta   %al
cmp    %rdx,%rdi
seta   %r9b
xor    %edi,%edi
test   %r11b,%r10b
jne    1112 <calc_diff+0x12>
and    %r9b,%al
jne    1112 <calc_diff+0x12>
mov    %r8d,%edi
and    $0xfffffffc,%edi
lea    -0x4(%rdi),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12b8 <calc_diff+0x1b8>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
movapd 0xe0f(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd (%rsi,%rax,8),%xmm1
movupd 0x10(%rsi,%rax,8),%xmm2
movupd (%rdx,%rax,8),%xmm3
subpd  %xmm3,%xmm1
movupd 0x10(%rdx,%rax,8),%xmm3
subpd  %xmm3,%xmm2
andpd  %xmm0,%xmm1
andpd  %xmm0,%xmm2
movupd %xmm1,(%rcx,%rax,8)
movupd %xmm2,0x10(%rcx,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm1
movupd 0x30(%rsi,%rax,8),%xmm2
movupd 0x20(%rdx,%rax,8),%xmm3
subpd  %xmm3,%xmm1
movupd 0x30(%rdx,%rax,8),%xmm3
subpd  %xmm3,%xmm2
andpd  %xmm0,%xmm1
andpd  %xmm0,%xmm2
movupd %xmm1,0x20(%rcx,%rax,8)
movupd %xmm2,0x30(%rcx,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    1200 <calc_diff+0x100>
test   $0x1,%r9b
je     12ae <calc_diff+0x1ae>
movupd (%rsi,%rax,8),%xmm0
movupd 0x10(%rsi,%rax,8),%xmm1
movupd (%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rdx,%rax,8),%xmm2
subpd  %xmm2,%xmm1
movapd 0xd65(%rip),%xmm2
andpd  %xmm2,%xmm0
andpd  %xmm2,%xmm1
movupd %xmm0,(%rcx,%rax,8)
movupd %xmm1,0x10(%rcx,%rax,8)
cmp    %r8,%rdi
jne    1112 <calc_diff+0x12>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1275 <calc_diff+0x175>
jmp    12ae <calc_diff+0x1ae>

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

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