// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/camera.cpp
// Function: Camera::Camera(Vec3<float>, Image, int)
Camera::Camera(Vec3f position, Image i, int m) : eye(position), mode(m) {
    ViewPort = Matrix::identity(4);
    
    int x , y , h, w;
    x = i.get_width()  / 8;
    y = i.get_height() / 8;
    w = i.get_width()  * 3/4;
    h = i.get_height() * 3/4;

    ViewPort[0][3] = x+w/2.f;
    ViewPort[1][3] = y+h/2.f;
    ViewPort[2][3] = depth/2.f;
    
    ViewPort[0][0] = w/2.f;
    ViewPort[1][1] = h/2.f;
    ViewPort[2][2] = depth/2.f;

    Projection = Matrix::identity(4);
    Projection[3][2] = -1.f/position.z;

    center = Vec3f(0, 0, 0);
    up = Vec3f(0, 1, 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r14
movlps %xmm0, (%rdi)
movss %xmm1, 0x14(%rsp)
movss %xmm1, 0x8(%rdi)
leaq 0x28(%rdi), %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rdi)
movq $0x0, 0x1c(%rdi)
movq %rbx, %rdi
movl $0x4, %esi
movl $0x4, %edx
callq 0x25ec
leaq 0x48(%r14), %rdi
movq %rdi, 0x18(%rsp)
movl $0x4, %esi
movl $0x4, %edx
callq 0x25ec
movl %ebp, 0x68(%r14)
leaq 0x20(%rsp), %rdi
movl $0x4, %esi
callq 0x267c
movq 0x38(%r14), %rax
leaq 0x20(%rsp), %r13
movaps (%r13), %xmm0
movq 0x10(%r13), %rcx
movq %rcx, 0x38(%r14)
movups 0x28(%r14), %xmm1
movups %xmm0, 0x28(%r14)
leaq 0x40(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r13)
movq $0x0, 0x10(%r13)
callq 0x2f62
movq 0x18(%r13), %rax
movq %rax, 0x40(%r14)
movq %r13, %rdi
callq 0x2f62
movq %r12, %rdi
callq 0x3e92
leal 0x7(%rax), %r15d
testl %eax, %eax
cmovnsl %eax, %r15d
movq %r12, %rdi
callq 0x3e96
leal 0x7(%rax), %ebp
testl %eax, %eax
cmovnsl %eax, %ebp
movq %r12, %rdi
callq 0x3e92
movl %eax, %r13d
movq %r12, %rdi
callq 0x3e96
movl %eax, %r12d
leal (%r13,%r13,2), %eax
leal 0x3(%r13,%r13,2), %r13d
testl %eax, %eax
cmovnsl %eax, %r13d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x26fe
sarl $0x2, %r13d
xorps %xmm1, %xmm1
cvtsi2ss %r13d, %xmm1
mulss 0x3ed1(%rip), %xmm1     # 0x7124
sarl $0x3, %r15d
xorps %xmm0, %xmm0
cvtsi2ss %r15d, %xmm0
movss %xmm1, 0x10(%rsp)
addss %xmm1, %xmm0
leal (%r12,%r12,2), %ecx
leal (%r12,%r12,2), %r15d
addl $0x3, %r15d
testl %ecx, %ecx
cmovnsl %ecx, %r15d
movq (%rax), %rax
movss %xmm0, 0xc(%rax)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x26fe
sarl $0x2, %r15d
xorps %xmm1, %xmm1
cvtsi2ss %r15d, %xmm1
mulss 0x3e80(%rip), %xmm1     # 0x7124
sarl $0x3, %ebp
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movss %xmm1, 0xc(%rsp)
addss %xmm1, %xmm0
movq (%rax), %rax
movss %xmm0, 0xc(%rax)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x26fe
movq (%rax), %rax
movl $0x42ff0000, 0xc(%rax)  # imm = 0x42FF0000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x26fe
movq (%rax), %rax
movss 0x10(%rsp), %xmm0
movss %xmm0, (%rax)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x26fe
movq (%rax), %rax
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x4(%rax)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x26fe
movq (%rax), %rax
movl $0x42ff0000, 0x8(%rax)  # imm = 0x42FF0000
leaq 0x20(%rsp), %rdi
movl $0x4, %esi
callq 0x267c
movq 0x58(%r14), %rax
leaq 0x20(%rsp), %r12
movaps (%r12), %xmm0
movq 0x10(%r12), %rcx
movq %rcx, 0x58(%r14)
movups 0x48(%r14), %xmm1
movups %xmm0, 0x48(%r14)
leaq 0x40(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movq $0x0, 0x10(%r12)
callq 0x2f62
movq 0x18(%r12), %rax
movq %rax, 0x60(%r14)
movq %r12, %rdi
callq 0x2f62
movq 0x18(%rsp), %rdi
movl $0x3, %esi
callq 0x26fe
leaq 0xc(%r14), %rcx
movss 0x3d8a(%rip), %xmm0     # 0x7128
divss 0x14(%rsp), %xmm0
movq (%rax), %rax
movss %xmm0, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movss 0x3c86(%rip), %xmm0     # 0x7040
movlps %xmm0, 0x1c(%r14)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x33d7
jmp 0x33d7
movq %rax, %r14
jmp 0x33e4
movq %rax, %r14
movq 0x18(%rsp), %rdi
callq 0x2f62
movq %rbx, %rdi
callq 0x2f62
movq %r14, %rdi
callq 0x22d0