// File: /workspace/github_c_makefile_star2_O0/gaultier[P]lox-c/vm.c
// Function: fn_native_parse_number
static Result fn_native_parse_number(Vm* vm, Value* args, uint8_t args_len,
                                     Value* ret) {
    if (args_len != 1) {
        VM_ERROR(vm, get_location(vm),
                 "Wrong arity in function call: expected 1, got: %d", args_len);
    }

    const Value* const v = &args[0];

    if (!IS_STRING(*v)) {
        VM_ERROR(vm, get_location(vm), "Expected a string, got: %s",
                 value_to_str_debug(*v));
    }

    char* s_nul = NULL;
    const size_t s_len = AS_STRING(*v)->len;
    REALLOC_SAFE(&s_nul, s_len + 1);
    memcpy(s_nul, AS_CSTRING(*v), s_len);
    s_nul[s_len] = '\0';

    char* err = NULL;
    const double num = strtod(s_nul, &err);

    if (s_len > 0 && *err != '\0') {
        VM_ERROR(vm, get_location(vm), "Cannot convert %s to number: %s",
                 value_to_str_debug(*v), strerror(errno));
    }
    *ret = NUMBER_VAL(num);

    return RES_OK;
}

// Assembly:
subq $0xa8, %rsp
movb %dl, %al
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movb %al, 0x8f(%rsp)
movq %rcx, 0x80(%rsp)
movzbl 0x8f(%rsp), %eax
cmpl $0x1, %eax
je 0xa1ea
jmp 0xa177
movq 0x5e72(%rip), %rax      # 0xfff0
movq (%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x98(%rsp), %rdi
callq 0x71c0
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x98(%rsp), %rdi
callq 0x71c0
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rdx
movq 0x8(%rax), %rcx
movzbl 0x8f(%rsp), %r8d
leaq 0x349e(%rip), %rsi      # 0xd664
movb $0x0, %al
callq 0x1140
movq 0x98(%rsp), %rdi
callq 0x95e0
movl $0x2, 0xa4(%rsp)
jmp 0xa40b
movq 0x90(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movl (%rax), %edi
movq 0x8(%rax), %rsi
xorl %edx, %edx
callq 0x66f0
testb $0x1, %al
jne 0xa29a
jmp 0xa213
movq 0x5dd6(%rip), %rax      # 0xfff0
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x98(%rsp), %rdi
callq 0x71c0
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x98(%rsp), %rdi
callq 0x71c0
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rax
movl (%rax), %edi
movq 0x8(%rax), %rsi
callq 0x6ad0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %rax, %r8
leaq 0x3429(%rip), %rsi      # 0xd69f
movb $0x0, %al
callq 0x1140
movq 0x98(%rsp), %rdi
callq 0x95e0
movl $0x2, 0xa4(%rsp)
jmp 0xa40b
movq $0x0, 0x70(%rsp)
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rsi
addq $0x1, %rsi
leaq 0x70(%rsp), %rdi
leaq 0x33f9(%rip), %rdx      # 0xd6c3
movl $0x176, %ecx            # imm = 0x176
callq 0x6190
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rsi
addq $0x18, %rsi
movq 0x68(%rsp), %rdx
callq 0x1160
movq 0x70(%rsp), %rax
movq 0x68(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq $0x0, 0x60(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1070
movsd %xmm0, 0x58(%rsp)
cmpq $0x0, 0x68(%rsp)
jbe 0xa3d3
movq 0x60(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xa3d3
jmp 0xa33b
movq 0x5cae(%rip), %rax      # 0xfff0
movq (%rax), %rax
movq %rax, (%rsp)
movq 0x98(%rsp), %rdi
callq 0x71c0
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x98(%rsp), %rdi
callq 0x71c0
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x78(%rsp), %rax
movl (%rax), %edi
movq 0x8(%rax), %rsi
callq 0x6ad0
movq %rax, 0x18(%rsp)
callq 0x1050
movl (%rax), %edi
callq 0x11e0
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %r8
movq %rax, %r9
leaq 0x3328(%rip), %rsi      # 0xd6da
movb $0x0, %al
callq 0x1140
movq 0x98(%rsp), %rdi
callq 0x95e0
movl $0x2, 0xa4(%rsp)
jmp 0xa40b
movq 0x80(%rsp), %rax
movl $0x2, 0x48(%rsp)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x48(%rsp), %rcx
movq %rcx, (%rax)
movq 0x50(%rsp), %rcx
movq %rcx, 0x8(%rax)
movl $0x0, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
nopw (%rax,%rax)