// File: /workspace/github_c_makefile_star2_O0/termbox[P]termbox/termbox.c
// Function: load_terminfo
static char *load_terminfo(void) {
    char tmp[4096];
    const char *term = getenv("TERM");
    if (!term) {
        return 0;
    }

    // if TERMINFO is set, no other directory should be searched
    const char *terminfo = getenv("TERMINFO");
    if (terminfo) {
        return terminfo_try_path(terminfo, term);
    }

    // next, consider ~/.terminfo
    const char *home = getenv("HOME");
    if (home) {
        snprintf(tmp, sizeof(tmp), "%s/.terminfo", home);
        tmp[sizeof(tmp) - 1] = '\0';
        char *data = terminfo_try_path(tmp, term);
        if (data)
            return data;
    }

    // next, TERMINFO_DIRS
    const char *dirs = getenv("TERMINFO_DIRS");
    if (dirs) {
        snprintf(tmp, sizeof(tmp), "%s", dirs);
        tmp[sizeof(tmp) - 1] = '\0';
        char *dir = strtok(tmp, ":");
        while (dir) {
            const char *cdir = dir;
            if (strcmp(cdir, "") == 0) {
                cdir = "/usr/share/terminfo";
            }
            char *data = terminfo_try_path(cdir, term);
            if (data)
                return data;
            dir = strtok(0, ":");
        }
    }

    // fallback to /usr/share/terminfo
    return terminfo_try_path("/usr/share/terminfo", term);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1050, %rsp           # imm = 0x1050
leaq 0x222b(%rip), %rdi      # 0x715d
callq 0x3030
movq %rax, -0x1018(%rbp)
cmpq $0x0, -0x1018(%rbp)
jne 0x4f55
movq $0x0, -0x8(%rbp)
jmp 0x510e
leaq 0x2206(%rip), %rdi      # 0x7162
callq 0x3030
movq %rax, -0x1020(%rbp)
cmpq $0x0, -0x1020(%rbp)
je 0x4f8e
movq -0x1020(%rbp), %rdi
movq -0x1018(%rbp), %rsi
callq 0x53a0
movq %rax, -0x8(%rbp)
jmp 0x510e
leaq 0x21d6(%rip), %rdi      # 0x716b
callq 0x3030
movq %rax, -0x1028(%rbp)
cmpq $0x0, -0x1028(%rbp)
je 0x5006
leaq -0x1010(%rbp), %rdi
movq -0x1028(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x21ab(%rip), %rdx      # 0x7170
movb $0x0, %al
callq 0x30d0
movb $0x0, -0x11(%rbp)
leaq -0x1010(%rbp), %rdi
movq -0x1018(%rbp), %rsi
callq 0x53a0
movq %rax, -0x1030(%rbp)
cmpq $0x0, -0x1030(%rbp)
je 0x5004
movq -0x1030(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x510e
jmp 0x5006
leaq 0x2170(%rip), %rdi      # 0x717d
callq 0x3030
movq %rax, -0x1038(%rbp)
cmpq $0x0, -0x1038(%rbp)
je 0x50f7
leaq -0x1010(%rbp), %rdi
movq -0x1038(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x2166(%rip), %rdx      # 0x71a7
movb $0x0, %al
callq 0x30d0
movb $0x0, -0x11(%rbp)
leaq -0x1010(%rbp), %rdi
leaq 0x2131(%rip), %rsi      # 0x718b
callq 0x3220
movq %rax, -0x1040(%rbp)
cmpq $0x0, -0x1040(%rbp)
je 0x50f5
movq -0x1040(%rbp), %rax
movq %rax, -0x1048(%rbp)
movq -0x1048(%rbp), %rdi
leaq 0x1f98(%rip), %rsi      # 0x7028
callq 0x3150
cmpl $0x0, %eax
jne 0x50a8
leaq 0x20ec(%rip), %rax      # 0x718d
movq %rax, -0x1048(%rbp)
movq -0x1048(%rbp), %rdi
movq -0x1018(%rbp), %rsi
callq 0x53a0
movq %rax, -0x1050(%rbp)
cmpq $0x0, -0x1050(%rbp)
je 0x50d9
movq -0x1050(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x510e
xorl %eax, %eax
movl %eax, %edi
leaq 0x20a7(%rip), %rsi      # 0x718b
callq 0x3220
movq %rax, -0x1040(%rbp)
jmp 0x5066
jmp 0x50f7
movq -0x1018(%rbp), %rsi
leaq 0x2088(%rip), %rdi      # 0x718d
callq 0x53a0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1050, %rsp           # imm = 0x1050
popq %rbp
retq
nopl (%rax,%rax)