#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 */
int fabs(double);
double sqrt(double);
double dp_edge_weight(double *Q1, double *T1, int nsamps1, double *Q2,
                      double *T2, int nsamps2, int dim, double a, double b,
                      double c, double d, int aidx, int cidx, double lam) {
  double res = 0.0;
  int Q1idx, Q2idx;
  int Q1idxnext, Q2idxnext;
  double t1, t2;
  double t1next, t2next;
  double t1nextcand1, t1nextcand2;
  double slope, rslope;
  double dq, dqi;
  int i;
  Q1idx = aidx;
  Q2idx = cidx;
  t1 = a;
  t2 = c;
  slope = (d - c) / (b - a);
  rslope = sqrt(slope);
  while (t1 < b && t2 < d) {
    if (Q1idx > nsamps1 - 2 || Q2idx > nsamps2 - 2)
      break;
    t1nextcand1 = T1[Q1idx + 1];
    t1nextcand2 = a + (T2[Q2idx + 1] - c) / slope;
    if (fabs(t1nextcand1 - t1nextcand2) < 1e-6) {
      t1next = T1[Q1idx + 1];
      t2next = T2[Q2idx + 1];
      Q1idxnext = Q1idx + 1;
      Q2idxnext = Q2idx + 1;
    } else if (t1nextcand1 < t1nextcand2) {
      t1next = t1nextcand1;
      t2next = c + slope * (t1next - a);
      Q1idxnext = Q1idx + 1;
      Q2idxnext = Q2idx;
    } else {
      t1next = t1nextcand2;
      t2next = T2[Q2idx + 1];
      Q1idxnext = Q1idx;
      Q2idxnext = Q2idx + 1;
    }
    if (t1next > b)
      t1next = b;
    if (t2next > d)
      t2next = d;
    dq = 0.0;
    for (i = 0; i < dim; ++i) {
      dqi = Q1[Q1idx * dim + i] - rslope * Q2[Q2idx * dim + i];
      dq += dqi * dqi + lam * (1 - rslope) * (1 - rslope);
    }
    res += (t1next - t1) * dq;
    t1 = t1next;
    t2 = t2next;
    Q1idx = Q1idxnext;
    Q2idx = Q2idxnext;
  }
  return res;
}


x86 assembly (clang, -O0):
<dp_edge_weight>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movsd  %xmm0,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
movsd  %xmm2,-0x48(%rbp)
movsd  %xmm3,-0x50(%rbp)
movsd  %xmm4,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    0x18(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    0x20(%rbp),%eax
mov    %eax,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
call   1040 <sqrt@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x78(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0xc5(%rbp)
jbe    11f4 <dp_edge_weight+0xd4>
movsd  -0x80(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0xc5(%rbp)
mov    -0xc5(%rbp),%al
test   $0x1,%al
jne    1207 <dp_edge_weight+0xe7>
jmp    1514 <dp_edge_weight+0x3f4>
mov    -0x64(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     1229 <dp_edge_weight+0x109>
mov    -0x68(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jle    122e <dp_edge_weight+0x10e>
jmp    1514 <dp_edge_weight+0x3f4>
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x68(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x48(%rbp),%xmm1
divsd  -0xa8(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
subsd  -0xa0(%rbp),%xmm0
ff
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd67(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ee <dp_edge_weight+0x1ce>
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x28(%rbp),%rax
mov    -0x68(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1394 <dp_edge_weight+0x274>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    1356 <dp_edge_weight+0x236>
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x48(%rbp),%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm2
ff
subsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x70(%rbp)
jmp    138f <dp_edge_weight+0x26f>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x28(%rbp),%rax
mov    -0x68(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x64(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1394 <dp_edge_weight+0x274>
movsd  -0x88(%rbp),%xmm0
ff
ucomisd -0x40(%rbp),%xmm0
jbe    13b4 <dp_edge_weight+0x294>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
ucomisd -0x50(%rbp),%xmm0
jbe    13d4 <dp_edge_weight+0x2b4>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movl   $0x0,-0xc4(%rbp)
mov    -0xc4(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    14c2 <dp_edge_weight+0x3a2>
mov    -0x8(%rbp),%rax
mov    -0x64(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0xc4(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    -0x68(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0xc4(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
movsd  -0xc0(%rbp),%xmm2
ff
movsd  -0x58(%rbp),%xmm1
movsd  0xb92(%rip),%xmm3
subsd  -0xb0(%rbp),%xmm3
ff
mulsd  %xmm3,%xmm1
movsd  0xb7e(%rip),%xmm3
subsd  -0xb0(%rbp),%xmm3
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    13e9 <dp_edge_weight+0x2c9>
movsd  -0x88(%rbp),%xmm0
ff
subsd  -0x78(%rbp),%xmm0
movsd  -0xb8(%rbp),%xmm2
ff
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x78(%rbp)
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x68(%rbp)
jmp    11c1 <dp_edge_weight+0xa1>
movsd  -0x60(%rbp),%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dp_edge_weight>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
movapd %xmm3,%xmm8
mov    %r9d,%r15d
mov    %rcx,0x58(%rsp)
mov    %edx,%ebx
mov    %rdi,0x50(%rsp)
movsd  %xmm3,0x60(%rsp)
movsd  %xmm2,0x38(%rsp)
subsd  %xmm2,%xmm8
movsd  %xmm1,0x68(%rsp)
movsd  %xmm0,0x28(%rsp)
subsd  %xmm0,%xmm1
divsd  %xmm1,%xmm8
xorpd  %xmm7,%xmm7
ucomisd %xmm7,%xmm8
mov    %r8,0x30(%rsp)
mov    %rsi,0x20(%rsp)
movsd  %xmm8,0x18(%rsp)
jb     1194 <dp_edge_weight+0x74>
mov    %r8,%r12
xorps  %xmm0,%xmm0
sqrtsd %xmm8,%xmm0
jmp    11bf <dp_edge_weight+0x9f>
movapd %xmm8,%xmm0
movsd  %xmm4,0x8(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm7,%xmm7
movsd  0x18(%rsp),%xmm8
mov    0x20(%rsp),%rsi
mov    0x30(%rsp),%r12
movsd  0x8(%rsp),%xmm4
movsd  0x68(%rsp),%xmm1
ucomisd 0x28(%rsp),%xmm1
jbe    14f7 <dp_edge_weight+0x3d7>
movsd  0x60(%rsp),%xmm1
ucomisd 0x38(%rsp),%xmm1
jbe    14f7 <dp_edge_weight+0x3d7>
mov    0xf8(%rsp),%ebp
add    $0xfffffffe,%ebx
mov    %ebx,0x4c(%rsp)
cmp    %ebp,%ebx
jl     14f7 <dp_edge_weight+0x3d7>
mov    0x100(%rsp),%r14d
add    $0xfffffffe,%r15d
mov    %r15d,0x48(%rsp)
cmp    %r14d,%r15d
jl     14f7 <dp_edge_weight+0x3d7>
mov    0xf0(%rsp),%eax
movapd 0xdde(%rip),%xmm6
xorpd  %xmm0,%xmm6
movsd  0xde2(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm4
mulsd  %xmm1,%xmm4
mov    %eax,%r13d
mov    %r13,0x98(%rsp)
and    $0xfffffffe,%r13d
mov    0x50(%rsp),%rax
add    $0x8,%rax
mov    %rax,0x90(%rsp)
mov    0x58(%rsp),%rax
add    $0x8,%rax
mov    %rax,0x88(%rsp)
xorpd  %xmm7,%xmm7
movsd  0x28(%rsp),%xmm2
movsd  %xmm4,0x8(%rsp)
movapd %xmm6,0x70(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm2,0xb0(%rsp)
movsd  %xmm7,0x40(%rsp)
lea    0x1(%rbp),%eax
mov    %eax,0x14(%rsp)
movslq %ebp,%r15
movsd  0x8(%rsi,%r15,8),%xmm0
lea    0x1(%r14),%eax
mov    %eax,0x10(%rsp)
movslq %r14d,%rbx
movsd  0x8(%r12,%rbx,8),%xmm1
add    $0x1,%rbx
subsd  0x38(%rsp),%xmm1
divsd  %xmm8,%xmm1
addsd  0x28(%rsp),%xmm1
movsd  %xmm0,0xa0(%rsp)
movsd  %xmm1,0xa8(%rsp)
subsd  %xmm1,%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jle    1370 <dp_edge_weight+0x250>
movsd  0xa8(%rsp),%xmm1
movsd  0xa0(%rsp),%xmm3
ucomisd %xmm3,%xmm1
jbe    13b0 <dp_edge_weight+0x290>
movapd %xmm3,%xmm0
subsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm8
mulsd  %xmm8,%xmm0
addsd  0x38(%rsp),%xmm0
mov    %r14d,%eax
movsd  0x8(%rsp),%xmm4
mov    0x30(%rsp),%r12
mov    0x20(%rsp),%rsi
movsd  0x40(%rsp),%xmm7
mov    0xf0(%rsp),%edx
movapd 0x70(%rsp),%xmm6
mov    0x14(%rsp),%ebx
test   %edx,%edx
jg     13f2 <dp_edge_weight+0x2d2>
xorpd  %xmm1,%xmm1
jmp    14a5 <dp_edge_weight+0x385>
nopl   0x0(%rax)
add    $0x1,%r15
mov    0x20(%rsp),%rsi
movsd  (%rsi,%r15,8),%xmm3
movsd  (%r12,%rbx,8),%xmm0
movsd  0x8(%rsp),%xmm4
movsd  0x18(%rsp),%xmm8
movsd  0x40(%rsp),%xmm7
mov    0xf0(%rsp),%edx
movapd 0x70(%rsp),%xmm6
mov    0x14(%rsp),%ebx
jmp    13e6 <dp_edge_weight+0x2c6>
nopl   0x0(%rax,%rax,1)
mov    0x30(%rsp),%r12
movsd  (%r12,%rbx,8),%xmm0
movapd %xmm1,%xmm3
mov    %ebp,%ebx
movsd  0x8(%rsp),%xmm4
mov    0x20(%rsp),%rsi
movsd  0x18(%rsp),%xmm8
movsd  0x40(%rsp),%xmm7
mov    0xf0(%rsp),%edx
movapd 0x70(%rsp),%xmm6
mov    0x10(%rsp),%eax
test   %edx,%edx
jle    1360 <dp_edge_weight+0x240>
imul   %edx,%ebp
imul   %edx,%r14d
movslq %ebp,%r9
movslq %r14d,%rcx
cmp    $0x1,%edx
jne    1410 <dp_edge_weight+0x2f0>
xorpd  %xmm1,%xmm1
xor    %edx,%edx
jmp    1470 <dp_edge_weight+0x350>
nopl   0x0(%rax)
mov    0x90(%rsp),%rdx
lea    (%rdx,%r9,8),%rbp
mov    0x88(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdi
xorpd  %xmm1,%xmm1
xor    %edx,%edx
xchg   %ax,%ax
movsd  -0x8(%rdi,%rdx,8),%xmm2
mulsd  %xmm6,%xmm2
addsd  -0x8(%rbp,%rdx,8),%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
movsd  (%rdi,%rdx,8),%xmm1
mulsd  %xmm6,%xmm1
addsd  0x0(%rbp,%rdx,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm4,%xmm1
addsd  %xmm2,%xmm1
add    $0x2,%rdx
cmp    %rdx,%r13
jne    1430 <dp_edge_weight+0x310>
testb  $0x1,0x98(%rsp)
01
je     14a5 <dp_edge_weight+0x385>
add    %rdx,%r9
add    %rdx,%rcx
mov    0x58(%rsp),%rdx
movsd  (%rdx,%rcx,8),%xmm2
mulsd  %xmm6,%xmm2
mov    0x50(%rsp),%rcx
addsd  (%rcx,%r9,8),%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm4,%xmm2
addsd  %xmm2,%xmm1
movsd  0x68(%rsp),%xmm5
movapd %xmm5,%xmm2
minsd  %xmm3,%xmm2
movapd %xmm2,%xmm3
subsd  0xb0(%rsp),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm3,%xmm7
ucomisd %xmm2,%xmm5
jbe    14f7 <dp_edge_weight+0x3d7>
movsd  0x60(%rsp),%xmm3
movapd %xmm3,%xmm1
minsd  %xmm0,%xmm1
ucomisd %xmm1,%xmm3
jbe    14f7 <dp_edge_weight+0x3d7>
cmp    0x4c(%rsp),%ebx
jg     14f7 <dp_edge_weight+0x3d7>
mov    %ebx,%ebp
mov    %eax,%r14d
cmp    0x48(%rsp),%eax
jle    1290 <dp_edge_weight+0x170>
movapd %xmm7,%xmm0
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @dp_edge_weight(double* %0, double* %1, i32 %2, double* %3, double* %4, i32 %5, i32 %6, double %7, double %8, double %9, double %10, i32 %11, i32 %12, double %13) {
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca double*
%19 = alloca double*
%20 = alloca i32
%21 = alloca i32
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca i32
%27 = alloca i32
%28 = alloca double
%29 = alloca double
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca double
%35 = alloca double
%36 = alloca double
%37 = alloca double
%38 = alloca double
%39 = alloca double
%40 = alloca double
%41 = alloca double
%42 = alloca double
%43 = alloca double
%44 = alloca i32
store double* %0, double** %15
store double* %1, double** %16
store i32 %2, i32* %17
store double* %3, double** %18
store double* %4, double** %19
store i32 %5, i32* %20
store i32 %6, i32* %21
store double %7, double* %22
store double %8, double* %23
store double %9, double* %24
store double %10, double* %25
store i32 %11, i32* %26
store i32 %12, i32* %27
store double %13, double* %28
store double 0.000000e+00, double* %29
%45 = load i32, i32* %26
store i32 %45, i32* %30
%46 = load i32, i32* %27
store i32 %46, i32* %31
%47 = load double, double* %22
store double %47, double* %34
%48 = load double, double* %24
store double %48, double* %35
%49 = load double, double* %25
%50 = load double, double* %24
%51 = fsub double %49, %50
%52 = load double, double* %23
%53 = load double, double* %22
%54 = fsub double %52, %53
%55 = fdiv double %51, %54
store double %55, double* %40
%56 = load double, double* %40
%57 = call double @sqrt(double %56)
store double %57, double* %41
br label %58
58: ; preds = %202, %14
%59 = load double, double* %34
%60 = load double, double* %23
%61 = fcmp olt double %59, %60
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load double, double* %35
%64 = load double, double* %25
%65 = fcmp olt double %63, %64
br label %66
66: ; preds = %62, %58
%67 = phi i1 [ false, %58 ], [ %65, %62 ]
br i1 %67, label %68, label %213
68: ; preds = %66
%69 = load i32, i32* %30
%70 = load i32, i32* %17
%71 = sub nsw i32 %70, 2
%72 = icmp sgt i32 %69, %71
br i1 %72, label %78, label %73
73: ; preds = %68
%74 = load i32, i32* %31
%75 = load i32, i32* %20
%76 = sub nsw i32 %75, 2
%77 = icmp sgt i32 %74, %76
br i1 %77, label %78, label %79
78: ; preds = %73, %68
br label %213
79: ; preds = %73
%80 = load double*, double** %16
%81 = load i32, i32* %30
%82 = add nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %80, i64 %83
%85 = load double, double* %84
store double %85, double* %38
%86 = load double, double* %22
%87 = load double*, double** %19
%88 = load i32, i32* %31
%89 = add nsw i32 %88, 1
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %87, i64 %90
%92 = load double, double* %91
%93 = load double, double* %24
%94 = fsub double %92, %93
%95 = load double, double* %40
%96 = fdiv double %94, %95
%97 = fadd double %86, %96
store double %97, double* %39
%98 = load double, double* %38
%99 = load double, double* %39
%100 = fsub double %98, %99
%101 = call i32 @fabs(double %100)
%102 = sitofp i32 %101 to double
%103 = fcmp olt double %102, 0x3EB0C6F7A0B5ED8D
br i1 %103, label %104, label %121
104: ; preds = %79
%105 = load double*, double** %16
%106 = load i32, i32* %30
%107 = add nsw i32 %106, 1
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %105, i64 %108
%110 = load double, double* %109
store double %110, double* %36
%111 = load double*, double** %19
%112 = load i32, i32* %31
%113 = add nsw i32 %112, 1
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %111, i64 %114
%116 = load double, double* %115
store double %116, double* %37
%117 = load i32, i32* %30
%118 = add nsw i32 %117, 1
store i32 %118, i32* %32
%119 = load i32, i32* %31
%120 = add nsw i32 %119, 1
store i32 %120, i32* %33
br label %148
121: ; preds = %79
%122 = load double, double* %38
%123 = load double, double* %39
%124 = fcmp olt double %122, %123
br i1 %124, label %125, label %136
125: ; preds = %121
%126 = load double, double* %38
store double %126, double* %36
%127 = load double, double* %24
%128 = load double, double* %40
%129 = load double, double* %36
%130 = load double, double* %22
%131 = fsub double %129, %130
%132 = call double @llvm.fmuladd.f64(double %128, double %131, double %127)
store double %132, double* %37
%133 = load i32, i32* %30
%134 = add nsw i32 %133, 1
store i32 %134, i32* %32
%135 = load i32, i32* %31
store i32 %135, i32* %33
br label %147
136: ; preds = %121
%137 = load double, double* %39
store double %137, double* %36
%138 = load double*, double** %19
%139 = load i32, i32* %31
%140 = add nsw i32 %139, 1
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds double, double* %138, i64 %141
%143 = load double, double* %142
store double %143, double* %37
%144 = load i32, i32* %30
store i32 %144, i32* %32
%145 = load i32, i32* %31
%146 = add nsw i32 %145, 1
store i32 %146, i32* %33
br label %147
147: ; preds = %136, %125
br label %148
148: ; preds = %147, %104
%149 = load double, double* %36
%150 = load double, double* %23
%151 = fcmp ogt double %149, %150
br i1 %151, label %152, label %154
152: ; preds = %148
%153 = load double, double* %23
store double %153, double* %36
br label %154
154: ; preds = %152, %148
%155 = load double, double* %37
%156 = load double, double* %25
%157 = fcmp ogt double %155, %156
br i1 %157, label %158, label %160
158: ; preds = %154
%159 = load double, double* %25
store double %159, double* %37
br label %160
160: ; preds = %158, %154
store double 0.000000e+00, double* %42
store i32 0, i32* %44
br label %161
161: ; preds = %199, %160
%162 = load i32, i32* %44
%163 = load i32, i32* %21
%164 = icmp slt i32 %162, %163
br i1 %164, label %165, label %202
165: ; preds = %161
%166 = load double*, double** %15
%167 = load i32, i32* %30
%168 = load i32, i32* %21
%169 = mul nsw i32 %167, %168
%170 = load i32, i32* %44
%171 = add nsw i32 %169, %170
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds double, double* %166, i64 %172
%174 = load double, double* %173
%175 = load double, double* %41
%176 = load double*, double** %18
%177 = load i32, i32* %31
%178 = load i32, i32* %21
%179 = mul nsw i32 %177, %178
%180 = load i32, i32* %44
%181 = add nsw i32 %179, %180
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds double, double* %176, i64 %182
%184 = load double, double* %183
%185 = fneg double %175
%186 = call double @llvm.fmuladd.f64(double %185, double %184, double %174)
store double %186, double* %43
%187 = load double, double* %43
%188 = load double, double* %43
%189 = load double, double* %28
%190 = load double, double* %41
%191 = fsub double 1.000000e+00, %190
%192 = fmul double %189, %191
%193 = load double, double* %41
%194 = fsub double 1.000000e+00, %193
%195 = fmul double %192, %194
%196 = call double @llvm.fmuladd.f64(double %187, double %188, double %195)
%197 = load double, double* %42
%198 = fadd double %197, %196
store double %198, double* %42
br label %199
199: ; preds = %165
%200 = load i32, i32* %44
%201 = add nsw i32 %200, 1
store i32 %201, i32* %44
br label %161
202: ; preds = %161
%203 = load double, double* %36
%204 = load double, double* %34
%205 = fsub double %203, %204
%206 = load double, double* %42
%207 = load double, double* %29
%208 = call double @llvm.fmuladd.f64(double %205, double %206, double %207)
store double %208, double* %29
%209 = load double, double* %36
store double %209, double* %34
%210 = load double, double* %37
store double %210, double* %35
%211 = load i32, i32* %32
store i32 %211, i32* %30
%212 = load i32, i32* %33
store i32 %212, i32* %31
br label %58
213: ; preds = %78, %66
%214 = load double, double* %29
ret double %214
}

LLVM IR (-O2):
define double @dp_edge_weight(double* nocapture %0, double* nocapture %1, i32 %2, double* nocapture %3, double* nocapture %4, i32 %5, i32 %6, double %7, double %8, double %9, double %10, i32 %11, i32 %12, double %13) {
%15 = fsub double %10, %9
%16 = fsub double %8, %7
%17 = fdiv double %15, %16
%18 = tail call double @sqrt(double %17)
%19 = add nsw i32 %2, -2
%20 = add nsw i32 %5, -2
%21 = fcmp uge double %7, %8
%22 = fcmp uge double %9, %10
%23 = or i1 %21, %22
%24 = icmp slt i32 %19, %11
%25 = select i1 %23, i1 true, i1 %24
%26 = icmp slt i32 %20, %12
%27 = select i1 %25, i1 true, i1 %26
br i1 %27, label %133, label %28
28: ; preds = %14
%29 = icmp sgt i32 %6, 0
%30 = fneg double %18
%31 = fsub double 1.000000e+00, %18
%32 = fmul double %31, %13
%33 = fmul double %31, %32
%34 = zext i32 %6 to i64
%35 = and i64 %34, 1
%36 = icmp eq i32 %6, 1
%37 = and i64 %34, 4294967294
%38 = icmp eq i64 %35, 0
br label %39
39: ; preds = %28, %122
%40 = phi double [ 0.000000e+00, %28 ], [ %125, %122 ]
%41 = phi i32 [ %11, %28 ], [ %72, %122 ]
%42 = phi i32 [ %12, %28 ], [ %71, %122 ]
%43 = phi double [ %7, %28 ], [ %74, %122 ]
%44 = add nsw i32 %41, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %1, i64 %45
%47 = load double, double* %46
%48 = add nsw i32 %42, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %4, i64 %49
%51 = load double, double* %50
%52 = fsub double %51, %9
%53 = fdiv double %52, %17
%54 = fadd double %53, %7
%55 = fsub double %47, %54
%56 = tail call i32 @fabs(double %55)
%57 = icmp slt i32 %56, 1
br i1 %57, label %58, label %61
58: ; preds = %39
%59 = load double, double* %46
%60 = load double, double* %50
br label %68
61: ; preds = %39
%62 = fcmp olt double %47, %54
br i1 %62, label %63, label %66
63: ; preds = %61
%64 = fsub double %47, %7
%65 = tail call double @llvm.fmuladd.f64(double %17, double %64, double %9)
br label %68
66: ; preds = %61
%67 = load double, double* %50
br label %68
68: ; preds = %63, %66, %58
%69 = phi double [ %59, %58 ], [ %47, %63 ], [ %54, %66 ]
%70 = phi double [ %60, %58 ], [ %65, %63 ], [ %67, %66 ]
%71 = phi i32 [ %48, %58 ], [ %42, %63 ], [ %48, %66 ]
%72 = phi i32 [ %44, %58 ], [ %44, %63 ], [ %41, %66 ]
%73 = fcmp ogt double %69, %8
%74 = select i1 %73, double %8, double %69
%75 = fcmp ogt double %70, %10
%76 = select i1 %75, double %10, double %70
br i1 %29, label %77, label %122
77: ; preds = %68
%78 = mul nsw i32 %41, %6
%79 = mul nsw i32 %42, %6
%80 = sext i32 %78 to i64
%81 = sext i32 %79 to i64
br i1 %36, label %108, label %82
82: ; preds = %77, %82
%83 = phi i64 [ %105, %82 ], [ 0, %77 ]
%84 = phi double [ %104, %82 ], [ 0.000000e+00, %77 ]
%85 = phi i64 [ %106, %82 ], [ 0, %77 ]
%86 = add nsw i64 %83, %80
%87 = getelementptr inbounds double, double* %0, i64 %86
%88 = load double, double* %87
%89 = add nsw i64 %83, %81
%90 = getelementptr inbounds double, double* %3, i64 %89
%91 = load double, double* %90
%92 = tail call double @llvm.fmuladd.f64(double %30, double %91, double %88)
%93 = tail call double @llvm.fmuladd.f64(double %92, double %92, double %33)
%94 = fadd double %84, %93
%95 = or i64 %83, 1
%96 = add nsw i64 %95, %80
%97 = getelementptr inbounds double, double* %0, i64 %96
%98 = load double, double* %97
%99 = add nsw i64 %95, %81
%100 = getelementptr inbounds double, double* %3, i64 %99
%101 = load double, double* %100
%102 = tail call double @llvm.fmuladd.f64(double %30, double %101, double %98)
%103 = tail call double @llvm.fmuladd.f64(double %102, double %102, double %33)
%104 = fadd double %94, %103
%105 = add nuw nsw i64 %83, 2
%106 = add i64 %85, 2
%107 = icmp eq i64 %106, %37
br i1 %107, label %108, label %82
108: ; preds = %82, %77
%109 = phi double [ undef, %77 ], [ %104, %82 ]
%110 = phi i64 [ 0, %77 ], [ %105, %82 ]
%111 = phi double [ 0.000000e+00, %77 ], [ %104, %82 ]
br i1 %38, label %122, label %112
112: ; preds = %108
%113 = add nsw i64 %110, %80
%114 = getelementptr inbounds double, double* %0, i64 %113
%115 = load double, double* %114
%116 = add nsw i64 %110, %81
%117 = getelementptr inbounds double, double* %3, i64 %116
%118 = load double, double* %117
%119 = tail call double @llvm.fmuladd.f64(double %30, double %118, double %115)
%120 = tail call double @llvm.fmuladd.f64(double %119, double %119, double %33)
%121 = fadd double %111, %120
br label %122
122: ; preds = %112, %108, %68
%123 = phi double [ 0.000000e+00, %68 ], [ %109, %108 ], [ %121, %112 ]
%124 = fsub double %74, %43
%125 = tail call double @llvm.fmuladd.f64(double %124, double %123, double %40)
%126 = fcmp uge double %74, %8
%127 = fcmp uge double %76, %10
%128 = select i1 %126, i1 true, i1 %127
%129 = icmp sgt i32 %72, %19
%130 = select i1 %128, i1 true, i1 %129
%131 = icmp sgt i32 %71, %20
%132 = select i1 %130, i1 true, i1 %131
br i1 %132, label %133, label %39
133: ; preds = %122, %14
%134 = phi double [ 0.000000e+00, %14 ], [ %125, %122 ]
ret double %134
}