// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x68(%rbp)
subq $0x3, %rax
ja 0xb9b7
movq -0x68(%rbp), %rax
leaq 0x3944(%rip), %rcx      # 0xf0f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movss 0x6c(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x4400
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
movq -0x10(%rbp), %rax
movss 0x6c(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x4290
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movss 0x68(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x4290
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movss 0x68(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x4400
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movq -0x10(%rbp), %rax
movss 0x24(%rax), %xmm1
movq -0x10(%rbp), %rax
movss 0x74(%rax), %xmm0
mulss -0x54(%rbp), %xmm0
movss -0x5c(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xc(%rax)
movq -0x10(%rbp), %rax
movss 0x28(%rax), %xmm1
movq -0x10(%rbp), %rax
movss 0x74(%rax), %xmm0
movss -0x58(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x10(%rax)
movq -0x10(%rbp), %rax
movss 0x2c(%rax), %xmm1
movq -0x10(%rbp), %rax
movss 0x74(%rax), %xmm0
mulss -0x54(%rbp), %xmm0
movss -0x60(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x14(%rax)
movq -0x10(%rbp), %rax
movss 0x68(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x6c(%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
movq -0x10(%rbp), %rax
movss 0x70(%rax), %xmm2
leaq -0x50(%rbp), %rdi
callq 0x4170
movq -0x10(%rbp), %rdi
addq $0xc, %rdi
leaq -0x50(%rbp), %rsi
callq 0x4070
leaq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x78, %rsi
callq 0x41f0
jmp 0xb9d9
movq -0x10(%rbp), %rdi
addq $0xc, %rdi
movq -0x10(%rbp), %rsi
addq $0x24, %rsi
movq -0x10(%rbp), %rdx
addq $0x18, %rdx
movq -0x10(%rbp), %rcx
addq $0x78, %rcx
callq 0x41e0
jmp 0xb9d9
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
leaq -0x50(%rbp), %rsi
callq 0x4060
movq -0x10(%rbp), %rdi
addq $0xc, %rdi
leaq -0x50(%rbp), %rsi
callq 0x4070
leaq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x78, %rsi
callq 0x41f0
jmp 0xb9d9
movq -0x10(%rbp), %rax
movss 0x68(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq -0x10(%rbp), %rax
movss 0x6c(%rax), %xmm1
movq -0x10(%rbp), %rax
movss 0x70(%rax), %xmm2
leaq -0x50(%rbp), %rdi
callq 0x4170
movq -0x10(%rbp), %rdi
addq $0xc, %rdi
leaq -0x50(%rbp), %rsi
callq 0x4070
leaq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x78, %rsi
callq 0x41f0
jmp 0xb9d9
movq 0x763a(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x3768(%rip), %rsi      # 0xf130
movb $0x0, %al
callq 0x4280
movl $0x1, %edi
callq 0x4520
movq -0x10(%rbp), %rdi
addq $0xb8, %rdi
movq -0x10(%rbp), %rsi
addq $0x78, %rsi
movq -0x10(%rbp), %rdx
addq $0xf8, %rdx
callq 0x4140
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)