// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x5a8ae24, -0x18(%rbp) # imm = 0x5A8AE24
movq $0x3e791d2, -0x20(%rbp) # imm = 0x3E791D2
movq $0x34ce3f6, -0x28(%rbp) # imm = 0x34CE3F6
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
subq $0x34ce3f6, %rax        # imm = 0x34CE3F6
je 0x2cf97
jmp 0x2ceae
movq -0x40(%rbp), %rax
subq $0x3e791d2, %rax        # imm = 0x3E791D2
je 0x2cf48
jmp 0x2cec0
movq -0x40(%rbp), %rax
subq $0x5a8ae24, %rax        # imm = 0x5A8AE24
jne 0x2d047
jmp 0x2ced2
movq -0x10(%rbp), %rdi
callq 0x2d090
movl %eax, -0x2c(%rbp)
leaq 0x58113(%rip), %rax     # 0x84ff8
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x58107(%rip), %rdi     # 0x84ff8
callq 0x41e60
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
leaq 0x1913d(%rip), %rdi     # 0x46045
movl $0x21a, %esi            # imm = 0x21A
leaq 0x19291(%rip), %rdx     # 0x461a5
movzbl %al, %ecx
callq 0xb210
leaq 0x522e5(%rip), %rax     # 0x7f208
movq (%rax), %rax
leaq 0x580cb(%rip), %rcx     # 0x84ff8
movl (%rcx), %edi
leaq 0x1929f(%rip), %rsi     # 0x461d5
callq *%rax
movl %eax, %ecx
leaq 0x580bb(%rip), %rax     # 0x84ffc
movl %ecx, (%rax)
jmp 0x2d081
movq -0x10(%rbp), %rdi
callq 0x2d090
movl %eax, -0x30(%rbp)
leaq 0x580a5(%rip), %rax     # 0x85000
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x58099(%rip), %rdi     # 0x85000
callq 0x41e60
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
leaq 0x190c7(%rip), %rdi     # 0x46045
movl $0x220, %esi            # imm = 0x220
leaq 0x19257(%rip), %rdx     # 0x461e1
movzbl %al, %ecx
callq 0xb210
jmp 0x2d081
movq -0x10(%rbp), %rsi
leaq 0x1926d(%rip), %rdi     # 0x4620f
movb $0x0, %al
callq 0x102c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2d090
movl %eax, -0x34(%rbp)
leaq 0x58044(%rip), %rax     # 0x85004
movl -0x34(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x58038(%rip), %rdi     # 0x85004
callq 0x41e60
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
leaq 0x19062(%rip), %rdi     # 0x46045
movl $0x229, %esi            # imm = 0x229
leaq 0x1928f(%rip), %rdx     # 0x4627e
movzbl %al, %ecx
callq 0xb210
leaq 0x5220a(%rip), %rax     # 0x7f208
movq (%rax), %rax
leaq 0x57ffc(%rip), %rcx     # 0x85004
movl (%rcx), %edi
leaq 0x192a3(%rip), %rsi     # 0x462b4
callq *%rax
movl %eax, %ecx
leaq 0x58238(%rip), %rax     # 0x85254
movl %ecx, (%rax)
leaq 0x521e3(%rip), %rax     # 0x7f208
movq (%rax), %rax
leaq 0x57fd5(%rip), %rcx     # 0x85004
movl (%rcx), %edi
leaq 0x1928c(%rip), %rsi     # 0x462c4
callq *%rax
movl %eax, %ecx
leaq 0x58215(%rip), %rax     # 0x85258
movl %ecx, (%rax)
jmp 0x2d081
movq 0x3bf92(%rip), %rax     # 0x68fe0
movq (%rax), %rsi
movq -0x8(%rbp), %rax
leaq 0x18c13(%rip), %rdi     # 0x45c6f
leaq 0x18fe2(%rip), %rdx     # 0x46045
movl $0x230, %ecx            # imm = 0x230
leaq 0x19269(%rip), %r8      # 0x462d8
leaq 0x19270(%rip), %r9      # 0x462e6
movq %rax, (%rsp)
movb $0x0, %al
callq 0xb100
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)