#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);
int get_contact_index(int size1, int size2, double *x1, double *y1, double *x2,
                      double *y2, double periodx, double periody, int *start1,
                      int *end1, int *start2, int *end2) {
  int i1, i2;
  double dx, dy;
  *start1 = -1;
  *start2 = -1;
  for (i1 = 0; i1 < size1; i1++) {
    for (i2 = 0; i2 < size2; i2++) {
      dx = fabs(x1[i1] - x2[i2]);
      dx = (dx < fabs(dx - periodx) ? dx : fabs(dx - periodx));
      dy = fabs(y1[i1] - y2[i2]);
      dy = (dy < fabs(dy - periody) ? dy : fabs(dy - periody));
      if (dx < (1.0e-10) && dy < (1.0e-10)) {
        *start1 = i1 + 1;
        *start2 = i2 + 1;
        goto foundstart;
      }
    }
  }
  return 0;
foundstart:
  *end1 = -1;
  *end2 = -1;
  for (i1 = size1 - 1; i1 >= 0; i1--) {
    for (i2 = size2 - 1; i2 >= 0; i2--) {
      dx = fabs(x1[i1] - x2[i2]);
      dx = (dx < fabs(dx - periodx) ? dx : fabs(dx - periodx));
      dy = fabs(y1[i1] - y2[i2]);
      dy = (dy < fabs(dy - periody) ? dy : fabs(dy - periody));
      if (dx < (1.0e-10) && dy < (1.0e-10)) {
        *end1 = i1 + 1;
        *end2 = i2 + 1;
        goto foundend;
      }
    }
  }
  return 0;
foundend:
  if (*start1 == *end1 || *start2 == *end2)
    return 0;
  if (*start1 > *end1)
    (*start1)--;
  else
    (*end1)--;
  if (*start2 > *end2)
    (*start2)--;
  else
    (*end2)--;
  return 1;
}


x86 assembly (clang, -O0):
<get_contact_index>:
push   %rbp
mov    %rsp,%rbp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
mov    0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12d9 <get_contact_index+0x1d9>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12c6 <get_contact_index+0x1c6>
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x48(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xe71(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xe52(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11cb <get_contact_index+0xcb>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    11e5 <get_contact_index+0xe5>
movsd  -0x50(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xe24(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x48(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xdf0(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movaps 0xdd1(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    124c <get_contact_index+0x14c>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1266 <get_contact_index+0x166>
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movaps 0xda3(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xd98(%rip),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    12b3 <get_contact_index+0x1b3>
movsd  0xd85(%rip),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    12b3 <get_contact_index+0x1b3>
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    12e5 <get_contact_index+0x1e5>
jmp    12b8 <get_contact_index+0x1b8>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1162 <get_contact_index+0x62>
jmp    12cb <get_contact_index+0x1cb>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    114f <get_contact_index+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    1527 <get_contact_index+0x427>
mov    0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jl     148a <get_contact_index+0x38a>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jl     1477 <get_contact_index+0x377>
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x48(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xcc0(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xca1(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    137c <get_contact_index+0x27c>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    1396 <get_contact_index+0x296>
movsd  -0x50(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xc73(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x48(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xc3f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movaps 0xc20(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    13fd <get_contact_index+0x2fd>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    1417 <get_contact_index+0x317>
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movaps 0xbf2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xbe7(%rip),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    1464 <get_contact_index+0x364>
movsd  0xbd4(%rip),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    1464 <get_contact_index+0x364>
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
mov    0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    1496 <get_contact_index+0x396>
jmp    1469 <get_contact_index+0x369>
mov    -0x48(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
jmp    1315 <get_contact_index+0x215>
jmp    147c <get_contact_index+0x37c>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    1302 <get_contact_index+0x202>
movl   $0x0,-0x4(%rbp)
jmp    1527 <get_contact_index+0x427>
mov    0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x18(%rbp),%rcx
cmp    (%rcx),%eax
je     14ba <get_contact_index+0x3ba>
mov    0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x28(%rbp),%rcx
cmp    (%rcx),%eax
jne    14c6 <get_contact_index+0x3c6>
movl   $0x0,-0x4(%rbp)
jmp    1527 <get_contact_index+0x427>
mov    0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x18(%rbp),%rcx
cmp    (%rcx),%eax
jle    14e8 <get_contact_index+0x3e8>
mov    0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
jmp    14f3 <get_contact_index+0x3f3>
mov    0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x28(%rbp),%rcx
cmp    (%rcx),%eax
jle    1515 <get_contact_index+0x415>
mov    0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
jmp    1520 <get_contact_index+0x420>
mov    0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_contact_index>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x48(%rsp),%r10
mov    0x38(%rsp),%r14
movl   $0xffffffff,(%r14)
movl   $0xffffffff,(%r10)
test   %edi,%edi
jle    1256 <get_contact_index+0x156>
mov    0x50(%rsp),%r11
mov    0x40(%rsp),%r15
mov    %edi,%r12d
mov    %esi,%r13d
unpcklpd %xmm0,%xmm1
xor    %ebx,%ebx
movapd 0xeb8(%rip),%xmm0
movapd 0xec0(%rip),%xmm2
jmp    116d <get_contact_index+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %r12,%rbx
je     1256 <get_contact_index+0x156>
test   %esi,%esi
jle    1160 <get_contact_index+0x60>
movsd  (%rcx,%rbx,8),%xmm3
movhpd (%rdx,%rbx,8),%xmm3
xor    %eax,%eax
nopl   (%rax)
movsd  (%r9,%rax,8),%xmm4
movhpd (%r8,%rax,8),%xmm4
movapd %xmm3,%xmm5
subpd  %xmm4,%xmm5
andpd  %xmm0,%xmm5
movapd %xmm5,%xmm4
subpd  %xmm1,%xmm4
andpd  %xmm0,%xmm4
minpd  %xmm4,%xmm5
cmpltpd %xmm2,%xmm5
movmskpd %xmm5,%ebp
cmp    $0x3,%bpl
je     11c2 <get_contact_index+0xc2>
add    $0x1,%rax
cmp    %rax,%r13
jne    1180 <get_contact_index+0x80>
jmp    1160 <get_contact_index+0x60>
add    $0x1,%ebx
mov    %ebx,(%r14)
add    $0x1,%eax
mov    %eax,(%r10)
movl   $0xffffffff,(%r15)
movl   $0xffffffff,(%r11)
movslq %edi,%rdi
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rdi
movsd  -0x8(%rcx,%rbx,8),%xmm3
movhpd -0x8(%rdx,%rbx,8),%xmm3
mov    %r13,%rsi
cs nopw 0x0(%rax,%rax,1)
nop
test   %rsi,%rsi
jle    1250 <get_contact_index+0x150>
add    $0xffffffffffffffff,%rsi
mov    %esi,%eax
shl    $0x3,%rax
movsd  (%r9,%rax,1),%xmm4
movhpd (%r8,%rax,1),%xmm4
movapd %xmm3,%xmm5
subpd  %xmm4,%xmm5
andpd  %xmm0,%xmm5
movapd %xmm5,%xmm4
subpd  %xmm1,%xmm4
andpd  %xmm0,%xmm4
minpd  %xmm4,%xmm5
cmpltpd %xmm2,%xmm5
movmskpd %xmm5,%eax
cmp    $0x3,%al
jne    1200 <get_contact_index+0x100>
jmp    125a <get_contact_index+0x15a>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x2,%rbx
jge    11df <get_contact_index+0xdf>
xor    %eax,%eax
jmp    12a0 <get_contact_index+0x1a0>
lea    0x1(%rsi),%eax
mov    %ebx,(%r15)
mov    %eax,(%r11)
mov    (%r14),%edx
mov    (%r15),%ecx
xor    %eax,%eax
cmp    %ecx,%edx
je     12a0 <get_contact_index+0x1a0>
sub    (%r10),%esi
cmp    $0xffffffff,%esi
je     12a0 <get_contact_index+0x1a0>
cmp    %ecx,%edx
cmovg  %edx,%ecx
cmovg  %r14,%r15
add    $0xffffffff,%ecx
mov    %ecx,(%r15)
mov    (%r10),%eax
mov    (%r11),%ecx
cmp    %ecx,%eax
cmovg  %eax,%ecx
cmovg  %r10,%r11
add    $0xffffffff,%ecx
mov    %ecx,(%r11)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @get_contact_index(i32 %0, i32 %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double %6, double %7, i32* nocapture %8, i32* nocapture %9, i32* nocapture %10, i32* nocapture %11) {
store i32 -1, i32* %8
store i32 -1, i32* %10
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %115
14: ; preds = %12
%15 = icmp sgt i32 %1, 0
%16 = zext i32 %0 to i64
%17 = zext i32 %1 to i64
%18 = insertelement <2 x double> poison, double %7, i64 0
%19 = insertelement <2 x double> %18, double %6, i64 1
br label %20
20: ; preds = %14, %59
%21 = phi i64 [ 0, %14 ], [ %60, %59 ]
br i1 %15, label %22, label %59
22: ; preds = %20
%23 = getelementptr inbounds double, double* %2, i64 %21
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %3, i64 %21
%26 = load double, double* %25
%27 = insertelement <2 x double> poison, double %26, i64 0
%28 = insertelement <2 x double> %27, double %24, i64 1
br label %29
29: ; preds = %22, %56
%30 = phi i64 [ 0, %22 ], [ %57, %56 ]
%31 = getelementptr inbounds double, double* %4, i64 %30
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %5, i64 %30
%34 = load double, double* %33
%35 = insertelement <2 x double> poison, double %34, i64 0
%36 = insertelement <2 x double> %35, double %32, i64 1
%37 = fsub <2 x double> %28, %36
%38 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %37)
%39 = fsub <2 x double> %38, %19
%40 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %39)
%41 = fcmp olt <2 x double> %38, %40
%42 = select <2 x i1> %41, <2 x double> %38, <2 x double> %40
%43 = fcmp olt <2 x double> %42, <double 1.000000e-10, double 1.000000e-10>
%44 = extractelement <2 x i1> %43, i64 0
%45 = extractelement <2 x i1> %43, i64 1
%46 = select i1 %45, i1 %44, i1 false
br i1 %46, label %47, label %56
47: ; preds = %29
%48 = zext i32 %1 to i64
%49 = trunc i64 %21 to i32
%50 = trunc i64 %30 to i32
%51 = add nuw nsw i32 %49, 1
store i32 %51, i32* %8
%52 = add nuw nsw i32 %50, 1
store i32 %52, i32* %10
store i32 -1, i32* %9
store i32 -1, i32* %11
%53 = sext i32 %0 to i64
%54 = insertelement <2 x double> poison, double %7, i64 0
%55 = insertelement <2 x double> %54, double %6, i64 1
br label %64
56: ; preds = %29
%57 = add nuw nsw i64 %30, 1
%58 = icmp eq i64 %57, %17
br i1 %58, label %59, label %29
59: ; preds = %56, %20
%60 = add nuw nsw i64 %21, 1
%61 = icmp eq i64 %60, %16
br i1 %61, label %115, label %20
62: ; preds = %73
%63 = icmp sgt i64 %65, 1
br i1 %63, label %64, label %115
64: ; preds = %47, %62
%65 = phi i64 [ %53, %47 ], [ %66, %62 ]
%66 = add nsw i64 %65, -1
%67 = getelementptr inbounds double, double* %2, i64 %66
%68 = getelementptr inbounds double, double* %3, i64 %66
%69 = load double, double* %67
%70 = load double, double* %68
%71 = insertelement <2 x double> poison, double %70, i64 0
%72 = insertelement <2 x double> %71, double %69, i64 1
br label %73
73: ; preds = %64, %77
%74 = phi i64 [ %48, %64 ], [ %75, %77 ]
%75 = add nsw i64 %74, -1
%76 = icmp sgt i64 %74, 0
br i1 %76, label %77, label %62
77: ; preds = %73
%78 = and i64 %75, 4294967295
%79 = getelementptr inbounds double, double* %4, i64 %78
%80 = load double, double* %79
%81 = getelementptr inbounds double, double* %5, i64 %78
%82 = load double, double* %81
%83 = insertelement <2 x double> poison, double %82, i64 0
%84 = insertelement <2 x double> %83, double %80, i64 1
%85 = fsub <2 x double> %72, %84
%86 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %85)
%87 = fsub <2 x double> %86, %55
%88 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %87)
%89 = fcmp olt <2 x double> %86, %88
%90 = select <2 x i1> %89, <2 x double> %86, <2 x double> %88
%91 = fcmp olt <2 x double> %90, <double 1.000000e-10, double 1.000000e-10>
%92 = extractelement <2 x i1> %91, i64 0
%93 = extractelement <2 x i1> %91, i64 1
%94 = select i1 %93, i1 %92, i1 false
br i1 %94, label %95, label %73
95: ; preds = %77
%96 = trunc i64 %65 to i32
%97 = trunc i64 %74 to i32
store i32 %96, i32* %9
store i32 %97, i32* %11
%98 = load i32, i32* %8
%99 = load i32, i32* %9
%100 = icmp eq i32 %98, %99
br i1 %100, label %115, label %101
101: ; preds = %95
%102 = load i32, i32* %10
%103 = icmp eq i32 %102, %97
br i1 %103, label %115, label %104
104: ; preds = %101
%105 = icmp sgt i32 %98, %99
%106 = select i1 %105, i32 %98, i32 %99
%107 = select i1 %105, i32* %8, i32* %9
%108 = add nsw i32 %106, -1
store i32 %108, i32* %107
%109 = load i32, i32* %10
%110 = load i32, i32* %11
%111 = icmp sgt i32 %109, %110
%112 = select i1 %111, i32 %109, i32 %110
%113 = select i1 %111, i32* %10, i32* %11
%114 = add nsw i32 %112, -1
store i32 %114, i32* %113
br label %115
115: ; preds = %59, %62, %104, %12, %95, %101
%116 = phi i32 [ 0, %101 ], [ 0, %95 ], [ 0, %12 ], [ 1, %104 ], [ 0, %62 ], [ 0, %59 ]
ret i32 %116
}