// File: /workspace/github_c_makefile_star2_O1/MuvikLabs[P]runt/basic.c
// Function: rproc_load
static int rproc_load(runt_vm *vm, runt_ptr p)
{
    runt_stacklet *s;
    const char *str;
    const char *fname;
    char buf[1024];
    int pstate = RUNT_OFF;

    memset(buf, 0, 1024);
    s = runt_pop(vm);
    str = runt_to_string(s->p);
    pstate = runt_get_state(vm, RUNT_MODE_INTERACTIVE);


    /* Try and load runt file */

    sprintf(buf, "%s.rnt", str);

    /* remove load cell from cell pool */
    runt_cell_undo(vm);

    if(access(buf, F_OK) != -1) {
        fname = buf;
        return loader(vm, pstate, fname, s, load_dictionary);
    }

    /* maybe it is a plugin? */

    if(getenv("RUNT_PLUGIN_PATH") != NULL) {
        sprintf(buf, "%s/%s.so", getenv("RUNT_PLUGIN_PATH"), str);
    } else {
        sprintf(buf, "%s/.runt/plugins/%s.so", getenv("HOME"), str);
    }

    if(access(buf, F_OK) != -1) {
        fname = buf;
        return loader(vm, pstate, fname, s, runt_load_plugin);
    }

    /* try local plugin */

    sprintf(buf, "%s.so", str);

    if(access(buf, F_OK) != -1) {
        return loader(vm, pstate, buf, s, runt_load_plugin);
    }

    runt_print(vm, "Could not find '%s'\n", str);
    return RUNT_NOT_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdi, %rbx
leaq 0x20(%rsp), %r12
movl $0x400, %edx            # imm = 0x400
movq %r12, %rdi
xorl %esi, %esi
callq 0x1090
movq %rbx, %rdi
callq 0x1edb
movq %rax, %r14
movq 0x18(%rax), %rax
movq %rax, 0x10(%rsp)
movups 0x8(%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x20b3
movq %rax, %r15
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1cef
movl %eax, %ebp
leaq 0x25b0(%rip), %rsi      # 0x7446
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1150
movq %rbx, %rdi
callq 0x3620
movq %r12, %rdi
xorl %esi, %esi
callq 0x1110
cmpl $-0x1, %eax
je 0x4edb
leaq 0x10e3(%rip), %r8       # 0x5fa4
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rcx
callq 0x5f3e
movl %eax, %r12d
jmp 0x4fc0
leaq 0x256b(%rip), %rdi      # 0x744d
callq 0x1030
testq %rax, %rax
je 0x4ef5
leaq 0x256b(%rip), %rsi      # 0x745e
jmp 0x4f08
leaq 0x2582(%rip), %rdi      # 0x747e
callq 0x1030
leaq 0x255f(%rip), %rsi      # 0x7467
leaq 0x20(%rsp), %rdi
movq %rax, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1150
leaq 0x20(%rsp), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x1110
cmpl $-0x1, %eax
jne 0x4f59
leaq 0x252c(%rip), %rsi      # 0x7461
xorl %r12d, %r12d
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1150
movq %r13, %rdi
xorl %esi, %esi
callq 0x1110
cmpl $-0x1, %eax
je 0x4fa9
movl 0x18(%r14), %eax
movl %eax, 0x534(%rbx)
movq %rbx, %rdi
movl $0x2, %esi
movl $0x4, %edx
callq 0x1507
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x3683
movl %eax, %r14d
movq %rbx, %rdi
movl $0x2, %esi
movl %ebp, %edx
callq 0x1507
testl %r14d, %r14d
je 0x4fc0
movq %rbx, %rdi
callq 0x3689
movl $0x1, %r12d
jmp 0x4fc0
leaq 0x24d3(%rip), %rsi      # 0x7483
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1cfe
movl %r12d, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq