// File: /workspace/github_c_makefile_star2_O1/AlexCharlton[P]Hyperscene/src/camera.c
// Function: hpsUpdateCamera
void hpsUpdateCamera(HPScamera *camera){
    HPScamera *c = camera;
    float cameraMat[16];
    switch (camera->style){
    case HPS_ORBIT:
    {
        float cosPitch = cos(c->rotation.y);
        float sinPitch = sin(c->rotation.y);
        float sinYaw = sin(c->rotation.x);
        float cosYaw = cos(c->rotation.x);
        c->position.x = c->object.x + c->rotation.w * cosPitch * sinYaw;
        c->position.y = c->object.y + c->rotation.w * sinPitch;
        c->position.z = c->object.z + c->rotation.w * cosPitch * cosYaw;
        hpmYPRRotation(c->rotation.x, -c->rotation.y, c->rotation.z, cameraMat);
        hpmTranslate((float *) &c->position, cameraMat);
        hpmCameraInverse(cameraMat, c->view);
        break;
    }
    case HPS_LOOK_AT:
        hpmLookAt((float *) &c->position, (float *) &c->object, (float *) &c->up, 
                  c->view);
        break;
    case HPS_POSITION:
        hpmQuaternionRotation((float *) &c->rotation, cameraMat);
        hpmTranslate((float *) &c->position, cameraMat);
        hpmCameraInverse(cameraMat, c->view);
        break;
    case HPS_FIRST_PERSON:
        hpmYPRRotation(-c->rotation.x, c->rotation.y, c->rotation.z, cameraMat);
        hpmTranslate((float *) &c->position, cameraMat);
        hpmCameraInverse(cameraMat, c->view);
        break;
    default:
        fprintf(stderr, "Camera does not have a valid style\n");
        exit(EXIT_FAILURE);
    }
    hpmMultMat4(c->projection, c->view, c->viewProjection);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
movl 0x8(%rdi), %eax
cmpq $0x3, %rax
ja 0x8fc6
movq %rdi, %rbx
leaq 0x22e2(%rip), %rcx      # 0xb140
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x68(%rbx), %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x4050
jmp 0x8f73
cvtss2sd 0x6c(%rbx), %xmm0
callq 0x4310
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x6c(%rbx), %xmm0
callq 0x4210
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x68(%rbx), %xmm0
callq 0x4210
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x68(%rbx), %xmm0
callq 0x4310
cvtsd2ss %xmm0, %xmm0
movss 0x74(%rbx), %xmm1
movss 0x8(%rsp), %xmm2
mulss %xmm1, %xmm2
movss 0x4(%rsp), %xmm3
mulss %xmm2, %xmm3
addss 0x24(%rbx), %xmm3
leaq 0xc(%rbx), %r14
movss %xmm3, 0xc(%rbx)
movss 0xc(%rsp), %xmm3
mulss %xmm1, %xmm3
addss 0x28(%rbx), %xmm3
movss %xmm3, 0x10(%rbx)
mulss %xmm0, %xmm2
addss 0x2c(%rbx), %xmm2
movss %xmm2, 0x14(%rbx)
movss 0x68(%rbx), %xmm0
movss 0x6c(%rbx), %xmm1
xorps 0x2126(%rip), %xmm1     # 0xb050
movss 0x70(%rbx), %xmm2
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x4140
movq %r14, %rdi
movq %r15, %rsi
callq 0x4060
leaq 0x78(%rbx), %rsi
movq %r15, %rdi
jmp 0x8f86
movss 0x68(%rbx), %xmm0
xorps 0x20f4(%rip), %xmm0     # 0xb050
movss 0x6c(%rbx), %xmm1
movss 0x70(%rbx), %xmm2
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x4140
leaq 0xc(%rbx), %rdi
movq %r14, %rsi
callq 0x4060
leaq 0x78(%rbx), %rsi
movq %r14, %rdi
callq 0x4190
jmp 0x8fa2
leaq 0xc(%rbx), %rdi
leaq 0x24(%rbx), %rsi
leaq 0x18(%rbx), %rdx
leaq 0x78(%rbx), %rcx
callq 0x4180
leaq 0xb8(%rbx), %rdi
leaq 0x78(%rbx), %rsi
addq $0xf8, %rbx
movq %rbx, %rdx
callq 0x4110
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x444f