// File: /workspace/github_c_makefile_star2_O3/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 $0x70, %rsp
movl 0x8(%rdi), %eax
cmpq $0x3, %rax
ja 0x8845
movq %rdi, %rbx
leaq 0x2ab2(%rip), %rcx      # 0xb1a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x68(%rbx), %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0x4050
jmp 0x87f2
cvtss2sd 0x6c(%rbx), %xmm0
callq 0x4310
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x6c(%rbx), %xmm0
callq 0x4210
movaps %xmm0, 0x10(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x68(%rbx), %xmm0
callq 0x4210
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x68(%rbx), %xmm0
callq 0x4310
cvtsd2ss %xmm0, %xmm0
movss 0x74(%rbx), %xmm1
movaps 0x20(%rsp), %xmm5
mulss %xmm1, %xmm5
movapd (%rsp), %xmm2
unpcklpd 0x10(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
cvtpd2ps %xmm2, %xmm2
leaq 0xc(%rbx), %r14
movsd 0x24(%rbx), %xmm3
movaps %xmm5, %xmm4
unpcklps %xmm1, %xmm4            # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
mulps %xmm2, %xmm4
addps %xmm3, %xmm4
movlps %xmm4, 0xc(%rbx)
mulss %xmm0, %xmm5
addss 0x2c(%rbx), %xmm5
movss %xmm5, 0x14(%rbx)
movss 0x68(%rbx), %xmm0
movss 0x6c(%rbx), %xmm1
xorps 0x28a7(%rip), %xmm1     # 0xb050
movss 0x70(%rbx), %xmm2
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x4140
movq %r14, %rdi
movq %r15, %rsi
callq 0x4060
leaq 0x78(%rbx), %rsi
movq %r15, %rdi
jmp 0x8805
movss 0x68(%rbx), %xmm0
xorps 0x2875(%rip), %xmm0     # 0xb050
movss 0x6c(%rbx), %xmm1
movss 0x70(%rbx), %xmm2
leaq 0x30(%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 0x8821
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 $0x70, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x444f