// File: /workspace/github_cpp_makefile_star2_O3/BartMassey[P]ancient-raytracer/render.cc
// Function: trace(ray, model&, int)
point trace( ray r, model &m, int depth ) {
  object *p, *current = 0;
  intersection s, sb;

  if( depth > m.maxdepth ) {
    point value( m.bg );
    
    value.dilate(0);
    return value;
  }
  // find an object struct by the ray
  for( p = &m.scene; p; p = p->next() )
    if( p->intersect( r, s ) ) {
	sb = s;
	current = p;
	break;
    }
  if (!current) {
    point value( m.bg );
    
    value.dilate(0);
    return value;
  }
  // if there are other intersections,
  // choose the nearest
  for( p = p->next(); p; p = p->next() )
    if( p->intersect( r, s ) && s.t < sb.t ) {
      delete sb.normal;
      delete sb.at;
      sb = s;
      current = p;
    }
  // determine the pixel value
  point nr(r.at( sb.t ));
  point value( (current->get_texture()).value(
   *sb.at, nr, *sb.normal, m, depth + 1 ) );

  delete sb.normal;
  delete sb.at;
  value.dilate(1);
  return value;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdi, %rbx
cmpl %ecx, 0x20(%rdx)
jge 0x238b
movq 0x18(%rdx), %rcx
leaq 0x94e8(%rip), %rax      # 0xb848
movq %rax, (%rbx)
movslq 0x8(%rcx), %rax
testq %rax, %rax
jle 0x24a3
xorl %edx, %edx
movss 0xc(%rcx,%rdx,4), %xmm0
movss %xmm0, 0xc(%rbx,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x2372
jmp 0x249a
movl %ecx, 0x2c(%rsp)
movq %rdx, 0x30(%rsp)
movq 0x10(%rdx), %r14
testq %r14, %r14
je 0x2468
movq %rsi, %r13
leaq 0x14(%rsi), %rax
movq %rax, 0x20(%rsp)
leaq 0x34(%rsi), %rax
movq %rax, 0x18(%rsp)
leaq 0x976b(%rip), %r12      # 0xbb28
addq $0x10, %r12
leaq 0xd8(%rsp), %r15
leaq 0x38(%rsp), %rbp
movq %r12, 0xd8(%rsp)
leaq 0x946b(%rip), %rax      # 0xb848
movq %rax, 0xe0(%rsp)
movslq 0x10(%r13), %rdx
movl %edx, 0xe8(%rsp)
testq %rdx, %rdx
jle 0x240b
shlq $0x2, %rdx
leaq 0xec(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x20a0
leaq 0x9436(%rip), %rax      # 0xb848
movq %rax, 0x100(%rsp)
movslq 0x30(%r13), %rdx
movl %edx, 0x108(%rsp)
testq %rdx, %rdx
jle 0x2440
shlq $0x2, %rdx
leaq 0x10c(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x20a0
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq *0x28(%rax)
testl %eax, %eax
jne 0x24c5
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movq %rax, %r14
testq %rax, %rax
jne 0x23ce
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rcx
leaq 0x93d0(%rip), %rax      # 0xb848
movq %rax, (%rbx)
movslq 0x8(%rcx), %rax
testq %rax, %rax
jle 0x24a3
xorl %edx, %edx
movss 0xc(%rcx,%rdx,4), %xmm0
movss %xmm0, 0xc(%rbx,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x2486
cmpl $0x4, %eax
jge 0x2727
movl $0x0, 0xc(%rbx,%rax,4)
incl %eax
movl %eax, 0x8(%rbx)
movq %rbx, %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movss 0x38(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x40(%rsp), %rbp
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
testq %rax, %rax
je 0x25e0
movq %rax, %r15
movq %r12, 0x90(%rsp)
leaq 0x9344(%rip), %rax      # 0xb848
movq %rax, 0x98(%rsp)
movslq 0x10(%r13), %rdx
movl %edx, 0xa0(%rsp)
testq %rdx, %rdx
jle 0x2532
shlq $0x2, %rdx
leaq 0xa4(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x20a0
leaq 0x930f(%rip), %rax      # 0xb848
movq %rax, 0xb8(%rsp)
movslq 0x30(%r13), %rdx
movl %edx, 0xc0(%rsp)
testq %rdx, %rdx
jle 0x2567
shlq $0x2, %rdx
leaq 0xc4(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x20a0
movq (%r15), %rax
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq *0x28(%rax)
testl %eax, %eax
je 0x25cb
movss 0xc(%rsp), %xmm0
ucomiss 0x38(%rsp), %xmm0
jbe 0x25cb
testq %rbp, %rbp
je 0x259d
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x18(%rax)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x25ad
movq (%rdi), %rax
callq *0x18(%rax)
movss 0x38(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x40(%rsp), %rbp
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r15, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x30(%rax)
movq %rax, %r15
testq %rax, %rax
jne 0x24f5
movslq 0x30(%r13), %r15
testq %r15, %r15
jle 0x2620
leaq 0x7c(%rsp), %rdi
leaq (,%r15,4), %rdx
movq 0x18(%rsp), %rsi
callq 0x20a0
movss 0xc(%rsp), %xmm1
xorl %eax, %eax
movss 0x7c(%rsp,%rax,4), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, 0x7c(%rsp,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x2608
movslq 0x10(%r13), %r12
testq %r12, %r12
jle 0x2643
leaq (,%r12,4), %rdx
leaq 0x124(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x20a0
leaq 0x91fe(%rip), %rax      # 0xb848
movq %rax, 0x50(%rsp)
movl %r15d, 0x58(%rsp)
testl %r15d, %r15d
jle 0x2670
leaq 0x7c(%rsp), %rsi
leaq 0x5c(%rsp), %rdi
leaq (,%r15,4), %rdx
callq 0x20a0
testl %r12d, %r12d
jle 0x2692
leaq 0x144(%rsp), %rdi
leaq (,%r12,4), %rdx
leaq 0x124(%rsp), %rsi
callq 0x20a0
cmpl %r12d, %r15d
jne 0x2746
testl %r15d, %r15d
jle 0x26bf
xorl %eax, %eax
movss 0x144(%rsp,%rax,4), %xmm0
addss 0x5c(%rsp,%rax,4), %xmm0
movss %xmm0, 0x5c(%rsp,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x26a2
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movl 0x2c(%rsp), %ecx
incl %ecx
movq (%rax), %r10
movl %ecx, (%rsp)
leaq 0x50(%rsp), %rcx
movq %rbx, %rdi
movq %rax, %rsi
movq 0x10(%rsp), %r14
movq %r14, %rdx
movq %rbp, %r8
movq 0x30(%rsp), %r9
callq *0x18(%r10)
testq %rbp, %rbp
je 0x2702
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x18(%rax)
testq %r14, %r14
je 0x2710
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movslq 0x8(%rbx), %rax
cmpq $0x4, %rax
jge 0x2727
movl $0x3f800000, 0xc(%rbx,%rax,4) # imm = 0x3F800000
jmp 0x24ab
leaq 0x5afd(%rip), %rdi      # 0x822b
leaq 0x5971(%rip), %rsi      # 0x80a6
leaq 0x5afa(%rip), %rcx      # 0x8236
movl $0xeb, %edx
callq 0x2080
leaq 0x5983(%rip), %rdi      # 0x80d0
leaq 0x5952(%rip), %rsi      # 0x80a6
leaq 0x59a6(%rip), %rcx      # 0x8101
movl $0x66, %edx
callq 0x2080