// File: /workspace/github_c_makefile_star2_O3/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 0x20e33
cmpq $0x3e791d2, %rdi        # imm = 0x3E791D2
je 0x20dfa
cmpq $0x5a8ae24, %rdi        # imm = 0x5A8AE24
jne 0x20ea5
movq %rsi, %rdi
callq 0x20ee4
leaq 0x4a1fe(%rip), %rbx     # 0x6afb8
movl %eax, (%rbx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0x102aa(%rip), %rdi     # 0x31075
leaq 0x10403(%rip), %rdx     # 0x311d5
movl $0x21a, %esi            # imm = 0x21A
callq 0x729c
leaq 0x443e5(%rip), %rax     # 0x651c8
movl (%rbx), %edi
leaq 0x10419(%rip), %rsi     # 0x31205
callq *(%rax)
leaq 0x4a1c7(%rip), %rcx     # 0x6afbc
jmp 0x20ea1
movq %rsi, %rdi
callq 0x20ee4
leaq 0x4a1b7(%rip), %rcx     # 0x6afc0
movl %eax, (%rcx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0x1025b(%rip), %rdi     # 0x31075
leaq 0x103f0(%rip), %rdx     # 0x31211
movl $0x220, %esi            # imm = 0x220
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x729c
leaq 0x10405(%rip), %rdi     # 0x3123f
xorl %eax, %eax
callq 0xa899
movq %rax, %rdi
callq 0x20ee4
leaq 0x4a174(%rip), %rbx     # 0x6afc4
movl %eax, (%rbx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0x10214(%rip), %rdi     # 0x31075
leaq 0x10446(%rip), %rdx     # 0x312ae
movl $0x229, %esi            # imm = 0x229
callq 0x729c
leaq 0x4434f(%rip), %r14     # 0x651c8
movl (%rbx), %edi
leaq 0x10462(%rip), %rsi     # 0x312e4
callq *(%r14)
leaq 0x4a388(%rip), %rcx     # 0x6b214
movl %eax, (%rcx)
movl (%rbx), %edi
leaq 0x1045d(%rip), %rsi     # 0x312f4
callq *(%r14)
leaq 0x4a377(%rip), %rcx     # 0x6b218
movl %eax, (%rcx)
jmp 0x20edb
movq 0x2e124(%rip), %rax     # 0x4efd0
movq (%rax), %rsi
movq %rdi, (%rsp)
leaq 0xfde5(%rip), %rdi      # 0x30c9f
leaq 0x101b4(%rip), %rdx     # 0x31075
leaq 0x10440(%rip), %r8      # 0x31308
leaq 0x10447(%rip), %r9      # 0x31316
movl $0x230, %ecx            # imm = 0x230
xorl %eax, %eax
callq 0x718c
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq