// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/math.c
// Function: intersectRayBox
bool intersectRayBox(const float *P,const float *invV,
                     const float *boxMin,const float *boxMax,
                     float *h0,float *h1) {

  //from libdimension
  // This is actually correct, even though it appears not to handle edge cases
  // (line.n.{x,y,z} == 0).  It works because the infinities that result from
  // dividing by zero will still behave correctly in the comparisons.  Lines
  // which are parallel to an axis and outside the box will have tmin == inf
  // or tmax == -inf, while lines inside the box will have tmin and tmax
  // unchanged.
  float t=INFINITY;
  float tx1 = (boxMin[0] - P[0])*invV[0];
  float tx2 = (boxMax[0] - P[0])*invV[0];

  float tmin = minOf(tx1, tx2);
  float tmax = maxOf(tx1, tx2);

  float ty1 = (boxMin[1] - P[1])*invV[1];
  float ty2 = (boxMax[1] - P[1])*invV[1];

  tmin = maxOf(tmin, minOf(ty1, ty2));
  tmax = minOf(tmax, maxOf(ty1, ty2));

  float tz1 = (boxMin[2] - P[2])*invV[2];
  float tz2 = (boxMax[2] - P[2])*invV[2];

  tmin = maxOf(tmin, minOf(tz1, tz2));
  tmax = minOf(tmax, maxOf(tz1, tz2));
  *h0=maxOf(0.0f,tmin);
  *h1=tmax;
  return tmax >= maxOf(0.0f, tmin) && tmin < t;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movss 0xd61c8(%rip), %xmm0    # 0x4e4910
movss %xmm0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movss (%rax), %xmm0
movq -0x8(%rbp), %rax
subss (%rax), %xmm0
movq -0x10(%rbp), %rax
mulss (%rax), %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x20(%rbp), %rax
movss (%rax), %xmm0
movq -0x8(%rbp), %rax
subss (%rax), %xmm0
movq -0x10(%rbp), %rax
mulss (%rax), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x38(%rbp), %xmm0
movss -0x3c(%rbp), %xmm1
callq 0x40dbb0
movss %xmm0, -0x40(%rbp)
movss -0x38(%rbp), %xmm0
movss -0x3c(%rbp), %xmm1
callq 0x40dbf0
movss %xmm0, -0x44(%rbp)
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
mulss 0x4(%rax), %xmm0
movss %xmm0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
mulss 0x4(%rax), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x40(%rbp), %xmm0
movss %xmm0, -0x6c(%rbp)
movss -0x48(%rbp), %xmm0
movss -0x4c(%rbp), %xmm1
callq 0x40dbb0
movaps %xmm0, %xmm1
movss -0x6c(%rbp), %xmm0
callq 0x40dbf0
movss %xmm0, -0x40(%rbp)
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x48(%rbp), %xmm0
movss -0x4c(%rbp), %xmm1
callq 0x40dbf0
movaps %xmm0, %xmm1
movss -0x68(%rbp), %xmm0
callq 0x40dbb0
movss %xmm0, -0x44(%rbp)
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
mulss 0x8(%rax), %xmm0
movss %xmm0, -0x50(%rbp)
movq -0x20(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
mulss 0x8(%rax), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x40(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x50(%rbp), %xmm0
movss -0x54(%rbp), %xmm1
callq 0x40dbb0
movaps %xmm0, %xmm1
movss -0x64(%rbp), %xmm0
callq 0x40dbf0
movss %xmm0, -0x40(%rbp)
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x50(%rbp), %xmm0
movss -0x54(%rbp), %xmm1
callq 0x40dbf0
movaps %xmm0, %xmm1
movss -0x60(%rbp), %xmm0
callq 0x40dbb0
movss %xmm0, -0x44(%rbp)
movss -0x40(%rbp), %xmm1
xorps %xmm0, %xmm0
callq 0x40dbf0
movq -0x28(%rbp), %rax
movss %xmm0, (%rax)
movss -0x44(%rbp), %xmm0
movq -0x30(%rbp), %rax
movss %xmm0, (%rax)
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movss -0x40(%rbp), %xmm1
xorps %xmm0, %xmm0
callq 0x40dbf0
movaps %xmm0, %xmm1
movss -0x5c(%rbp), %xmm0
xorl %eax, %eax
ucomiss %xmm1, %xmm0
movb %al, -0x55(%rbp)
jb 0x40e939
movss -0x40(%rbp), %xmm1
movss -0x34(%rbp), %xmm0
ucomiss %xmm1, %xmm0
seta %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)