// File: BartMassey[P]ancient-raytracer/render.cc
// Function: render(object*, char*, int, int)
static void render( object *scene, char *imgtype, int w, int h ) {
  light thelight( point( 2 * HE, -HE, 0 ), point( 1.25, 1.25, 1.15 ) );
  point eye( HE, 0, 0 );
  xform view_xform( XFORM_ROTATE_Y, -A );
  int i, j;

  output *out = 0;
  point dkgray( 0.2, 0.2, 0.2 );
  model m( eye, thelight, *scene, dkgray );

  // create the appropriate output object
  if( !strcmp( imgtype, "-oldppm" ) )
    out = new oldppm_output( (char *)"render.out", w, h );
  else if( !strcmp( imgtype, "-ppm" ) )
    out = new ppm_output( (char *)"render.out", w, h );
  else
    assert( 0 );
  // sweep over the whole viewplane
  for( j = h - 1; j >= 0; j-- ) {
    for( i = 0; i < w; i++ ) {
#ifdef ANTIALIAS
      int aa = ANTIALIAS;
      point ave( 0.0, 0.0, 0.0, 0.0 );
      double joggle = frandom();
      for( int k = 0; k < aa; k++ ) {
        point rt(
         2 * HS * (j + dojoggle( cos, k, aa, joggle )) / h - HS,
         2 * HS * (i + dojoggle( sin, k, aa, joggle )) / w - HS,
         D );
	rt.transform( view_xform );
        ray r( eye, rt );

	ave += trace( r, m, 0 ) * (1.0 / aa);
      }
#else
      point rt(
       2 * HS * j / h - HS,
       2 * HS * i / w - HS,
       D );
      rt.transform( view_xform );
      ray r( eye, rt );
      point ave( trace( r, m, 0 ) );
#endif
      out->putpixel( i, h - j - 1, ave );
    }
    out->flushrow( h - j - 1 );
  }
  out->flush();
  delete out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movsd 0x87af(%rip), %xmm0     # 0xb020
movsd %xmm0, -0x2a8(%rbp)
callq 0x2040
movaps %xmm0, %xmm1
movsd -0x2a8(%rbp), %xmm0
movsd 0x8797(%rip), %xmm2     # 0xb028
movsd %xmm2, -0x2a0(%rbp)
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm1
cvtsd2ss %xmm1, %xmm1
movss %xmm1, -0x294(%rbp)
callq 0x2040
movsd -0x2a0(%rbp), %xmm2
movaps %xmm0, %xmm1
movss -0x294(%rbp), %xmm0
mulsd %xmm2, %xmm1
movaps 0x8780(%rip), %xmm2     # 0xb050
pxor %xmm2, %xmm1
cvtsd2ss %xmm1, %xmm1
leaq -0x80(%rbp), %rdi
xorps %xmm2, %xmm2
callq 0x3fe0
leaq -0xa0(%rbp), %rdi
movss 0x8715(%rip), %xmm1     # 0xb008
movss 0x8711(%rip), %xmm2     # 0xb00c
movaps %xmm1, %xmm0
callq 0x3fe0
jmp 0x2905
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x4030
jmp 0x291b
leaq -0xa0(%rbp), %rdi
callq 0x2fd0
leaq -0x80(%rbp), %rdi
callq 0x2fd0
movsd 0x86e8(%rip), %xmm0     # 0xb020
callq 0x2040
movsd 0x86e3(%rip), %xmm1     # 0xb028
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0xd0(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq 0x3fe0
jmp 0x2961
leaq -0x168(%rbp), %rdi
movl $0x4, %esi
movss 0x869b(%rip), %xmm0     # 0xb010
callq 0x5f10
jmp 0x297c
movq $0x0, -0x178(%rbp)
leaq -0x198(%rbp), %rdi
movss 0x867e(%rip), %xmm2     # 0xb014
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x3fe0
jmp 0x29a3
movq -0x8(%rbp), %rcx
leaq -0x1c0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x198(%rbp), %r8
callq 0x40a0
jmp 0x29c7
movq -0x10(%rbp), %rdi
leaq 0x886e(%rip), %rsi      # 0xb240
callq 0x2160
cmpl $0x0, %eax
jne 0x2ae5
movl $0x28, %edi
callq 0x2110
movq %rax, -0x2b0(%rbp)
jmp 0x29f3
movq -0x2b0(%rbp), %rdi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x8841(%rip), %rsi      # 0xb248
callq 0x8780
jmp 0x2a0e
movq -0x2b0(%rbp), %rax
movq %rax, -0x178(%rbp)
jmp 0x2b81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2a53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x2fd0
leaq -0x80(%rbp), %rdi
callq 0x2fd0
jmp 0x2ee4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2edb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2ecf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2ec3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2eb7
movq -0x2b0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
movl $0x28, %esi
callq 0x2120
jmp 0x2eb7
movq -0x10(%rbp), %rdi
leaq 0x8570(%rip), %rsi      # 0xb060
callq 0x2160
cmpl $0x0, %eax
jne 0x2b60
movl $0x28, %edi
callq 0x2110
movq %rax, -0x2b8(%rbp)
jmp 0x2b0d
movq -0x2b8(%rbp), %rdi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x8727(%rip), %rsi      # 0xb248
callq 0x83b0
jmp 0x2b28
movq -0x2b8(%rbp), %rax
movq %rax, -0x178(%rbp)
jmp 0x2b7f
movq -0x2b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
movl $0x28, %esi
callq 0x2120
jmp 0x2eb7
leaq 0x877c(%rip), %rdi      # 0xb2e3
leaq 0x86e5(%rip), %rsi      # 0xb253
movl $0x51, %edx
leaq 0x86e3(%rip), %rcx      # 0xb25d
callq 0x20b0
jmp 0x2b81
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x170(%rbp)
cmpl $0x0, -0x170(%rbp)
jl 0x2e4e
movl $0x0, -0x16c(%rbp)
movl -0x16c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2e19
movsd 0x8465(%rip), %xmm0     # 0xb020
movsd %xmm0, -0x2d8(%rbp)
callq 0x20a0
movaps %xmm0, %xmm1
movsd -0x2d8(%rbp), %xmm0
movsd 0x844d(%rip), %xmm2     # 0xb028
movsd %xmm2, -0x2e0(%rbp)
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm1
cvtsi2sdl -0x170(%rbp), %xmm2
mulsd %xmm2, %xmm1
cvtsi2sdl -0x18(%rbp), %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, -0x2e8(%rbp)
callq 0x20a0
movsd -0x2e8(%rbp), %xmm2
movaps %xmm0, %xmm1
movsd -0x2d8(%rbp), %xmm0
movsd 0x8408(%rip), %xmm3     # 0xb030
movsd %xmm3, -0x2d0(%rbp)
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
cvtsd2ss %xmm1, %xmm1
movss %xmm1, -0x2bc(%rbp)
callq 0x20a0
movsd -0x2e0(%rbp), %xmm2
movaps %xmm0, %xmm1
movsd -0x2d8(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm1
cvtsi2sdl -0x16c(%rbp), %xmm2
mulsd %xmm2, %xmm1
cvtsi2sdl -0x14(%rbp), %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, -0x2c8(%rbp)
callq 0x20a0
movsd -0x2d0(%rbp), %xmm3
movsd -0x2c8(%rbp), %xmm2
movaps %xmm0, %xmm1
movss -0x2bc(%rbp), %xmm0
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
cvtsd2ss %xmm1, %xmm1
leaq -0x1e0(%rbp), %rdi
movss 0x835c(%rip), %xmm2     # 0xb018
callq 0x3fe0
jmp 0x2cc3
leaq -0x1e0(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x37c0
jmp 0x2cd8
leaq -0x228(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
callq 0x4120
jmp 0x2cf4
leaq -0x290(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x2fe0
jmp 0x2d09
leaq -0x248(%rbp), %rdi
leaq -0x290(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x2310
jmp 0x2d27
leaq -0x290(%rbp), %rdi
callq 0x3060
movq -0x178(%rbp), %rdi
movl -0x16c(%rbp), %esi
movl -0x18(%rbp), %eax
movl -0x170(%rbp), %edx
notl %edx
addl %eax, %edx
movq (%rdi), %rax
movq (%rax), %rax
leaq -0x248(%rbp), %rcx
callq *%rax
jmp 0x2d5e
leaq -0x248(%rbp), %rdi
callq 0x2fd0
leaq -0x228(%rbp), %rdi
callq 0x3060
leaq -0x1e0(%rbp), %rdi
callq 0x2fd0
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x2ba4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2e08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x3060
jmp 0x2dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x2fd0
leaq -0x228(%rbp), %rdi
callq 0x3060
leaq -0x1e0(%rbp), %rdi
callq 0x2fd0
jmp 0x2eb7
movq -0x178(%rbp), %rdi
movl -0x18(%rbp), %eax
movl -0x170(%rbp), %esi
notl %esi
addl %eax, %esi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0x2e38
jmp 0x2e3a
movl -0x170(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x170(%rbp)
jmp 0x2b8d
movq -0x178(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0x2e60
movq -0x178(%rbp), %rax
movq %rax, -0x2f0(%rbp)
cmpq $0x0, %rax
je 0x2e81
movq -0x2f0(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
leaq -0x198(%rbp), %rdi
callq 0x2fd0
leaq -0x168(%rbp), %rdi
callq 0x41c0
leaq -0xd0(%rbp), %rdi
callq 0x2fd0
leaq -0x60(%rbp), %rdi
callq 0x41d0
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
leaq -0x198(%rbp), %rdi
callq 0x2fd0
leaq -0x168(%rbp), %rdi
callq 0x41c0
leaq -0xd0(%rbp), %rdi
callq 0x2fd0
leaq -0x60(%rbp), %rdi
callq 0x41d0
movq -0xa8(%rbp), %rdi
callq 0x21c0