// File: /workspace/github_c_makefile_star2_O1/gaultier[P]lox-c/vm.c
// Function: vm_run_bytecode
Result vm_run_bytecode(Vm* vm) {
    assert(vm->frame_len > 0);
    CallFrame* frame = &vm->frames[vm->frame_len - 1];

    while (true) {
        uint8_t opcode = 0;
        read_u8(vm, &opcode);
        const Location* const loc = get_location(vm);

        LOG("opcode=%d %s\n", opcode, opcode_str[opcode]);

        switch (opcode) {
            case OP_RETURN: {
                stack_log(vm);
                Value return_value = {0};
                RETURN_IF_ERR(stack_pop(vm, &return_value));

                vm->frame_len--;
                stack_log(vm);

                if (vm->frame_len == 0) {  // End of script
                    LOG("final pop%s\n", "");
                    RETURN_IF_ERR(stack_pop(vm, &return_value));
                    return RES_OK;
                }

                vm->stack_top = frame->slots;
                RETURN_IF_ERR(stack_push(vm, return_value));

                frame = &vm->frames[vm->frame_len - 1];

                break;
            }
            case OP_NEGATE: {
                Value value = {0};
                RETURN_IF_ERR(stack_pop(vm, &value));

                if (!IS_NUMBER(value)) {
                    VM_ERROR(vm, loc, "Negation: expected a number, got: %s",
                             value_to_str_debug(value));
                }

                RETURN_IF_ERR(stack_push(vm, NUMBER_VAL(-AS_NUMBER(value))));
                break;
            }
            case OP_ADD: {
                Value rhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &rhs));
                Value lhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &lhs));

                if (IS_STRING(lhs) && IS_STRING(rhs)) {
                    Value v = {0};
                    str_cat(vm, lhs, rhs, &v);

                    RETURN_IF_ERR(stack_push(vm, v));
                    break;
                }

                if ((IS_STRING(lhs) && !IS_STRING(rhs))) {
                    VM_ERROR(vm, loc,
                             "Addition: cannot concatenate a non-string type, "
                             "got: %s",
                             value_to_str_debug(rhs));
                }

                if ((IS_STRING(rhs) && !IS_STRING(lhs))) {
                    VM_ERROR(vm, loc,
                             "Addition: cannot concatenate a non-string type, "
                             "got: %s",
                             value_to_str_debug(lhs));
                }

                if (!IS_NUMBER(lhs)) {
                    VM_ERROR(vm, loc, "Addition: expected a number, got: %s",
                             value_to_str_debug(lhs));
                }

                if (!IS_NUMBER(rhs)) {
                    VM_ERROR(vm, loc, "Addition: expected a number, got: %s",
                             value_to_str_debug(rhs));
                }

                // TODO: Check for underflow/overflow
                RETURN_IF_ERR(stack_push(
                    vm, NUMBER_VAL(AS_NUMBER(lhs) + AS_NUMBER(rhs))));
                break;
            }
            case OP_SUBTRACT: {
                Value rhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &rhs));
                if (!IS_NUMBER(rhs)) {
                    VM_ERROR(vm, loc, "Subtraction: expected a number, got: %s",
                             value_to_str_debug(rhs));
                }

                Value lhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &lhs));
                if (!IS_NUMBER(lhs)) {
                    VM_ERROR(vm, loc, "Subtraction: expected a number, got: %s",
                             value_to_str_debug(lhs));
                }

                // TODO: Check for underflow/overflow
                RETURN_IF_ERR(stack_push(
                    vm, NUMBER_VAL(AS_NUMBER(lhs) - AS_NUMBER(rhs))));
                break;
            }
            case OP_MULTIPLY: {
                Value rhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &rhs));
                if (!IS_NUMBER(rhs)) {
                    VM_ERROR(vm, loc,
                             "Multiplication: expected a number, got: %s",
                             value_to_str_debug(rhs));
                }

                Value lhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &lhs));
                if (!IS_NUMBER(lhs)) {
                    VM_ERROR(vm, loc,
                             "Multiplication: expected a number, got: %s",
                             value_to_str_debug(lhs));
                }

                // TODO: Check for underflow/overflow
                RETURN_IF_ERR(stack_push(
                    vm, NUMBER_VAL(AS_NUMBER(lhs) * AS_NUMBER(rhs))));
                break;
            }
            case OP_DIVIDE: {
                Value rhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &rhs));
                if (!IS_NUMBER(rhs)) {
                    VM_ERROR(vm, loc, "Division: expected a number, got: %s",
                             value_to_str_debug(rhs));
                }

                Value lhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &lhs));
                if (!IS_NUMBER(lhs)) {
                    VM_ERROR(vm, loc, "Division: expected a number, got: %s",
                             value_to_str_debug(lhs));
                }

                RETURN_IF_ERR(stack_push(
                    vm, NUMBER_VAL(AS_NUMBER(lhs) / AS_NUMBER(rhs))));
                break;
            }
            case OP_CONSTANT: {
                Value v = {0};
                RETURN_IF_ERR(read_constant(vm, &v));
                RETURN_IF_ERR(stack_push(vm, v));
            } break;
            case OP_NIL:
                RETURN_IF_ERR(stack_push(vm, NIL_VAL));
                break;
            case OP_TRUE:
                RETURN_IF_ERR(stack_push(vm, BOOL_VAL(true)));
                break;
            case OP_FALSE:
                RETURN_IF_ERR(stack_push(vm, BOOL_VAL(false)));
                break;
            case OP_NOT: {
                Value v = {0};
                RETURN_IF_ERR(stack_pop(vm, &v));
                RETURN_IF_ERR(stack_push(vm, BOOL_VAL(value_is_falsy(v))));
                break;
            }
            case OP_EQUAL: {
                Value rhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &rhs));
                Value lhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &lhs));
                RETURN_IF_ERR(stack_push(vm, BOOL_VAL(value_eq(lhs, rhs))));
                break;
            }
            case OP_LESS: {
                Value rhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &rhs));
                if (!IS_NUMBER(rhs)) {
                    VM_ERROR(vm, loc, "Comparison:expected a number, got: %s",
                             value_to_str_debug(rhs));
                }

                Value lhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &lhs));
                if (!IS_NUMBER(lhs)) {
                    VM_ERROR(vm, loc, "Comparison:expected a number, got: %s",
                             value_to_str_debug(lhs));
                }

                // TODO: Check for 0
                RETURN_IF_ERR(
                    stack_push(vm, BOOL_VAL(AS_NUMBER(lhs) < AS_NUMBER(rhs))));
                break;
            }
            case OP_GREATER: {
                Value rhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &rhs));
                if (!IS_NUMBER(rhs)) {
                    VM_ERROR(vm, loc, "Comparison:expected a number, got: %s",
                             value_to_str_debug(rhs));
                }

                Value lhs = {0};
                RETURN_IF_ERR(stack_pop(vm, &lhs));
                if (!IS_NUMBER(lhs)) {
                    VM_ERROR(vm, loc, "Comparison:expected a number, got: %s",
                             value_to_str_debug(lhs));
                }

                // TODO: Check for 0
                RETURN_IF_ERR(
                    stack_push(vm, BOOL_VAL(AS_NUMBER(lhs) > AS_NUMBER(rhs))));
                break;
            }
            case OP_PRINT: {
                Value value = {0};
                RETURN_IF_ERR(stack_pop(vm, &value));
                printf("%s\n", value_to_str(value));
            } break;
            case OP_POP: {
                Value value = {0};
                RETURN_IF_ERR(stack_pop(vm, &value));
            } break;
            case OP_DEFINE_GLOBAL: {
                Value name = {0};
                RETURN_IF_ERR(read_constant(vm, &name));

                Value value = {0};
                RETURN_IF_ERR(stack_pop(vm, &value));

                ht_insert(vm->globals, AS_CSTRING(name), AS_STRING(name)->len,
                          &value, sizeof(value));
                LOG("def global name=%.*s value=%s\n",
                    (int)AS_STRING(name)->len, AS_CSTRING(name),
                    value_to_str_debug(value));

                LOG("stack size: %zu\n", stack_len(vm));
                break;
            }
            case OP_GET_GLOBAL: {
                Value name = {0};
                RETURN_IF_ERR(read_constant(vm, &name));

                char* const s = AS_CSTRING(name);
                const size_t s_len = AS_STRING(name)->len;
                Value* value = ht_search(vm->globals, s, s_len);

                if (!value) {
                    VM_ERROR(vm, loc, "Undefined global variable `%.*s`",
                             (int)s_len, s);
                }

                LOG("get global name=%.*s value=%s\n", (int)s_len, s,
                    value_to_str_debug(*value));
                RETURN_IF_ERR(stack_push(vm, *value));
                break;
            }
            case OP_SET_GLOBAL: {
                Value name = {0};
                RETURN_IF_ERR(read_constant(vm, &name));

                char* const s = AS_CSTRING(name);
                const size_t s_len = AS_STRING(name)->len;
                Value* const value = ht_search(vm->globals, s, s_len);
                if (!value) {
                    VM_ERROR(vm, loc, "Undefined global variable `%.*s`",
                             (int)s_len, s);
                }

                RETURN_IF_ERR(stack_peek_from_top_at(vm, value, 0));
                LOG("set global name=%.*s value=%s\n", (int)s_len, s,
                    value_to_str_debug(*value));

                break;
            }
            case OP_GET_LOCAL: {
                uint8_t slot = 0;
                RETURN_IF_ERR(read_u8(vm, &slot));

                RETURN_IF_ERR(stack_push(vm, frame->slots[slot]));
                LOG("OP_GET_LOCAL local_index=%d v=%s\n", slot,
                    value_to_str_debug(frame->slots[slot]));

                stack_log(vm);
                break;
            }
            case OP_SET_LOCAL: {
                uint8_t slot = 0;
                RETURN_IF_ERR(read_u8(vm, &slot));

                Value v = {0};
                RETURN_IF_ERR(stack_peek_from_top_at(vm, &v, 0));
                frame->slots[slot] = v;
                stack_log(vm);

                break;
            }
            case OP_JUMP_IF_FALSE: {
                uint16_t jump = 0;
                RETURN_IF_ERR(read_u16(vm, &jump));

                Value v = {0};
                RETURN_IF_ERR(stack_peek_from_top_at(vm, &v, 0));
                frame->ip += jump * (size_t)(value_is_falsy(v));
            } break;
            case OP_JUMP: {
                uint16_t jump = 0;
                RETURN_IF_ERR(read_u16(vm, &jump));
                frame->ip += jump;
            } break;
            case OP_LOOP: {
                uint16_t jump = 0;
                RETURN_IF_ERR(read_u16(vm, &jump));
                frame->ip -= jump;
            } break;
            case OP_CALL: {
                uint8_t arg_count = 0;
                RETURN_IF_ERR(read_u8(vm, &arg_count));

                Value callee = {0};
                RETURN_IF_ERR(stack_peek_from_top_at(vm, &callee, arg_count));
                RETURN_IF_ERR(value_call(vm, callee, arg_count));
                LOG("stack top after call=%s\n",
                    value_to_str_debug(*(vm->stack_top - 1)));

                frame = &vm->frames[vm->frame_len - 1];

                LOG("called f=%.*s slots[0]=%s\n", (int)frame->fn->name_len,
                    frame->fn->name, value_to_str_debug(frame->slots[0]));

                break;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movsbq 0x40618(%rdi), %rax
testq %rax, %rax
jle 0x5eb9
movq %rdi, %rbx
leaq 0x40018(%rdi), %rcx
movq %rcx, 0x50(%rsp)
decl %eax
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rax
addq $0x40018, %rax          # imm = 0x40018
movq %rax, 0x20(%rsp)
leaq 0x40008(%rdi), %rax
movq %rax, 0x60(%rsp)
leaq 0xb(%rsp), %r13
leaq 0x2cba(%rip), %r15      # 0x7df4
movb $0x0, 0xb(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4ef2
movq %rbx, %rdi
callq 0x4f87
movq %rax, %r12
movzbl 0xb(%rsp), %eax
cmpq $0x18, %rax
ja 0x5ae2
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x40000(%rbx), %rcx
cmpq %rbx, %rcx
je 0x5e7b
leaq -0x10(%rcx), %rdi
movq %rdi, 0x40000(%rbx)
movl -0x10(%rcx), %edx
movq -0x8(%rcx), %rsi
movb 0x40618(%rbx), %al
decb %al
movb %al, 0x40618(%rbx)
je 0x5bba
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq %rcx, 0x40000(%rbx)
movq %rcx, %rdi
subq %rbx, %rdi
cmpq $0x3fff0, %rdi          # imm = 0x3FFF0
jae 0x5e9a
movl %edx, (%rcx)
movq %rsi, 0x8(%rcx)
addq $0x10, 0x40000(%rbx)
movsbq 0x40618(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x50(%rsp), %rdx
leaq (%rdx,%rcx,8), %rcx
addq $-0x18, %rcx
movq %rcx, 0x20(%rsp)
jmp 0x5bd6
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movapd %xmm0, (%rsi)
movq %rbx, %rdi
callq 0x4fe1
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movdqu -0x10(%rax), %xmm0
leaq 0x40(%rsp), %rcx
movdqa %xmm0, (%rcx)
movq 0x40010(%rbx), %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsi), %rdx
addq $0x18, %rsi
movl $0x10, %r8d
callq 0x1efe
jmp 0x5ae2
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %edi
movq -0x8(%rax), %rsi
callq 0x4a4f
movq %rax, %rdi
callq 0x1060
jmp 0x5ae2
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
cmpq %rbx, %rcx
je 0x5e7b
movq -0x8(%rax), %rcx
movl -0x10(%rax), %edx
leaq -0x20(%rax), %rsi
movq %rsi, 0x40000(%rbx)
movl -0x20(%rax), %edi
movq -0x18(%rax), %rsi
callq 0x489a
jmp 0x5a16
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %esi
movsd -0x8(%rax), %xmm0
cmpl $0x2, %esi
jne 0x5d2e
cmpq %rbx, %rcx
je 0x5e7b
leaq -0x20(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x20(%rax), %esi
movsd -0x18(%rax), %xmm1
cmpl $0x2, %esi
sete %bpl
jne 0x5d96
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
subsd %xmm0, %xmm1
jmp 0x5963
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %esi
movsd -0x8(%rax), %xmm0
cmpl $0x2, %esi
jne 0x5d3b
cmpq %rbx, %rcx
je 0x5e7b
leaq -0x20(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x20(%rax), %esi
movsd -0x18(%rax), %xmm1
cmpl $0x2, %esi
sete %bpl
jne 0x5da7
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
jmp 0x58ea
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
movl $0x0, (%rax)
jmp 0x5677
leaq 0x2f(%rsp), %r14
movb $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4ef2
pxor %xmm0, %xmm0
leaq 0x40(%rsp), %r15
movdqa %xmm0, (%r15)
movzbl (%r14), %r14d
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5f50
movl (%r15), %ebp
movq 0x8(%r15), %r15
movq %r15, 0x30(%rsp)
movq %rbx, %rdi
callq 0x4f87
movq %rax, %rdi
cmpl $0x3, %ebp
jne 0x5c9f
movq 0x30(%rsp), %rsi
movl (%rsi), %ecx
cmpl $0x1, %ecx
je 0x5be3
cmpl $0x2, %ecx
leaq 0x29a5(%rip), %r15      # 0x7df4
je 0x5bf7
testl %ecx, %ecx
jne 0x5c65
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x13f6
movl $0x2, %eax
jmp 0x5c65
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %ebp
movq -0x8(%rax), %xmm0
cmpl $0x2, %ebp
jne 0x5d48
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
pxor 0x28c8(%rip), %xmm0     # 0x7d80
movl $0x2, -0x10(%rax)
movq %xmm0, -0x8(%rax)
addq $0x10, 0x40000(%rbx)
cmpl $0x2, %ebp
je 0x5ae2
jmp 0x5e5e
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
addq $-0x10, %rax
movq %rax, 0x40000(%rbx)
jmp 0x5ae2
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
cmpq %rbx, %rcx
je 0x5e7b
movl -0x10(%rax), %r13d
movsd -0x8(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
leaq -0x20(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x20(%rax), %r15d
movq -0x18(%rax), %xmm0
movq %xmm0, 0x58(%rsp)
movq %xmm0, %rbp
movl %r15d, %edi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x4938
movq 0x38(%rsp), %xmm0
movq %xmm0, %r14
testb %al, %al
je 0x5b0e
movl %r13d, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4938
testb %al, %al
je 0x5b0e
movq $0x0, 0x30(%rsp)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %xmm0
movq %xmm0, 0x40(%rsp)
movl %r15d, %edi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x4938
testb %al, %al
je 0x5ed8
movl %r13d, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4938
testb %al, %al
je 0x5ef7
movq 0x10(%rsp), %r14
movq 0x10(%r14), %r15
addq $0x18, %r14
movq 0x40(%rsp), %r12
movq 0x10(%r12), %r13
addq $0x18, %r12
leaq (%r15,%r13), %rsi
movq 0x60(%rsp), %rdi
callq 0x4950
movq %rax, %rbp
leaq 0x18(%rax), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1160
leaq (%r15,%rbp), %rdi
addq $0x18, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1160
movq %rbp, 0x30(%rsp)
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
movq 0x30(%rsp), %rcx
movl $0x3, (%rax)
movq %rcx, 0x8(%rax)
addq $0x10, 0x40000(%rbx)
movb $0x1, %al
jmp 0x5e4a
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
movl $0x1, (%rax)
movq $0x0, 0x8(%rax)
jmp 0x5ada
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movdqa %xmm0, (%rsi)
movq %rbx, %rdi
callq 0x4fe1
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
movq 0x18(%rsp), %rcx
movl 0x10(%rsp), %edx
movl %edx, (%rax)
movq %rcx, 0x8(%rax)
jmp 0x5ada
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %r14
movdqa %xmm0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4fe1
movq 0x8(%r14), %r15
movq 0x10(%r15), %r13
addq $0x18, %r15
movq 0x40010(%rbx), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1e77
movq %rax, %r14
testq %rax, %rax
je 0x5cb6
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
movq 0x8(%r14), %rcx
movl (%r14), %edx
movl %edx, (%rax)
movq %rcx, 0x8(%rax)
addq $0x10, 0x40000(%rbx)
leaq 0xb(%rsp), %r13
leaq 0x26af(%rip), %r15      # 0x7df4
testq %r14, %r14
jne 0x5ae2
jmp 0x5e5e
leaq 0x40(%rsp), %r14
movb $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4ef2
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x5f50
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movzbl (%r14), %ecx
shll $0x4, %ecx
movdqa (%r15), %xmm0
leaq 0x2658(%rip), %r15      # 0x7df4
movdqu %xmm0, (%rax,%rcx)
jmp 0x5ae2
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %esi
movsd -0x8(%rax), %xmm0
cmpl $0x2, %esi
jne 0x5d62
cmpq %rbx, %rcx
je 0x5e7b
leaq -0x20(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x20(%rax), %esi
movsd -0x18(%rax), %xmm1
cmpl $0x2, %esi
sete %bpl
jne 0x5db8
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
mulsd %xmm1, %xmm0
movl $0x2, -0x20(%rax)
movsd %xmm0, -0x18(%rax)
jmp 0x596f
leaq 0x40(%rsp), %r14
movw $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5089
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movdqa %xmm0, (%r15)
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x5f50
movzwl (%r14), %r14d
movl (%r15), %edi
movq 0x8(%r15), %rsi
leaq 0x258e(%rip), %r15      # 0x7df4
callq 0x4884
testb %al, %al
cmoveq %r12, %r14
movq 0x20(%rsp), %rax
addq %r14, 0x8(%rax)
jmp 0x5ae2
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %esi
movsd -0x8(%rax), %xmm0
cmpl $0x2, %esi
jne 0x5d6f
cmpq %rbx, %rcx
je 0x5e7b
leaq -0x20(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x20(%rax), %esi
movsd -0x18(%rax), %xmm1
cmpl $0x2, %esi
sete %bpl
jne 0x5dc9
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
xorl %ecx, %ecx
ucomisd %xmm1, %xmm0
seta %cl
movl $0x0, -0x20(%rax)
movq %rcx, -0x18(%rax)
jmp 0x596f
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %esi
movsd -0x8(%rax), %xmm0
cmpl $0x2, %esi
jne 0x5d7c
cmpq %rbx, %rcx
je 0x5e7b
leaq -0x20(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x20(%rax), %esi
movsd -0x18(%rax), %xmm1
cmpl $0x2, %esi
sete %bpl
jne 0x5dda
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
divsd %xmm0, %xmm1
movl $0x2, -0x20(%rax)
movsd %xmm1, -0x18(%rax)
addq $0x10, 0x40000(%rbx)
testb %bpl, %bpl
jne 0x5ae2
jmp 0x5e5e
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %r14
movdqa %xmm0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4fe1
movq 0x8(%r14), %r15
movq 0x10(%r15), %r13
addq $0x18, %r15
movq 0x40010(%rbx), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1e77
movq %rax, %r14
testq %rax, %rax
je 0x5cf2
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5f50
testq %r14, %r14
leaq 0xb(%rsp), %r13
leaq 0x2410(%rip), %r15      # 0x7df4
jne 0x5ae2
jmp 0x5e5e
movq 0x40000(%rbx), %rax
cmpq %rbx, %rax
je 0x5e7b
leaq -0x10(%rax), %rcx
movq %rcx, 0x40000(%rbx)
movl -0x10(%rax), %edi
movq -0x8(%rax), %rsi
callq 0x4884
movq 0x40000(%rbx), %rcx
movq %rcx, %rdx
subq %rbx, %rdx
cmpq $0x3fff0, %rdx          # imm = 0x3FFF0
jae 0x5e9a
movzbl %al, %eax
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
jmp 0x5ada
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
movl $0x0, (%rax)
movq $0x1, 0x8(%rax)
jmp 0x5ada
leaq 0x10(%rsp), %r14
movw $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5089
movzwl (%r14), %eax
movq 0x20(%rsp), %rcx
addq %rax, 0x8(%rcx)
jmp 0x5ae2
leaq 0x10(%rsp), %rsi
movb $0x0, (%rsi)
movq %rbx, %rdi
callq 0x4ef2
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
jae 0x5e9a
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl 0x10(%rsp), %edx
shll $0x4, %edx
movq 0x8(%rcx,%rdx), %rsi
movl (%rcx,%rdx), %ecx
movl %ecx, (%rax)
movq %rsi, 0x8(%rax)
addq $0x10, 0x40000(%rbx)
movb $0x1, %al
jmp 0x5e60
leaq 0x10(%rsp), %r14
movw $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5089
movzwl (%r14), %eax
movq 0x20(%rsp), %rcx
subq %rax, 0x8(%rcx)
jmp 0x5ae2
movl %r15d, %edi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x4938
testb %al, %al
je 0x5b34
movl %r13d, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4938
testb %al, %al
je 0x5e1c
movl %r13d, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4938
testb %al, %al
je 0x5b5a
movl %r15d, %edi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x4938
testb %al, %al
je 0x5e2f
cmpl $0x2, %r15d
jne 0x5df6
cmpl $0x2, %r13d
jne 0x5e09
movq 0x40000(%rbx), %rax
movq %rax, %rcx
subq %rbx, %rcx
cmpq $0x3fff0, %rcx          # imm = 0x3FFF0
leaq 0x226b(%rip), %r15      # 0x7df4
jae 0x5e9a
movsd 0x38(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movl $0x2, (%rax)
movsd %xmm0, 0x8(%rax)
addq $0x10, 0x40000(%rbx)
movb $0x1, %al
leaq 0xb(%rsp), %r13
jmp 0x5e56
cmpq %rbx, %rdi
je 0x5e7b
addq $-0x20, %rcx
movq %rcx, 0x40000(%rbx)
movl $0x0, 0xc(%rsp)
testb %al, %al
jne 0x5ae2
jmp 0x5e5e
movq %rbx, %rdi
movl %r14d, %edx
callq 0x640a
leaq 0x21ff(%rip), %r15      # 0x7df4
jmp 0x5c65
movq 0x10(%rsi), %rax
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %rcx
movdqa %xmm0, (%rcx)
movq 0x40000(%rbx), %rsi
movl %r14d, %edx
shll $0x4, %edx
subq %rdx, %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq *%rax
testl %eax, %eax
jne 0x5c65
notq %r14
shlq $0x4, %r14
addq 0x40000(%rbx), %r14
movq %r14, 0x40000(%rbx)
movq %r14, %rax
subq %rbx, %rax
cmpq $0x3fff0, %rax          # imm = 0x3FFF0
jae 0x5e9a
movq 0x18(%rsp), %rax
movl 0x10(%rsp), %ecx
movl %ecx, (%r14)
movq %rax, 0x8(%r14)
addq $0x10, 0x40000(%rbx)
xorl %eax, %eax
testl %eax, %eax
movl 0xc(%rsp), %ecx
cmovnel %eax, %ecx
movl %ecx, 0xc(%rsp)
jne 0x5c92
movsbq 0x40618(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x50(%rsp), %rdx
leaq (%rdx,%rcx,8), %rcx
addq $-0x18, %rcx
movq %rcx, 0x20(%rsp)
testl %eax, %eax
jne 0x5e5e
jmp 0x5ae2
movl %ebp, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x13a2
movl $0x2, %eax
jmp 0x5bee
movq 0x7333(%rip), %rax      # 0xcff0
movq (%rax), %rdi
movq (%r12), %rdx
movq 0x8(%r12), %rcx
leaq 0x34bf(%rip), %rsi      # 0x918f
movl %r13d, %r8d
movq %r15, %r9
xorl %eax, %eax
callq 0x1140
movq %rbx, %rdi
callq 0x5f16
movl $0x2, 0xc(%rsp)
jmp 0x5739
movq 0x72f7(%rip), %rax      # 0xcff0
movq (%rax), %rdi
movq (%r12), %rdx
movq 0x8(%r12), %rcx
leaq 0x3483(%rip), %rsi      # 0x918f
movl %r13d, %r8d
movq %r15, %r9
xorl %eax, %eax
callq 0x1140
movq %rbx, %rdi
callq 0x5f16
movl $0x2, 0xc(%rsp)
jmp 0x59d5
movq %r12, %rdi
movq %rbx, %rdx
callq 0x170b
jmp 0x5d87
movq %r12, %rdi
movq %rbx, %rdx
callq 0x144b
jmp 0x5d87
movq %r12, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x190b
movl $0x2, 0xc(%rsp)
jmp 0x54cc
movq %r12, %rdi
movq %rbx, %rdx
callq 0x165b
jmp 0x5d87
movq %r12, %rdi
movq %rbx, %rdx
callq 0x14fb
jmp 0x5d87
movq %r12, %rdi
movq %rbx, %rdx
callq 0x15ab
movl $0x2, 0xc(%rsp)
xorl %ebp, %ebp
jmp 0x5977
movq %r12, %rdi
movapd %xmm1, %xmm0
movq %rbx, %rdx
callq 0x1763
jmp 0x5de9
movq %r12, %rdi
movapd %xmm1, %xmm0
movq %rbx, %rdx
callq 0x14a3
jmp 0x5de9
movq %r12, %rdi
movapd %xmm1, %xmm0
movq %rbx, %rdx
callq 0x16b3
jmp 0x5de9
movq %r12, %rdi
movapd %xmm1, %xmm0
movq %rbx, %rdx
callq 0x1553
jmp 0x5de9
movq %r12, %rdi
movapd %xmm1, %xmm0
movq %rbx, %rdx
callq 0x1603
movl $0x2, 0xc(%rsp)
jmp 0x5977
movq %r12, %rdi
movl %r15d, %esi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x1863
jmp 0x5e40
movq %r12, %rdi
movl %r13d, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x18b7
jmp 0x5e40
movq %r12, %rdi
movl %r13d, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x17bb
jmp 0x5e40
movq %r12, %rdi
movl %r15d, %esi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x180f
movl $0x2, 0xc(%rsp)
xorl %eax, %eax
leaq 0xb(%rsp), %r13
leaq 0x1f9e(%rip), %r15      # 0x7df4
testb %al, %al
jne 0x5ae2
xorl %eax, %eax
testb %al, %al
jne 0x513a
movl 0xc(%rsp), %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x346e(%rip), %rdi      # 0x92f0
leaq 0x30e9(%rip), %rsi      # 0x8f72
leaq 0x3472(%rip), %rcx      # 0x9302
movl $0x86, %edx
callq 0x10f0
leaq 0x3481(%rip), %rdi      # 0x9322
leaq 0x30ca(%rip), %rsi      # 0x8f72
leaq 0x3491(%rip), %rcx      # 0x9340
movl $0x6f, %edx
callq 0x10f0
leaq 0x30a0(%rip), %rdi      # 0x8f60
leaq 0x30ab(%rip), %rsi      # 0x8f72
leaq 0x3145(%rip), %rcx      # 0x9013
movl $0x1a1, %edx            # imm = 0x1A1
callq 0x10f0
leaq 0x34b7(%rip), %rdi      # 0x9396
leaq 0x308c(%rip), %rsi      # 0x8f72
leaq 0x34b8(%rip), %rcx      # 0x93a5
movl $0x3e, %edx
callq 0x10f0
leaq 0x34d1(%rip), %rdi      # 0x93cf
leaq 0x306d(%rip), %rsi      # 0x8f72
leaq 0x3499(%rip), %rcx      # 0x93a5
movl $0x3f, %edx
callq 0x10f0