// File: /workspace/github_c_makefile_star2_O3/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 0x1e92
movq %rax, %r14
movq 0x18(%rax), %rax
movq %rax, 0x10(%rsp)
movups 0x8(%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x2055
movq %rax, %r15
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1caa
movl %eax, %ebp
leaq 0x2728(%rip), %rsi      # 0x7446
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1150
movq %rbx, %rdi
callq 0x355f
movq %r12, %rdi
xorl %esi, %esi
callq 0x1110
cmpl $-0x1, %eax
je 0x4d64
movl 0x18(%r14), %ecx
leaq 0x10fe(%rip), %r8       # 0x5e4b
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5de8
movl %eax, %r12d
jmp 0x4e49
leaq 0x26e2(%rip), %rdi      # 0x744d
callq 0x1030
testq %rax, %rax
je 0x4d7e
leaq 0x26e2(%rip), %rsi      # 0x745e
jmp 0x4d91
leaq 0x26f9(%rip), %rdi      # 0x747e
callq 0x1030
leaq 0x26d6(%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 0x4de2
leaq 0x26a3(%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 0x4e32
movl 0x18(%r14), %eax
movl %eax, 0x534(%rbx)
movq %rbx, %rdi
movl $0x2, %esi
movl $0x4, %edx
callq 0x14e5
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x35c2
movl %eax, %r14d
movq %rbx, %rdi
movl $0x2, %esi
movl %ebp, %edx
callq 0x14e5
testl %r14d, %r14d
je 0x4e49
movq %rbx, %rdi
callq 0x35c8
movl $0x1, %r12d
jmp 0x4e49
leaq 0x264a(%rip), %rsi      # 0x7483
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1cb9
movl %r12d, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq