// File: /workspace/github_cpp_makefile_star2_O1/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 $0x168, %rsp            # imm = 0x168
movq %rdi, %rbx
cmpl %ecx, 0x20(%rdx)
jge 0x238e
movq 0x18(%rdx), %rcx
leaq 0xa4e8(%rip), %rax      # 0xc848
movq %rax, (%rbx)
movslq 0x8(%rcx), %rax
movl %eax, 0x8(%rbx)
testq %rax, %rax
jle 0x2749
xorl %edx, %edx
movss 0xc(%rcx,%rdx,4), %xmm0
movss %xmm0, 0xc(%rbx,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x2375
jmp 0x2749
movq %rsi, %r13
movl %ecx, 0x24(%rsp)
movq %rdx, 0x28(%rsp)
movq 0x10(%rdx), %r14
testq %r14, %r14
je 0x245b
leaq 0x14(%r13), %rax
movq %rax, 0x10(%rsp)
leaq 0x34(%r13), %rbp
leaq 0xa76d(%rip), %r12      # 0xcb28
addq $0x10, %r12
leaq 0xa482(%rip), %r15      # 0xc848
movq %r12, 0x108(%rsp)
movq %r15, 0x110(%rsp)
movslq 0x10(%r13), %rdx
movl %edx, 0x118(%rsp)
testq %rdx, %rdx
jle 0x23fc
shlq $0x2, %rdx
leaq 0x11c(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x20a0
movq %r15, 0x130(%rsp)
movslq 0x30(%r13), %rdx
movl %edx, 0x138(%rsp)
testq %rdx, %rdx
jle 0x2428
shlq $0x2, %rdx
leaq 0x13c(%rsp), %rdi
movq %rbp, %rsi
callq 0x20a0
movq (%r14), %rax
movq %r14, %rdi
leaq 0x108(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq *0x28(%rax)
testl %eax, %eax
jne 0x245f
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movq %rax, %r14
testq %rax, %rax
jne 0x23c6
xorl %eax, %eax
jmp 0x2477
xorl %eax, %eax
jmp 0x2477
movss 0x38(%rsp), %xmm0
movq 0x40(%rsp), %rbp
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rax
testq %rax, %rax
je 0x2714
movss %xmm0, 0x10(%rsp)
movq %rax, 0x30(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
testq %rax, %rax
je 0x25a3
movq %rax, %r15
leaq 0x14(%r13), %rax
movq %rax, 0x58(%rsp)
leaq 0x34(%r13), %rax
movq %rax, 0x50(%rsp)
leaq 0xa66f(%rip), %r14      # 0xcb28
addq $0x10, %r14
leaq 0xa384(%rip), %r12      # 0xc848
movq %r14, 0xc0(%rsp)
movq %r12, 0xc8(%rsp)
movslq 0x10(%r13), %rdx
movl %edx, 0xd0(%rsp)
testq %rdx, %rdx
jle 0x24fa
shlq $0x2, %rdx
leaq 0xd4(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x20a0
movq %r12, 0xe8(%rsp)
movslq 0x30(%r13), %rdx
movl %edx, 0xf0(%rsp)
testq %rdx, %rdx
jle 0x2528
shlq $0x2, %rdx
leaq 0xf4(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x20a0
movq (%r15), %rax
movq %r15, %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq *0x28(%rax)
testl %eax, %eax
je 0x258e
movss 0x10(%rsp), %xmm0
ucomiss 0x38(%rsp), %xmm0
jbe 0x258e
testq %rbp, %rbp
je 0x255e
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x18(%rax)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x256e
movq (%rdi), %rax
callq *0x18(%rax)
movss 0x38(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x40(%rsp), %rbp
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r15, 0x30(%rsp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x30(%rax)
movq %rax, %r15
testq %rax, %rax
jne 0x24c4
leaq 0xa29e(%rip), %r15      # 0xc848
movq %r15, 0x80(%rsp)
movslq 0x30(%r13), %r14
movl %r14d, 0x88(%rsp)
testq %r14, %r14
jle 0x2602
leaq 0x34(%r13), %rsi
leaq 0x8c(%rsp), %rdi
leaq (,%r14,4), %rdx
callq 0x20a0
movss 0x10(%rsp), %xmm1
xorl %eax, %eax
movss 0x8c(%rsp,%rax,4), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, 0x8c(%rsp,%rax,4)
incq %rax
cmpq %rax, %r14
jne 0x25e4
movslq 0x10(%r13), %r12
testq %r12, %r12
jle 0x2627
addq $0x14, %r13
leaq (,%r12,4), %rdx
leaq 0x154(%rsp), %rdi
movq %r13, %rsi
callq 0x20a0
movq %r15, 0x60(%rsp)
movl %r14d, 0x68(%rsp)
testl %r14d, %r14d
jle 0x2650
leaq 0x8c(%rsp), %rsi
leaq 0x6c(%rsp), %rdi
leaq (,%r14,4), %rdx
callq 0x20a0
movq %r15, 0xa0(%rsp)
movl %r12d, 0xa8(%rsp)
testl %r12d, %r12d
jle 0x2681
leaq 0xac(%rsp), %rdi
movq %r12, %rdx
shlq $0x2, %rdx
leaq 0x154(%rsp), %rsi
callq 0x20a0
cmpl %r12d, %r14d
jne 0x278f
testl %r14d, %r14d
movq 0x30(%rsp), %rdi
jle 0x26b3
xorl %eax, %eax
movss 0xac(%rsp,%rax,4), %xmm0
addss 0x6c(%rsp,%rax,4), %xmm0
movss %xmm0, 0x6c(%rsp,%rax,4)
incq %rax
cmpq %rax, %r14
jne 0x2696
movq (%rdi), %rax
callq *0x40(%rax)
movl 0x24(%rsp), %ecx
incl %ecx
movq (%rax), %r10
movl %ecx, (%rsp)
leaq 0x60(%rsp), %rcx
movq %rbx, %rdi
movq %rax, %rsi
movq 0x18(%rsp), %rdx
movq %rbp, %r8
movq 0x28(%rsp), %r9
callq *0x18(%r10)
testq %rbp, %rbp
je 0x26f0
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x18(%rax)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2700
movq (%rdi), %rax
callq *0x18(%rax)
movslq 0x8(%rbx), %rax
cmpq $0x4, %rax
jge 0x2770
movl $0x3f800000, 0xc(%rbx,%rax,4) # imm = 0x3F800000
jmp 0x2756
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rcx
leaq 0xa124(%rip), %rax      # 0xc848
movq %rax, (%rbx)
movslq 0x8(%rcx), %rax
movl %eax, 0x8(%rbx)
testq %rax, %rax
jle 0x2749
xorl %edx, %edx
movss 0xc(%rcx,%rdx,4), %xmm0
movss %xmm0, 0xc(%rbx,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x2735
cmpl $0x4, %eax
jge 0x2770
movl $0x0, 0xc(%rbx,%rax,4)
incl %eax
movl %eax, 0x8(%rbx)
movq %rbx, %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6a7c(%rip), %rdi      # 0x91f3
leaq 0x68f0(%rip), %rsi      # 0x906e
leaq 0x6a79(%rip), %rcx      # 0x91fe
movl $0xeb, %edx
callq 0x2080
leaq 0x6902(%rip), %rdi      # 0x9098
leaq 0x68d1(%rip), %rsi      # 0x906e
leaq 0x6925(%rip), %rcx      # 0x90c9
movl $0x66, %edx
callq 0x2080