#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 PT_diff(double *res, double *p1, double *p2, int n) {
  int i;
  if (!res)
    res = p1;
  for (i = 0; i < n; i++) {
    res[i] = fabs(p1[i] - p2[i]);
  }
}


x86 assembly (clang, -O0):
<PT_diff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1126 <PT_diff+0x26>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1179 <PT_diff+0x79>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xea6(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <PT_diff+0x2d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<PT_diff>:
test   %rdi,%rdi
cmove  %rsi,%rdi
test   %ecx,%ecx
jle    12c7 <PT_diff+0x1c7>
mov    %ecx,%r8d
cmp    $0x4,%ecx
jae    1197 <PT_diff+0x97>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
test   $0x1,%r8b
je     1144 <PT_diff+0x44>
movsd  (%rsi,%rcx,8),%xmm0
subsd  (%rdx,%rcx,8),%xmm0
andpd  0xec5(%rip),%xmm0
movlpd %xmm0,(%rdi,%rcx,8)
or     $0x1,%rcx
add    %r8,%rax
je     12c7 <PT_diff+0x1c7>
movapd 0xeab(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rsi,%rcx,8),%xmm1
subsd  (%rdx,%rcx,8),%xmm1
andpd  %xmm0,%xmm1
movlpd %xmm1,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm1
subsd  0x8(%rdx,%rcx,8),%xmm1
andpd  %xmm0,%xmm1
movlpd %xmm1,0x8(%rdi,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r8
jne    1160 <PT_diff+0x60>
jmp    12c7 <PT_diff+0x1c7>
lea    (%rdi,%r8,8),%rcx
lea    (%rsi,%r8,8),%rax
cmp    %rax,%rdi
setb   %r10b
cmp    %rsi,%rcx
seta   %r11b
lea    (%rdx,%r8,8),%rax
cmp    %rax,%rdi
setb   %al
cmp    %rdx,%rcx
seta   %r9b
xor    %ecx,%ecx
test   %r11b,%r10b
jne    111d <PT_diff+0x1d>
and    %r9b,%al
jne    111d <PT_diff+0x1d>
mov    %r8d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12c8 <PT_diff+0x1c8>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
movapd 0xdff(%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,(%rdi,%rax,8)
movupd %xmm2,0x10(%rdi,%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(%rdi,%rax,8)
movupd %xmm2,0x30(%rdi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    1210 <PT_diff+0x110>
test   $0x1,%r9b
je     12be <PT_diff+0x1be>
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 0xd55(%rip),%xmm2
andpd  %xmm2,%xmm0
andpd  %xmm2,%xmm1
movupd %xmm0,(%rdi,%rax,8)
movupd %xmm1,0x10(%rdi,%rax,8)
cmp    %r8,%rcx
jne    111d <PT_diff+0x1d>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1285 <PT_diff+0x185>
jmp    12be <PT_diff+0x1be>

LLVM IR (-O0):
define void @PT_diff(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%10 = load double*, double** %5
%11 = icmp ne double* %10, null
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = load double*, double** %6
store double* %13, double** %5
br label %14
14: ; preds = %12, %4
store i32 0, i32* %9
br label %15
15: ; preds = %36, %14
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = load double*, double** %6
%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 = load double*, double** %7
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fsub double %24, %29
%31 = call double @llvm.fabs.f64(double %30)
%32 = load double*, double** %5
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
store double %31, double* %35
br label %36
36: ; preds = %19
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %15
39: ; preds = %15
ret void
}

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