int SHPCheckBoundsOverlap(double *padfBox1Min, double *padfBox1Max,
                          double *padfBox2Min, double *padfBox2Max,
                          int nDimension) {
  int iDim;
  for (iDim = 0; iDim < nDimension; iDim++) {
    if (padfBox2Max[iDim] < padfBox1Min[iDim])
      return 0;
    if (padfBox1Max[iDim] < padfBox2Min[iDim])
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<SHPCheckBoundsOverlap>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    119e <SHPCheckBoundsOverlap+0x9e>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    115b <SHPCheckBoundsOverlap+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <SHPCheckBoundsOverlap+0xa5>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    118b <SHPCheckBoundsOverlap+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <SHPCheckBoundsOverlap+0xa5>
jmp    1190 <SHPCheckBoundsOverlap+0x90>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    111f <SHPCheckBoundsOverlap+0x1f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<SHPCheckBoundsOverlap>:
mov    $0x1,%eax
test   %r8d,%r8d
jle    1135 <SHPCheckBoundsOverlap+0x35>
mov    %r8d,%r8d
xor    %r9d,%r9d
movsd  (%rdi,%r9,8),%xmm0
ucomisd (%rcx,%r9,8),%xmm0
ja     1136 <SHPCheckBoundsOverlap+0x36>
movsd  (%rdx,%r9,8),%xmm0
ucomisd (%rsi,%r9,8),%xmm0
ja     1136 <SHPCheckBoundsOverlap+0x36>
add    $0x1,%r9
cmp    %r9,%r8
jne    1110 <SHPCheckBoundsOverlap+0x10>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @SHPCheckBoundsOverlap(double* %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store i32 %4, i32* %11
store i32 0, i32* %12
br label %13
13: ; preds = %44, %5
%14 = load i32, i32* %12
%15 = load i32, i32* %11
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %47
17: ; preds = %13
%18 = load double*, double** %10
%19 = load i32, i32* %12
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %7
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fcmp olt double %22, %27
br i1 %28, label %29, label %30
29: ; preds = %17
store i32 0, i32* %6
br label %48
30: ; preds = %17
%31 = load double*, double** %8
%32 = load i32, i32* %12
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = load double*, double** %9
%37 = load i32, i32* %12
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = fcmp olt double %35, %40
br i1 %41, label %42, label %43
42: ; preds = %30
store i32 0, i32* %6
br label %48
43: ; preds = %30
br label %44
44: ; preds = %43
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %13
47: ; preds = %13
store i32 1, i32* %6
br label %48
48: ; preds = %47, %42, %29
%49 = load i32, i32* %6
ret i32 %49
}

LLVM IR (-O2):
define i32 @SHPCheckBoundsOverlap(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %25
7: ; preds = %5
%8 = zext i32 %4 to i64
br label %11
9: ; preds = %18
%10 = icmp eq i64 %24, %8
br i1 %10, label %25, label %11
11: ; preds = %7, %9
%12 = phi i64 [ 0, %7 ], [ %24, %9 ]
%13 = getelementptr inbounds double, double* %3, i64 %12
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %0, i64 %12
%16 = load double, double* %15
%17 = fcmp olt double %14, %16
br i1 %17, label %25, label %18
18: ; preds = %11
%19 = getelementptr inbounds double, double* %1, i64 %12
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %2, i64 %12
%22 = load double, double* %21
%23 = fcmp olt double %20, %22
%24 = add nuw nsw i64 %12, 1
br i1 %23, label %25, label %9
25: ; preds = %11, %18, %9, %5
%26 = phi i32 [ 1, %5 ], [ 1, %9 ], [ 0, %18 ], [ 0, %11 ]
ret i32 %26
}