// File: /workspace/github_c_makefile_star2_O2/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 0x1f7b5
cmpq $0x3e791d2, %rdi        # imm = 0x3E791D2
je 0x1f77c
cmpq $0x5a8ae24, %rdi        # imm = 0x5A8AE24
jne 0x1f827
movq %rsi, %rdi
callq 0x1f866
leaq 0x4688c(%rip), %rbx     # 0x65fc8
movl %eax, (%rbx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0xc900(%rip), %rdi      # 0x2c04d
leaq 0xca59(%rip), %rdx      # 0x2c1ad
movl $0x21a, %esi            # imm = 0x21A
callq 0x6903
leaq 0x40a73(%rip), %rax     # 0x601d8
movl (%rbx), %edi
leaq 0xca6f(%rip), %rsi      # 0x2c1dd
callq *(%rax)
leaq 0x46855(%rip), %rcx     # 0x65fcc
jmp 0x1f823
movq %rsi, %rdi
callq 0x1f866
leaq 0x46845(%rip), %rcx     # 0x65fd0
movl %eax, (%rcx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0xc8b1(%rip), %rdi      # 0x2c04d
leaq 0xca46(%rip), %rdx      # 0x2c1e9
movl $0x220, %esi            # imm = 0x220
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x6903
leaq 0xca5b(%rip), %rdi      # 0x2c217
xorl %eax, %eax
callq 0x9642
movq %rax, %rdi
callq 0x1f866
leaq 0x46802(%rip), %rbx     # 0x65fd4
movl %eax, (%rbx)
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leaq 0xc86a(%rip), %rdi      # 0x2c04d
leaq 0xca9c(%rip), %rdx      # 0x2c286
movl $0x229, %esi            # imm = 0x229
callq 0x6903
leaq 0x409dd(%rip), %r14     # 0x601d8
movl (%rbx), %edi
leaq 0xcab8(%rip), %rsi      # 0x2c2bc
callq *(%r14)
leaq 0x46a16(%rip), %rcx     # 0x66224
movl %eax, (%rcx)
movl (%rbx), %edi
leaq 0xcab3(%rip), %rsi      # 0x2c2cc
callq *(%r14)
leaq 0x46a05(%rip), %rcx     # 0x66228
movl %eax, (%rcx)
jmp 0x1f85d
movq 0x2a7a2(%rip), %rax     # 0x49fd0
movq (%rax), %rsi
movq %rdi, (%rsp)
leaq 0xc43b(%rip), %rdi      # 0x2bc77
leaq 0xc80a(%rip), %rdx      # 0x2c04d
leaq 0xca96(%rip), %r8       # 0x2c2e0
leaq 0xca9d(%rip), %r9       # 0x2c2ee
movl $0x230, %ecx            # imm = 0x230
xorl %eax, %eax
callq 0x683a
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq