// File: /workspace/github_c_makefile_star2_O1/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 0x6cd1(%rip), %rdi      # 0x80fd
callq 0x11f0
leaq 0x6d04(%rip), %rdi      # 0x813c
callq 0x11f0
movq 0xad14(%rip), %rdi      # 0xc158
callq 0x5359
movq %rax, %rbx
xorps %xmm0, %xmm0
movss %xmm0, 0x38(%rsp)
movss 0x6ba7(%rip), %xmm2     # 0x8004
xorps %xmm1, %xmm1
callq 0x2a5a
movq %rbx, %rdi
callq 0x5897
movss 0x6b93(%rip), %xmm0     # 0x8008
callq 0x479d
movaps %xmm0, %xmm1
addss 0x6b87(%rip), %xmm1     # 0x800c
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x2a5a
movq %rbx, %rdi
callq 0x58a7
movss 0x6b70(%rip), %xmm2     # 0x8010
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2a5a
movaps %xmm0, 0x40(%rsp)
movss %xmm1, 0x3c(%rsp)
movss 0x6b56(%rip), %xmm1     # 0x8014
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x2a5a
movaps %xmm0, %xmm2
movaps %xmm1, %xmm3
movl $0x40a00000, 0x10(%rsp) # imm = 0x40A00000
movl $0x42c80000, 0x8(%rsp)  # imm = 0x42C80000
movl $0x3f000000, (%rsp)     # imm = 0x3F000000
movss 0x6b2a(%rip), %xmm4     # 0x8018
movss 0x6b26(%rip), %xmm6     # 0x801c
movss 0x6b22(%rip), %xmm7     # 0x8020
xorps %xmm5, %xmm5
movaps 0x40(%rsp), %xmm0
movss 0x3c(%rsp), %xmm1
callq 0x18d4
movq %rax, %rdi
callq 0x68a4
movq %rax, %r14
movq %rax, 0xac65(%rip)      # 0xc188
movss 0x6af9(%rip), %xmm1     # 0x8024
movss 0x6af5(%rip), %xmm2     # 0x8028
xorps %xmm0, %xmm0
callq 0x2a5a
movaps %xmm0, 0x40(%rsp)
movss %xmm1, 0x3c(%rsp)
movss 0x6ade(%rip), %xmm1     # 0x802c
xorps %xmm2, %xmm2
movss 0x6abb(%rip), %xmm0     # 0x8014
callq 0x2a5a
movaps %xmm0, %xmm2
movaps %xmm1, %xmm3
movq %r14, %rdi
movaps 0x40(%rsp), %xmm0
movss 0x3c(%rsp), %xmm1
callq 0x6973
movq 0xac0a(%rip), %r14      # 0xc188
xorps %xmm0, %xmm0
movss 0x6aa3(%rip), %xmm1     # 0x802c
movss 0x6a83(%rip), %xmm2     # 0x8014
callq 0x2a5a
movq %r14, %rdi
callq 0x6986
movq 0xabe3(%rip), %rdi      # 0xc188
movq %rbx, %rsi
callq 0x695f
movq 0xabd4(%rip), %rdi      # 0xc188
xorl %ebp, %ebp
movl $0x1, %esi
xorl %edx, %edx
callq 0x6228
movq %rax, 0xabc7(%rip)      # 0xc190
callq 0x10d0
movq %rax, %r12
leaq 0x6b3c(%rip), %rdi      # 0x8114
callq 0x11f0
leaq 0x6bb2(%rip), %rbx      # 0x8196
leaq 0x6ad0(%rip), %r14      # 0x80bb
cmpl $0x0, 0xab76(%rip)      # 0xc168
jne 0x170a
callq 0x10d0
movq %rax, %r15
subq %r12, %rax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
divss 0x6a1d(%rip), %xmm1     # 0x8030
movss %xmm1, 0x40(%rsp)
movss 0x38(%rsp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x38(%rsp)
movss 0xab3b(%rip), %xmm0     # 0xc16c
addss %xmm1, %xmm0
movss %xmm0, 0xab2f(%rip)     # 0xc16c
incl %ebp
movq 0xab4a(%rip), %rdi      # 0xc190
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 0x171a
movq 0xab14(%rip), %rdi      # 0xc190
movss 0x40(%rsp), %xmm0
callq 0x17bd
movq 0xab02(%rip), %rdi      # 0xc190
movq 0xaaeb(%rip), %rsi      # 0xc180
callq 0x67ee
movq 0xaad7(%rip), %rdi      # 0xc178
callq 0x1170
xorps %xmm0, %xmm0
cvtss2sd 0xaabb(%rip), %xmm0     # 0xc16c
movq %rbx, %rdi
movb $0x1, %al
callq 0x1040
movss 0x38(%rsp), %xmm2
movss 0x694b(%rip), %xmm0     # 0x8014
ucomiss %xmm0, %xmm2
jbe 0x16fa
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)
cmpl $0x0, 0xaa67(%rip)      # 0xc168
movq %r15, %r12
je 0x15eb
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq