// File: /workspace/github_cpp_makefile_star2_O3/KellerMartins[P]PDS2-Pacman/source/graphics/ui.cpp
// Function: UI::Render()
void Render(){
        float screenWidth = (float)RenderManager::GetWidth();
        float screenHeight = (float)RenderManager::GetHeight();

        if(!_loadedFont){
            _font = GetFontDefault();
        }

        for(UIElement& e : _elements){
            if(e.type == ElementType::UIImage){
                
                Texture2D& imageTex = GetImage(e.string);

                float aspectRatio = (float)imageTex.width/(float)imageTex.height;
                
                float positionX = e.x*screenWidth  - e.width*screenHeight*aspectRatio/2;
                float positionY = e.y*screenHeight - e.height*screenHeight/2;

                DrawTexturePro(imageTex, (Rectangle){0, 0, (float)imageTex.width, (float)imageTex.height}, 
                                         (Rectangle){positionX, positionY, e.width*screenHeight*aspectRatio, e.height*screenHeight}, 
                                         VECTOR2_ZERO, 0,WHITE);
            }
            else if(e.type == ElementType::UIText || e.type == ElementType::UITextCentered){
                
                Vector2 position;
                position.x = e.x*screenWidth;
                position.y = e.y*screenHeight;
                float fontSize = e.height*screenHeight/100;
                float spacing = e.width*screenHeight/100;

                if(e.type == ElementType::UITextCentered){
                    Vector2 textSize = MeasureTextEx(_font, e.string.c_str(), fontSize, spacing);
                    position.x -= textSize.x/2;
                    position.y -= textSize.y/2;

                }

                DrawTextEx(_font, e.string.c_str(), position, fontSize, spacing, e.colorTint);
            }else if(e.type == ElementType::UIRect){
                DrawRectangle(e.x*screenWidth, e.y*screenHeight, 
                              e.width*screenWidth, e.height*screenHeight, 
                              e.colorTint);
            }
        }

        _elements.clear();
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
callq 0xf75f
movl %eax, %r14d
callq 0xf76b
movl %eax, %r15d
cmpb $0x0, 0x204e75(%rip)    # 0x215580
jne 0x1073c
leaq -0xb8(%rbp), %rbx
movq %rbx, %rdi
callq 0x5bb41
movq 0x20(%rbx), %rax
movq %rax, 0x204e51(%rip)    # 0x215578
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x204e33(%rip)   # 0x215568
movups %xmm0, 0x204e1c(%rip)   # 0x215558
movq 0x204e45(%rip), %rbx    # 0x215588
movq 0x204e46(%rip), %r12    # 0x215590
cmpq %r12, %rbx
je 0x109d7
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
cvtsi2ss %r15d, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x48(%rbp), %r13
leaq -0x58(%rbp), %r14
movl (%rbx), %eax
cmpl $0x2, %eax
jb 0x1087c
cmpl $0x3, %eax
je 0x1093f
cmpl $0x2, %eax
jne 0x109c3
movq %r13, -0x58(%rbp)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0xcddc
movq %r14, %rdi
callq 0x10238
movq %rax, %r15
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x107c9
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8880
xorps %xmm0, %xmm0
cvtsi2ssl 0x4(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2ssl 0x8(%r15), %xmm1
divss %xmm1, %xmm0
movss 0xc(%rbx), %xmm3
movss -0x2c(%rbp), %xmm5
mulss %xmm5, %xmm3
mulss %xmm0, %xmm3
movaps %xmm3, %xmm0
movss 0x88fbc(%rip), %xmm4    # 0x997b8
mulss %xmm4, %xmm0
movss 0x4(%rbx), %xmm2
mulss -0x30(%rbp), %xmm2
addss %xmm0, %xmm2
movss 0x10(%rbx), %xmm0
mulss %xmm5, %xmm0
movaps %xmm0, %xmm1
mulss %xmm4, %xmm1
movss 0x8(%rbx), %xmm4
mulss %xmm5, %xmm4
addss %xmm1, %xmm4
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
movl 0x10(%r15), %eax
movl %eax, -0x60(%rbp)
movups (%r15), %xmm1
movaps %xmm1, -0x70(%rbp)
xorps %xmm1, %xmm1
cvtsi2ssl 0x4(%r15), %xmm1
xorps %xmm4, %xmm4
cvtsi2ssl 0x8(%r15), %xmm4
unpcklps %xmm4, %xmm1            # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movl -0x60(%rbp), %eax
movl %eax, 0x10(%rsp)
movaps -0x70(%rbp), %xmm4
movups %xmm4, (%rsp)
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
xorps %xmm0, %xmm0
xorps %xmm4, %xmm4
xorps %xmm5, %xmm5
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x77577
jmp 0x109c3
movss 0x4(%rbx), %xmm3
mulss -0x30(%rbp), %xmm3
movss 0x8(%rbx), %xmm5
movss -0x2c(%rbp), %xmm0
mulss %xmm0, %xmm5
movss 0x10(%rbx), %xmm2
mulss %xmm0, %xmm2
movss 0x88f0f(%rip), %xmm1    # 0x997b4
divss %xmm1, %xmm2
movss 0xc(%rbx), %xmm4
mulss %xmm0, %xmm4
divss %xmm1, %xmm4
cmpl $0x1, %eax
jne 0x10988
movq 0x18(%rbx), %rdi
movq 0x204cae(%rip), %rax    # 0x215578
movq %rax, 0x20(%rsp)
movups 0x204c92(%rip), %xmm0   # 0x215568
movups %xmm0, 0x10(%rsp)
movups 0x204c76(%rip), %xmm0   # 0x215558
movups %xmm0, (%rsp)
movaps %xmm2, %xmm0
movaps %xmm4, %xmm1
movaps %xmm3, -0x90(%rbp)
movss %xmm2, -0x38(%rbp)
movss %xmm4, -0x34(%rbp)
movaps %xmm5, -0x80(%rbp)
callq 0x5d68c
movss -0x34(%rbp), %xmm4
movaps -0x90(%rbp), %xmm3
movaps %xmm0, %xmm1
movss 0x889d7(%rip), %xmm2    # 0x992f4
mulss %xmm2, %xmm1
subss %xmm1, %xmm3
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss %xmm2, %xmm0
movss -0x38(%rbp), %xmm2
movaps -0x80(%rbp), %xmm1
subss %xmm0, %xmm1
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
jmp 0x1098b
movss 0x4(%rbx), %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
movss 0x8(%rbx), %xmm0
movss -0x2c(%rbp), %xmm2
mulss %xmm2, %xmm0
cvttss2si %xmm0, %esi
movss 0xc(%rbx), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
movss 0x10(%rbx), %xmm0
mulss %xmm2, %xmm0
cvttss2si %xmm0, %ecx
movl 0x38(%rbx), %r8d
callq 0x4a1eb
jmp 0x109c3
unpcklps %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
movq 0x18(%rbx), %rdi
movl 0x38(%rbx), %esi
movq 0x204bdf(%rip), %rax    # 0x215578
movq %rax, 0x20(%rsp)
movups 0x204bc3(%rip), %xmm0   # 0x215568
movups %xmm0, 0x10(%rsp)
movups 0x204ba7(%rip), %xmm0   # 0x215558
movups %xmm0, (%rsp)
movaps %xmm3, %xmm0
movaps %xmm2, %xmm1
movaps %xmm4, %xmm2
callq 0x5d06b
addq $0x40, %rbx
cmpq %r12, %rbx
jne 0x10775
movq 0x204bb1(%rip), %rbx    # 0x215588
leaq 0x204baa(%rip), %rdi    # 0x215588
movq %rbx, %rsi
callq 0x11328
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x10a10
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8880
movq %rbx, %rdi
callq 0x8ea0