// File: /workspace/github_cpp_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
cmpl $0x2, %edi
jg 0x2ac9e
movq 0xd371(%rip), %r14      # 0x37fd0
leaq 0x383d(%rip), %rsi      # 0x2e4a3
movl $0x7, %edx
movq %r14, %rdi
callq 0x4370
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x2aea9
movq %rbx, %rdi
callq 0x4170
movq 0xd342(%rip), %rdi      # 0x37fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4370
jmp 0x2aec1
movl %edi, %ebp
cmpl $0x3, %edi
je 0x2acb4
movq 0x18(%rbx), %rdi
callq 0x44d0
movl %eax, 0xd6dc(%rip)      # 0x38390
cmpl $0x5, %ebp
jl 0x2accc
movq 0x20(%rbx), %rdi
callq 0x44d0
cmpl $0x1, %eax
sete 0xd8f4(%rip)            # 0x385c0
movq 0xd2fd(%rip), %r14      # 0x37fd0
leaq 0x37f9(%rip), %rsi      # 0x2e4d3
movl $0x12, %edx
movq %r14, %rdi
callq 0x4370
movl 0xd6a3(%rip), %esi      # 0x38390
movq %r14, %rdi
callq 0x4580
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4230
cmpb $0x1, 0xd89a(%rip)      # 0x385c0
jne 0x2ad63
leaq 0x37b7(%rip), %rsi      # 0x2e4e6
movl $0x28, %edx
movq %r14, %rdi
callq 0x4370
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4230
movl $0x10, %edi
callq 0x4310
movq %rax, %r14
movq 0x8(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xb614
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x5b20
movq %r14, 0xd789(%rip)      # 0x38520
leaq 0x18(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x2adb2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4320
movl $0x70, %edi
callq 0x4310
movq %rax, %r14
movq %rax, %rdi
callq 0x28240
movq %r14, 0xd75a(%rip)      # 0x38528
movq 0xd74b(%rip), %rax      # 0x38520
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 0x2997d
movq 0xd709(%rip), %rdi      # 0x38528
callq 0x283ba
movl $0x20, %edi
callq 0x4310
movq %rax, %r14
movq %rax, %rdi
movl $0x200, %esi            # imm = 0x200
movl $0x200, %edx            # imm = 0x200
callq 0x25824
movq %r14, 0xd76e(%rip)      # 0x385b8
callq 0x29544
movq 0xd762(%rip), %r14      # 0x385b8
movq 0x10(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xb614
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x2597e
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2ae8d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4320
movq 0xd13c(%rip), %rdi      # 0x37fd0
leaq 0x3674(%rip), %rsi      # 0x2e50f
movl $0xc, %edx
callq 0x4370
xorl %ebx, %ebx
jmp 0x2aede
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x4560
movq 0xd108(%rip), %rdi      # 0x37fd0
leaq 0x35dc(%rip), %rsi      # 0x2e4ab
movl $0x27, %edx
callq 0x4370
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0xd0eb(%rip), %r14      # 0x37fd0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4230
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2af7c
movq 0x18(%rsp), %rsi
incq %rsi
jmp 0x2af77
movq %rax, %rbx
jmp 0x2af7c
movq %rax, %rbx
movl $0x20, %esi
jmp 0x2af74
movq %rax, %rbx
movl $0x70, %esi
jmp 0x2af74
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2af6f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4320
jmp 0x2af6f
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
callq 0x4320
movq %rbx, %rdi
callq 0x45c0