#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_overlap_index(double x1, double y1, int nx2, int ny2, const double *x2,
                      const double *y2, int *i2, int *j2) {
  int i, j, l2;
  double dx, dy;
  for (j = 0; j < ny2; j++)
    for (i = 0; i < nx2; i++) {
      l2 = j * nx2 + i;
      dx = fabs(x1 - x2[l2]);
      dy = fabs(y1 - y2[l2]);
      if (dx < (1.0e-10) && dy < (1.0e-10)) {
        i2[0] = i;
        j2[0] = j;
        return 1;
      }
    }
  return 0;
}


x86 assembly (clang, -O0):
<get_overlap_index>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1205 <get_overlap_index+0x105>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f2 <get_overlap_index+0xf2>
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xea0(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xe7e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe5d(%rip),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    11df <get_overlap_index+0xdf>
movsd  0xe4a(%rip),%xmm0
ucomisd -0x60(%rbp),%xmm0
jbe    11df <get_overlap_index+0xdf>
mov    -0x44(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120c <get_overlap_index+0x10c>
jmp    11e4 <get_overlap_index+0xe4>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    113e <get_overlap_index+0x3e>
jmp    11f7 <get_overlap_index+0xf7>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    112b <get_overlap_index+0x2b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_overlap_index>:
push   %rbx
test   %esi,%esi
jle    118c <get_overlap_index+0x8c>
movslq %edi,%r11
mov    %esi,%r10d
mov    %r11d,%eax
shl    $0x3,%r11
xor    %esi,%esi
movapd 0xee0(%rip),%xmm2
movsd  0xee8(%rip),%xmm3
jmp    113f <get_overlap_index+0x3f>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rsi
add    %r11,%rdx
add    %r11,%rcx
cmp    %r10,%rsi
je     118c <get_overlap_index+0x8c>
test   %edi,%edi
jle    1130 <get_overlap_index+0x30>
xor    %ebx,%ebx
jmp    1159 <get_overlap_index+0x59>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%rax
je     1130 <get_overlap_index+0x30>
movapd %xmm0,%xmm4
subsd  (%rdx,%rbx,8),%xmm4
andpd  %xmm2,%xmm4
ucomisd %xmm4,%xmm3
jbe    1150 <get_overlap_index+0x50>
movapd %xmm1,%xmm4
subsd  (%rcx,%rbx,8),%xmm4
andpd  %xmm2,%xmm4
ucomisd %xmm4,%xmm3
jbe    1150 <get_overlap_index+0x50>
mov    %ebx,(%r8)
mov    %esi,(%r9)
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @get_overlap_index(double %0, double %1, i32 %2, i32 %3, double* %4, double* %5, i32* %6, i32* %7) {
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double
store double %0, double* %10
store double %1, double* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store double* %4, double** %14
store double* %5, double** %15
store i32* %6, i32** %16
store i32* %7, i32** %17
store i32 0, i32* %19
br label %23
23: ; preds = %71, %8
%24 = load i32, i32* %19
%25 = load i32, i32* %13
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %74
27: ; preds = %23
store i32 0, i32* %18
br label %28
28: ; preds = %67, %27
%29 = load i32, i32* %18
%30 = load i32, i32* %12
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %70
32: ; preds = %28
%33 = load i32, i32* %19
%34 = load i32, i32* %12
%35 = mul nsw i32 %33, %34
%36 = load i32, i32* %18
%37 = add nsw i32 %35, %36
store i32 %37, i32* %20
%38 = load double, double* %10
%39 = load double*, double** %14
%40 = load i32, i32* %20
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = fsub double %38, %43
%45 = call double @llvm.fabs.f64(double %44)
store double %45, double* %21
%46 = load double, double* %11
%47 = load double*, double** %15
%48 = load i32, i32* %20
%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* %22
%54 = load double, double* %21
%55 = fcmp olt double %54, 1.000000e-10
br i1 %55, label %56, label %66
56: ; preds = %32
%57 = load double, double* %22
%58 = fcmp olt double %57, 1.000000e-10
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = load i32, i32* %18
%61 = load i32*, i32** %16
%62 = getelementptr inbounds i32, i32* %61, i64 0
store i32 %60, i32* %62
%63 = load i32, i32* %19
%64 = load i32*, i32** %17
%65 = getelementptr inbounds i32, i32* %64, i64 0
store i32 %63, i32* %65
store i32 1, i32* %9
br label %75
66: ; preds = %56, %32
br label %67
67: ; preds = %66
%68 = load i32, i32* %18
%69 = add nsw i32 %68, 1
store i32 %69, i32* %18
br label %28
70: ; preds = %28
br label %71
71: ; preds = %70
%72 = load i32, i32* %19
%73 = add nsw i32 %72, 1
store i32 %73, i32* %19
br label %23
74: ; preds = %23
store i32 0, i32* %9
br label %75
75: ; preds = %74, %59
%76 = load i32, i32* %9
ret i32 %76
}

LLVM IR (-O2):
define i32 @get_overlap_index(double %0, double %1, i32 %2, i32 %3, double* nocapture %4, double* nocapture %5, i32* nocapture writeonly %6, i32* nocapture writeonly %7) {
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %42
10: ; preds = %8
%11 = icmp sgt i32 %2, 0
%12 = sext i32 %2 to i64
%13 = zext i32 %3 to i64
%14 = zext i32 %2 to i64
br label %15
15: ; preds = %10, %39
%16 = phi i64 [ 0, %10 ], [ %40, %39 ]
br i1 %11, label %17, label %39
17: ; preds = %15
%18 = mul nsw i64 %16, %12
br label %19
19: ; preds = %17, %36
%20 = phi i64 [ 0, %17 ], [ %37, %36 ]
%21 = add nsw i64 %20, %18
%22 = getelementptr inbounds double, double* %4, i64 %21
%23 = load double, double* %22
%24 = fsub double %0, %23
%25 = tail call double @llvm.fabs.f64(double %24)
%26 = getelementptr inbounds double, double* %5, i64 %21
%27 = load double, double* %26
%28 = fsub double %1, %27
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fcmp olt double %25, 1.000000e-10
%31 = fcmp olt double %29, 1.000000e-10
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %33, label %36
33: ; preds = %19
%34 = trunc i64 %16 to i32
%35 = trunc i64 %20 to i32
store i32 %35, i32* %6
store i32 %34, i32* %7
br label %42
36: ; preds = %19
%37 = add nuw nsw i64 %20, 1
%38 = icmp eq i64 %37, %14
br i1 %38, label %39, label %19
39: ; preds = %36, %15
%40 = add nuw nsw i64 %16, 1
%41 = icmp eq i64 %40, %13
br i1 %41, label %42, label %15
42: ; preds = %39, %8, %33
%43 = phi i32 [ 1, %33 ], [ 0, %8 ], [ 0, %39 ]
ret i32 %43
}