// File: /workspace/github_c_makefile_star2_O0/MuvikLabs[P]runt/irunt.c
// Function: irunt_begin
runt_int irunt_begin(int argc, char *argv[], runt_int (*loader)(runt_vm *))
{
    irunt_data irunt;
    char  *line = NULL;
    size_t len = 0;
    ssize_t read;
    runt_vm *vm;
    int argpos = 0;

    irunt_init(&irunt);
    argpos = irunt_parse_args(&irunt, argc, argv);

    if(argpos < 0) return 1;

    argv = &argv[argc - argpos];
    argc = argpos;
    vm = &irunt.vm;

    vm->argc = argc;
    vm->argv = argv;
    vm->argpos = argpos;

    irunt.mem = malloc(irunt.memsize);
    irunt.cells = malloc(sizeof(runt_cell) * irunt.ncells);

    runt_cell_pool_set(vm, irunt.cells, irunt.ncells);
    runt_cell_pool_init(vm);

    runt_memory_pool_set(vm, irunt.mem, irunt.memsize);

    vm->loader = loader;
    loader(vm);
    runt_pmark_set(vm);

    if(irunt.batch_mode) {
        runt_set_state(vm, RUNT_MODE_INTERACTIVE, RUNT_ON);
    }

    if(argc > 1) load_dictionary(vm, argv[1]);
    if(irunt.batch_mode && argc == 0) load_dictionary_handle(vm, stdin);
    if(!irunt.batch_mode) {
        runt_set_state(vm, RUNT_MODE_INTERACTIVE, RUNT_ON);
        while(runt_is_alive(vm) == RUNT_OK) {
            printf("> ");
            fflush(stdout);
            read = runt_getline(&line, &len, stdin);
            parse(vm, line, read);
        }
    }

    runt_close_plugins(vm);

    free(line);
    free(irunt.cells);
    free(irunt.mem);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1520, %rsp           # imm = 0x1520
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x14f8(%rbp)
movq $0x0, -0x1500(%rbp)
movl $0x0, -0x1514(%rbp)
leaq -0x14f0(%rbp), %rdi
callq 0x8960
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14f0(%rbp), %rdi
callq 0x89b0
movl %eax, -0x1514(%rbp)
cmpl $0x0, -0x1514(%rbp)
jge 0x8750
movl $0x1, -0x4(%rbp)
jmp 0x894d
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %ecx
subl -0x1514(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movl -0x1514(%rbp), %eax
movl %eax, -0x8(%rbp)
leaq -0x14f0(%rbp), %rax
movq %rax, -0x1510(%rbp)
movl -0x8(%rbp), %ecx
movq -0x1510(%rbp), %rax
movl %ecx, 0x11e8(%rax)
movq -0x10(%rbp), %rcx
movq -0x1510(%rbp), %rax
movq %rcx, 0x11e0(%rax)
movl -0x1514(%rbp), %ecx
movq -0x1510(%rbp), %rax
movl %ecx, 0x11ec(%rax)
movq -0x20(%rbp), %rdi
callq 0x10f0
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
imulq $0x28, %rax, %rdi
callq 0x10f0
movq %rax, -0x30(%rbp)
movq -0x1510(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x1770
movq -0x1510(%rbp), %rdi
callq 0x17b0
movq -0x1510(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
callq 0x1820
movq -0x18(%rbp), %rcx
movq -0x1510(%rbp), %rax
movq %rcx, 0x1200(%rax)
movq -0x18(%rbp), %rax
movq -0x1510(%rbp), %rdi
callq *%rax
movq -0x1510(%rbp), %rdi
callq 0x4710
cmpl $0x0, -0x28(%rbp)
je 0x8850
movq -0x1510(%rbp), %rdi
movl $0x2, %esi
movl $0x3, %edx
callq 0x1550
cmpl $0x1, -0x8(%rbp)
jle 0x886a
movq -0x1510(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x8a60
cmpl $0x0, -0x28(%rbp)
je 0x888c
cmpl $0x0, -0x8(%rbp)
jne 0x888c
movq -0x1510(%rbp), %rdi
movq 0x4754(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
callq 0x8ad0
cmpl $0x0, -0x28(%rbp)
jne 0x891c
movq -0x1510(%rbp), %rdi
movl $0x2, %esi
movl $0x3, %edx
callq 0x1550
movq -0x1510(%rbp), %rdi
callq 0x4620
cmpl $0x1, %eax
jne 0x891a
leaq 0xe84(%rip), %rdi       # 0x9748
movb $0x0, %al
callq 0x1080
movq 0x46fe(%rip), %rax      # 0xcfd0
movq (%rax), %rdi
callq 0x1100
movq 0x46f7(%rip), %rax      # 0xcfd8
movq (%rax), %rdx
leaq -0x14f8(%rbp), %rdi
leaq -0x1500(%rbp), %rsi
callq 0x4ce0
movq %rax, -0x1508(%rbp)
movq -0x1510(%rbp), %rdi
movq -0x14f8(%rbp), %rsi
movq -0x1508(%rbp), %rdx
callq 0x8690
jmp 0x88ac
jmp 0x891c
movq -0x1510(%rbp), %rdi
callq 0x4a70
movq -0x14f8(%rbp), %rdi
callq 0x1040
movq -0x30(%rbp), %rdi
callq 0x1040
movq -0x38(%rbp), %rdi
callq 0x1040
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1520, %rsp           # imm = 0x1520
popq %rbp
retq
nopl (%rax)