// File: /workspace/github_c_makefile_star2_O3/Nealsbo[P]C-Software-Renderer/src/application.c
// Function: Application_Run
void Application_Run() {
	printf( "Application Run: Start\n");
    SDL_Event e;

    SetupScene( Scene );
    mainRenderer = Renderer_Init( Scene, RENDER_STATE_LIT, RENDER_TYPE_SOFTWARE );
    
    float frames_slice = 0.0f;
    float delta = 0.0f;
    
    unsigned int frames_slice_count = 0;
    clock_t curr_time, last_time;
    last_time = clock();
    
	printf( "Application Run: Loop\n");
    while ( !quit ) {
        curr_time = clock();
        delta = (float)( curr_time - last_time )/CLOCKS_PER_SEC;
        frames_slice += delta;
        elapsed_time += delta;
        frames_slice_count++;
        
        IH_ProcessInput( e, mainRenderer );
        UpdateScene( mainRenderer, delta );
        Renderer_DrawWorld( mainRenderer, gScreenSurface );
        SDL_UpdateWindowSurface( gWindow );
        
        printf("%f\n", elapsed_time);
        if(frames_slice > 1.0f){
            printf("FPS: %u\n", (unsigned int)(1.0f / frames_slice * (float)frames_slice_count));
            frames_slice = 0.0f;
            frames_slice_count = 0;
        }

        if( quit ) {
            break;
        }
        last_time = curr_time;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
leaq 0x5cd1(%rip), %rdi      # 0x70fd
callq 0x11f0
leaq 0x5d04(%rip), %rdi      # 0x713c
callq 0x11f0
movq 0x9d14(%rip), %rdi      # 0xb158
callq 0x5020
movq %rax, %rbx
xorps %xmm0, %xmm0
movss %xmm0, 0x38(%rsp)
movss 0x5ba7(%rip), %xmm2     # 0x7004
xorps %xmm1, %xmm1
callq 0x2a24
movq %rbx, %rdi
callq 0x5560
movss 0x5b93(%rip), %xmm0     # 0x7008
callq 0x44a3
movaps %xmm0, %xmm1
addss 0x5b87(%rip), %xmm1     # 0x700c
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x2a24
movq %rbx, %rdi
callq 0x5570
movss 0x5b70(%rip), %xmm2     # 0x7010
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2a24
movaps %xmm0, 0x40(%rsp)
movss %xmm1, 0x3c(%rsp)
movss 0x5b56(%rip), %xmm1     # 0x7014
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x2a24
movaps %xmm0, %xmm2
movaps %xmm1, %xmm3
movl $0x40a00000, 0x10(%rsp) # imm = 0x40A00000
movl $0x42c80000, 0x8(%rsp)  # imm = 0x42C80000
movl $0x3f000000, (%rsp)     # imm = 0x3F000000
movss 0x5b2a(%rip), %xmm4     # 0x7018
movss 0x5b26(%rip), %xmm6     # 0x701c
movss 0x5b22(%rip), %xmm7     # 0x7020
xorps %xmm5, %xmm5
movaps 0x40(%rsp), %xmm0
movss 0x3c(%rsp), %xmm1
callq 0x18dc
movq %rax, %rdi
callq 0x6558
movq %rax, %r14
movq %rax, 0x9c65(%rip)      # 0xb188
movss 0x5af9(%rip), %xmm1     # 0x7024
movss 0x5af5(%rip), %xmm2     # 0x7028
xorps %xmm0, %xmm0
callq 0x2a24
movaps %xmm0, 0x40(%rsp)
movss %xmm1, 0x3c(%rsp)
movss 0x5ade(%rip), %xmm1     # 0x702c
xorps %xmm2, %xmm2
movss 0x5abb(%rip), %xmm0     # 0x7014
callq 0x2a24
movaps %xmm0, %xmm2
movaps %xmm1, %xmm3
movq %r14, %rdi
movaps 0x40(%rsp), %xmm0
movss 0x3c(%rsp), %xmm1
callq 0x6625
movq 0x9c0a(%rip), %r14      # 0xb188
xorps %xmm0, %xmm0
movss 0x5aa3(%rip), %xmm1     # 0x702c
movss 0x5a83(%rip), %xmm2     # 0x7014
callq 0x2a24
movq %r14, %rdi
callq 0x6638
movq 0x9be3(%rip), %rdi      # 0xb188
movq %rbx, %rsi
callq 0x6611
movq 0x9bd4(%rip), %rdi      # 0xb188
xorl %ebp, %ebp
movl $0x1, %esi
xorl %edx, %edx
callq 0x5ed0
movq %rax, 0x9bc7(%rip)      # 0xb190
callq 0x10d0
movq %rax, %r12
leaq 0x5b3c(%rip), %rdi      # 0x7114
callq 0x11f0
cmpl $0x0, 0x9b84(%rip)      # 0xb168
sete %al
leaq 0x5ba8(%rip), %rbx      # 0x7196
leaq 0x5ac6(%rip), %r14      # 0x70bb
testb $0x1, %al
je 0x1711
callq 0x10d0
movq %rax, %r15
subq %r12, %rax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
divss 0x5a18(%rip), %xmm1     # 0x7030
movss %xmm1, 0x40(%rsp)
movss 0x38(%rsp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x38(%rsp)
movss 0x9b36(%rip), %xmm0     # 0xb16c
addss %xmm1, %xmm0
movss %xmm0, 0x9b2a(%rip)     # 0xb16c
incl %ebp
movq 0x9b45(%rip), %rdi      # 0xb190
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x58(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups 0x78(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x1721
movq 0x9b0f(%rip), %rdi      # 0xb190
movss 0x40(%rsp), %xmm0
callq 0x17c4
movq 0x9afd(%rip), %rdi      # 0xb190
movq 0x9ae6(%rip), %rsi      # 0xb180
callq 0x649b
movq 0x9ad2(%rip), %rdi      # 0xb178
callq 0x1170
xorps %xmm0, %xmm0
cvtss2sd 0x9ab6(%rip), %xmm0     # 0xb16c
movq %rbx, %rdi
movb $0x1, %al
callq 0x1040
movss 0x38(%rsp), %xmm2
movss 0x5946(%rip), %xmm0     # 0x7014
ucomiss %xmm0, %xmm2
jbe 0x16ff
movl %ebp, %eax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
divss %xmm2, %xmm0
mulss %xmm0, %xmm1
cvttss2si %xmm1, %rsi
xorl %ebp, %ebp
movq %r14, %rdi
xorl %eax, %eax
callq 0x1040
xorps %xmm0, %xmm0
movss %xmm0, 0x38(%rsp)
movb $0x1, %al
cmpl $0x0, 0x9a60(%rip)      # 0xb168
movq %r15, %r12
je 0x15f5
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq