// File: /workspace/github_c_makefile_star2_O1/FredTheDino[P]Fog/src/engine/renderer/opengl_renderer.cpp
// Function: Renderer::Impl::upload_shader(unsigned long long, char const*)
void upload_shader(u64 asset_hash, const char *source) {
    constexpr u64 master_shader = Asset::asset_hash_comp("MASTER_SHADER");
    constexpr u64 font_shader = Asset::asset_hash_comp("FONT_SHADER");
    constexpr u64 post_process_shader = Asset::asset_hash_comp("POST_PROCESS_SHADER");
    switch (asset_hash) {
        case master_shader:
            master_shader_program = compile_shader_program_from_source(source);
            ASSERT(master_shader_program, "Failed to compile shader");
            master_shader_current_cam_loc =
                glGetUniformLocation(master_shader_program.id, "current_cam");
            break;
        case font_shader:
            font_shader_program = compile_shader_program_from_source(source);
            ASSERT(font_shader_program, "Failed to compile shader");
            break;
        case post_process_shader:
            source = Util::format_int(
                    "const int num_screens = " STR(OPENGL_NUM_CAMERAS) ";\n"
                    "uniform int num_active_samplers;\n"
                    "uniform sampler2D screen_samplers[num_screens];\n"
                    "%s", source);
            post_process_shader_program = compile_shader_program_from_source(source);
            ASSERT(post_process_shader_program, "Failed to compile shader");
            screen_texture_location = glGetUniformLocation(
                post_process_shader_program.id, "screen_samplers");
            num_screen_textures_location = glGetUniformLocation(
                post_process_shader_program.id, "num_active_samplers");
            break;
        default:
            ERR("Invalid asset passed as shader (%d)", asset_hash);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpq $0x34ce3f6, %rdi        # imm = 0x34CE3F6
je 0x21130
cmpq $0x3e791d2, %rdi        # imm = 0x3E791D2
je 0x210f7
cmpq $0x5a8ae24, %rdi        # imm = 0x5A8AE24
jne 0x211a2
movq %rsi, %rdi
callq 0x211e1
leaq 0x49f11(%rip), %rbx     # 0x6afc8
movl %eax, (%rbx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0xffbd(%rip), %rdi      # 0x31085
leaq 0x10116(%rip), %rdx     # 0x311e5
movl $0x21a, %esi            # imm = 0x21A
callq 0x722f
leaq 0x440f8(%rip), %rax     # 0x651d8
movl (%rbx), %edi
leaq 0x1012c(%rip), %rsi     # 0x31215
callq *(%rax)
leaq 0x49eda(%rip), %rcx     # 0x6afcc
jmp 0x2119e
movq %rsi, %rdi
callq 0x211e1
leaq 0x49eca(%rip), %rcx     # 0x6afd0
movl %eax, (%rcx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0xff6e(%rip), %rdi      # 0x31085
leaq 0x10103(%rip), %rdx     # 0x31221
movl $0x220, %esi            # imm = 0x220
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x722f
leaq 0x10118(%rip), %rdi     # 0x3124f
xorl %eax, %eax
callq 0xaafe
movq %rax, %rdi
callq 0x211e1
leaq 0x49e87(%rip), %rbx     # 0x6afd4
movl %eax, (%rbx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0xff27(%rip), %rdi      # 0x31085
leaq 0x10159(%rip), %rdx     # 0x312be
movl $0x229, %esi            # imm = 0x229
callq 0x722f
leaq 0x44062(%rip), %r14     # 0x651d8
movl (%rbx), %edi
leaq 0x10175(%rip), %rsi     # 0x312f4
callq *(%r14)
leaq 0x4a09b(%rip), %rcx     # 0x6b224
movl %eax, (%rcx)
movl (%rbx), %edi
leaq 0x10170(%rip), %rsi     # 0x31304
callq *(%r14)
leaq 0x4a08a(%rip), %rcx     # 0x6b228
movl %eax, (%rcx)
jmp 0x211d8
movq 0x2de27(%rip), %rax     # 0x4efd0
movq (%rax), %rsi
movq %rdi, (%rsp)
leaq 0xfaf8(%rip), %rdi      # 0x30caf
leaq 0xfec7(%rip), %rdx      # 0x31085
leaq 0x10153(%rip), %r8      # 0x31318
leaq 0x1015a(%rip), %r9      # 0x31326
movl $0x230, %ecx            # imm = 0x230
xorl %eax, %eax
callq 0x711f
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq