// File: /workspace/github_c_makefile_star2_O0/adsr[P]phpspy/vendor/termbox2/termbox2.h
// Function: load_terminfo
static int load_terminfo(void) {
    int rv;
    char tmp[PATH_MAX];

    // See terminfo(5) "Fetching Compiled Descriptions" for a description of
    // this behavior. Some of these paths are compile-time ncurses options, so
    // best guesses are used here.
    const char *term = getenv("TERM");
    if (!term) {
        return TB_ERR;
    }

    // If TERMINFO is set, try that directory and stop
    const char *terminfo = getenv("TERMINFO");
    if (terminfo) {
        return load_terminfo_from_path(terminfo, term);
    }

    // Next try ~/.terminfo
    const char *home = getenv("HOME");
    if (home) {
        snprintf_or_return(rv, tmp, sizeof(tmp), "%s/.terminfo", home);
        if_ok_return(rv, load_terminfo_from_path(tmp, term));
    }

    // Next try TERMINFO_DIRS
    //
    // Note, empty entries are supposed to be interpretted as the "compiled-in
    // default", which is of course system-dependent. Previously /etc/terminfo
    // was used here. Let's skip empty entries altogether rather than give
    // precedence to a guess, and check common paths after this loop.
    const char *dirs = getenv("TERMINFO_DIRS");
    if (dirs) {
        snprintf_or_return(rv, tmp, sizeof(tmp), "%s", dirs);
        char *dir = strtok(tmp, ":");
        while (dir) {
            const char *cdir = dir;
            if (*cdir != '\0') {
                if_ok_return(rv, load_terminfo_from_path(cdir, term));
            }
            dir = strtok(NULL, ":");
        }
    }

#ifdef TB_TERMINFO_DIR
    if_ok_return(rv, load_terminfo_from_path(TB_TERMINFO_DIR, term));
#endif
    if_ok_return(rv, load_terminfo_from_path("/usr/local/etc/terminfo", term));
    if_ok_return(rv,
        load_terminfo_from_path("/usr/local/share/terminfo", term));
    if_ok_return(rv, load_terminfo_from_path("/usr/local/lib/terminfo", term));
    if_ok_return(rv, load_terminfo_from_path("/etc/terminfo", term));
    if_ok_return(rv, load_terminfo_from_path("/usr/share/terminfo", term));
    if_ok_return(rv, load_terminfo_from_path("/usr/lib/terminfo", term));
    if_ok_return(rv, load_terminfo_from_path("/usr/share/lib/terminfo", term));
    if_ok_return(rv, load_terminfo_from_path("/lib/terminfo", term));

    return TB_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1040, %rsp           # imm = 0x1040
leaq 0x27b64(%rip), %rdi     # 0x33fc6
callq 0x6030
movq %rax, -0x1018(%rbp)
cmpq $0x0, -0x1018(%rbp)
jne 0xc484
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc757
leaq 0x27b40(%rip), %rdi     # 0x33fcb
callq 0x6030
movq %rax, -0x1020(%rbp)
cmpq $0x0, -0x1020(%rbp)
je 0xc4bc
movq -0x1020(%rbp), %rdi
movq -0x1018(%rbp), %rsi
callq 0xca80
movl %eax, -0x4(%rbp)
jmp 0xc757
leaq 0x27b11(%rip), %rdi     # 0x33fd4
callq 0x6030
movq %rax, -0x1028(%rbp)
cmpq $0x0, -0x1028(%rbp)
je 0xc544
jmp 0xc4db
leaq -0x1010(%rbp), %rdi
movq -0x1028(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x27ae4(%rip), %rdx     # 0x33fd9
movb $0x0, %al
callq 0x61d0
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0xc50e
cmpl $0x1000, -0x8(%rbp)     # imm = 0x1000
jl 0xc51a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc757
jmp 0xc51c
leaq -0x1010(%rbp), %rdi
movq -0x1018(%rbp), %rsi
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc542
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
jmp 0xc544
leaq 0x27a9b(%rip), %rdi     # 0x33fe6
callq 0x6030
movq %rax, -0x1030(%rbp)
cmpq $0x0, -0x1030(%rbp)
je 0xc62c
jmp 0xc567
leaq -0x1010(%rbp), %rdi
movq -0x1030(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x28c5c(%rip), %rdx     # 0x351dd
movb $0x0, %al
callq 0x61d0
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0xc59a
cmpl $0x1000, -0x8(%rbp)     # imm = 0x1000
jl 0xc5a6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc757
jmp 0xc5a8
leaq -0x1010(%rbp), %rdi
leaq 0x28f19(%rip), %rsi     # 0x354cf
callq 0x6530
movq %rax, -0x1038(%rbp)
cmpq $0x0, -0x1038(%rbp)
je 0xc62a
movq -0x1038(%rbp), %rax
movq %rax, -0x1040(%rbp)
movq -0x1040(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc611
movq -0x1040(%rbp), %rdi
movq -0x1018(%rbp), %rsi
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc60f
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
jmp 0xc611
xorl %eax, %eax
movl %eax, %edi
leaq 0x28eb3(%rip), %rsi     # 0x354cf
callq 0x6530
movq %rax, -0x1038(%rbp)
jmp 0xc5c2
jmp 0xc62c
movq -0x1018(%rbp), %rsi
leaq 0x279ba(%rip), %rdi     # 0x33ff4
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc652
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movq -0x1018(%rbp), %rsi
leaq 0x279ac(%rip), %rdi     # 0x3400c
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc678
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movq -0x1018(%rbp), %rsi
leaq 0x279a0(%rip), %rdi     # 0x34026
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc69e
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movq -0x1018(%rbp), %rsi
leaq 0x27952(%rip), %rdi     # 0x33ffe
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc6c4
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movq -0x1018(%rbp), %rsi
leaq 0x2796c(%rip), %rdi     # 0x3403e
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc6e7
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movq -0x1018(%rbp), %rsi
leaq 0x2795d(%rip), %rdi     # 0x34052
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc70a
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movq -0x1018(%rbp), %rsi
leaq 0x2794c(%rip), %rdi     # 0x34064
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc72d
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movq -0x1018(%rbp), %rsi
leaq 0x27933(%rip), %rdi     # 0x3406e
callq 0xca80
movl %eax, -0x8(%rbp)
cmpl $0x0, %eax
jne 0xc750
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xc757
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x1040, %rsp           # imm = 0x1040
popq %rbp
retq
nopw %cs:(%rax,%rax)