// File: /workspace/github_cpp_makefile_star2_O1/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
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x28(%r14), %rax
movups 0x30(%r14), %xmm0
leaq 0x20(%rsp), %r13
movq (%r13), %rcx
movq %rcx, 0x28(%r14)
movq 0x8(%r13), %rcx
movq %rcx, 0x30(%r14)
movq 0x10(%r13), %rcx
movq %rcx, 0x38(%r14)
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
movq %rax, (%rdi)
movups %xmm0, 0x8(%rdi)
movq %rcx, (%r13)
movq %rdx, 0x8(%r13)
movq %rsi, 0x10(%r13)
callq 0x2e46
movq 0x18(%r13), %rax
movq %rax, 0x40(%r14)
movq %r13, %rdi
callq 0x2e46
movq %r12, %rdi
callq 0x3ea6
leal 0x7(%rax), %r15d
testl %eax, %eax
cmovnsl %eax, %r15d
movq %r12, %rdi
callq 0x3eaa
leal 0x7(%rax), %ebp
testl %eax, %eax
cmovnsl %eax, %ebp
movq %r12, %rdi
callq 0x3ea6
movl %eax, %r13d
movq %r12, %rdi
callq 0x3eaa
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
cvtsi2ss %r13d, %xmm1
mulss 0x3f9d(%rip), %xmm1     # 0x70e8
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 0x3f4c(%rip), %xmm1     # 0x70e8
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
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x48(%r14), %rax
movups 0x50(%r14), %xmm0
leaq 0x20(%rsp), %r12
movq (%r12), %rcx
movq %rcx, 0x48(%r14)
movq 0x8(%r12), %rcx
movq %rcx, 0x50(%r14)
movq 0x10(%r12), %rcx
movq %rcx, 0x58(%r14)
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
movq %rax, (%rdi)
movups %xmm0, 0x8(%rdi)
movq %rcx, (%r12)
movq %rdx, 0x8(%r12)
movq %rsi, 0x10(%r12)
callq 0x2e46
movq 0x18(%r12), %rax
movq %rax, 0x60(%r14)
movq %r12, %rdi
callq 0x2e46
movq 0x18(%rsp), %rdi
movl $0x3, %esi
callq 0x26fe
leaq 0xc(%r14), %rcx
movss 0x3e39(%rip), %xmm0     # 0x70ec
divss 0x14(%rsp), %xmm0
movq (%rax), %rax
movss %xmm0, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x3f800000, 0x1c(%r14) # imm = 0x3F800000
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x32e7
jmp 0x32e7
movq %rax, %r14
jmp 0x32f4
movq %rax, %r14
movq 0x18(%rsp), %rdi
callq 0x2e46
movq %rbx, %rdi
callq 0x2e46
movq %r14, %rdi
callq 0x22d0