// File: /workspace/github_cpp_makefile_star2_O3/srajangarg[P]raytracer/src/main.cpp
// Function: main
int
main(int argc, char ** argv)
{
  if (argc < 3)
  {
    std::cout << "Usage: " << argv[0] << " scene.scd output.png [max_trace_depth]" << std::endl;
    return -1;
  }

  if (argc >= 4)
    max_trace_depth = atoi(argv[3]);
  if (argc >= 5)
    smooth_normals = (atoi(argv[4]) == 1);

  cout << "Max trace depth = " << max_trace_depth << endl;
  if (smooth_normals)
    cout << "Using smooth normals for triangle meshes" << endl;

  // Load the scene from the disk file
  scene = new Scene(argv[1]);

  // Setup the world object, containing the data from the scene
  world = new World();
  importSceneToWorld(scene->getRoot(), identity3D(), 0);
  world->printStats();

  // Set up the output framebuffer
  frame = new Frame(IMAGE_WIDTH, IMAGE_HEIGHT);

  // Render the world
  renderWithRaytracing();

  // Save the output to an image file
  frame->save(argv[2]);
  std::cout << "Image saved!" << std::endl;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
cmpl $0x2, %edi
jg 0x2a345
movq 0xccca(%rip), %rbx      # 0x36fd0
leaq 0x32c6(%rip), %rsi      # 0x2d5d3
movl $0x7, %edx
movq %rbx, %rdi
callq 0x4360
movq (%r14), %r14
testq %r14, %r14
je 0x2a574
movq %r14, %rdi
callq 0x4170
movq 0xcc9b(%rip), %rdi      # 0x36fd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x4360
jmp 0x2a58b
movl %edi, %ebx
cmpl $0x3, %edi
je 0x2a373
movq 0x18(%r14), %rdi
callq 0x44c0
movl %eax, 0xd015(%rip)      # 0x37370
cmpl $0x5, %ebx
jb 0x2a373
movq 0x20(%r14), %rdi
callq 0x44c0
cmpl $0x1, %eax
sete 0xd235(%rip)            # 0x375a8
movq 0xcc56(%rip), %rbx      # 0x36fd0
leaq 0x3282(%rip), %rsi      # 0x2d603
movl $0x12, %edx
movq %rbx, %rdi
callq 0x4360
movl 0xcfdc(%rip), %esi      # 0x37370
movq %rbx, %rdi
callq 0x4570
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
cmpb $0x1, 0xd1db(%rip)      # 0x375a8
jne 0x2a40a
leaq 0x3240(%rip), %rsi      # 0x2d616
movl $0x28, %edx
movq %rbx, %rdi
callq 0x4360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
movl $0x10, %edi
callq 0x4300
movq %rax, %r15
movq 0x8(%r14), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xb292
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x5b08
movq %r15, 0xd0ca(%rip)      # 0x37508
leaq 0x18(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x2a45a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4310
movl $0x70, %edi
callq 0x4300
movq %rax, %r15
movq %rax, %rdi
callq 0x28120
movq %r15, 0xd09a(%rip)      # 0x37510
movq 0xd08b(%rip), %rax      # 0x37508
movq (%rax), %rdi
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
leaq 0x28(%rsp), %rsi
movq %rax, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movups %xmm0, 0x18(%rsi)
movq %rax, 0x28(%rsi)
movups %xmm0, 0x30(%rsi)
movups %xmm0, 0x40(%rsi)
movq %rax, 0x50(%rsi)
movups %xmm0, 0x58(%rsi)
movups %xmm0, 0x68(%rsi)
movq %rax, 0x78(%rsi)
xorl %edx, %edx
callq 0x294f3
movq 0xd049(%rip), %rdi      # 0x37510
callq 0x2829a
movl $0x20, %edi
callq 0x4300
movq %rax, %r15
movq %rax, %rdi
movl $0x200, %esi            # imm = 0x200
movl $0x200, %edx            # imm = 0x200
callq 0x25d80
movq %r15, 0xd0ae(%rip)      # 0x375a0
callq 0x29165
movq 0xd0a2(%rip), %r15      # 0x375a0
movq 0x10(%r14), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xb292
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x25ec6
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2a535
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4310
leaq 0x3103(%rip), %rsi      # 0x2d63f
movl $0xc, %edx
movq %rbx, %rdi
callq 0x4360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
xorl %eax, %eax
jmp 0x2a5cb
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4550
leaq 0x3049(%rip), %rsi      # 0x2d5db
movl $0x27, %edx
movq %rbx, %rdi
callq 0x4360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2a63a
movq 0x18(%rsp), %rsi
incq %rsi
jmp 0x2a635
movq %rax, %rbx
jmp 0x2a63a
movq %rax, %rbx
movl $0x20, %esi
jmp 0x2a632
movq %rax, %rbx
movl $0x70, %esi
jmp 0x2a632
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a62d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4310
jmp 0x2a62d
movq %rax, %rbx
movl $0x10, %esi
movq %r15, %rdi
callq 0x4310
movq %rbx, %rdi
callq 0x45b0