// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/ffi.c
// Function: janet_ffi_read_one
static Janet janet_ffi_read_one(const uint8_t *from, JanetFFIType type, int recur) {
    if (recur == 0) janet_panic("recursion too deep");
    if (type.array_count >= 0) {
        JanetFFIType el_type = type;
        el_type.array_count = -1;
        size_t el_size = type_size(el_type);
        JanetArray *array = janet_array(type.array_count);
        for (int32_t i = 0; i < type.array_count; i++) {
            janet_array_push(array, janet_ffi_read_one(from, el_type, recur - 1));
            from += el_size;
        }
        return janet_wrap_array(array);
    }
    switch (type.prim) {
        default:
        case JANET_FFI_TYPE_VOID:
            return janet_wrap_nil();
        case JANET_FFI_TYPE_STRUCT: {
            JanetFFIStruct *st = type.st;
            Janet *tup = janet_tuple_begin(st->field_count);
            for (uint32_t i = 0; i < st->field_count; i++) {
                JanetFFIType tp = st->fields[i].type;
                tup[i] = janet_ffi_read_one(from + st->fields[i].offset, tp, recur - 1);
            }
            return janet_wrap_tuple(janet_tuple_end(tup));
        }
        case JANET_FFI_TYPE_DOUBLE:
            return janet_wrap_number(((double *)(from))[0]);
        case JANET_FFI_TYPE_FLOAT:
            return janet_wrap_number(((float *)(from))[0]);
        case JANET_FFI_TYPE_PTR: {
            void *ptr = ((void **)(from))[0];
            return (NULL == ptr) ? janet_wrap_nil() : janet_wrap_pointer(ptr);
        }
        case JANET_FFI_TYPE_STRING:
            return janet_cstringv(((char **)(from))[0]);
        case JANET_FFI_TYPE_BOOL:
            return janet_wrap_boolean(((bool *)(from))[0]);
        case JANET_FFI_TYPE_INT8:
            return janet_wrap_number(((int8_t *)(from))[0]);
        case JANET_FFI_TYPE_INT16:
            return janet_wrap_number(((int16_t *)(from))[0]);
        case JANET_FFI_TYPE_INT32:
            return janet_wrap_number(((int32_t *)(from))[0]);
        case JANET_FFI_TYPE_UINT8:
            return janet_wrap_number(((uint8_t *)(from))[0]);
        case JANET_FFI_TYPE_UINT16:
            return janet_wrap_number(((uint16_t *)(from))[0]);
        case JANET_FFI_TYPE_UINT32:
            return janet_wrap_number(((uint32_t *)(from))[0]);
#ifdef JANET_INT_TYPES
        case JANET_FFI_TYPE_INT64:
            return janet_wrap_s64(((int64_t *)(from))[0]);
        case JANET_FFI_TYPE_UINT64:
            return janet_wrap_u64(((uint64_t *)(from))[0]);
#else
        case JANET_FFI_TYPE_INT64:
            return janet_wrap_number(((int64_t *)(from))[0]);
        case JANET_FFI_TYPE_UINT64:
            return janet_wrap_number(((uint64_t *)(from))[0]);
#endif
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rsi, -0x18(%rbp)
movq %rdx, -0x10(%rbp)
movq %rdi, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x34b3c
leaq 0x547f3(%rip), %rdi     # 0x8932a
callq 0x1ad60
cmpl $0x0, -0xc(%rbp)
jl 0x34bf2
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x33060
movq %rax, -0x40(%rbp)
movl -0xc(%rbp), %edi
callq 0x13180
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x34bd6
movq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x34b10
movq -0x98(%rbp), %rdi
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rsi
callq 0x13510
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x34b81
movq -0x48(%rbp), %rdi
movabsq $-0x4800000000000, %rsi # imm = 0xFFFB800000000000
callq 0x7b610
movq %rax, -0x8(%rbp)
jmp 0x34e91
movl -0x10(%rbp), %eax
movq %rax, -0xa0(%rbp)
subq $0xe, %rax
ja 0x34c19
movq -0xa0(%rbp), %rax
leaq 0x532d4(%rip), %rcx     # 0x87ee4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x34c1b
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x6a740
movq %rax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x34cf6
movq -0x60(%rbp), %rax
addq $0x10, %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x6c(%rbp), %eax
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rax
addq $0x10, %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
addq 0x10(%rax), %rdi
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x34b10
movq -0xb0(%rbp), %rcx
movq %rax, %rdx
movq -0xa8(%rbp), %rax
movq %rdx, -0x88(%rbp)
movq -0x88(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x34c52
movq -0x68(%rbp), %rdi
callq 0x6a7a0
movq %rax, %rdi
movabsq $-0x4000000000000, %rsi # imm = 0xFFFC000000000000
callq 0x7b550
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
xorl %eax, %eax
cmpq -0x90(%rbp), %rax
jne 0x34d78
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x8(%rbp)
jmp 0x34d92
movq -0x90(%rbp), %rdi
movabsq $-0x800000000000, %rsi  # imm = 0xFFFF800000000000
callq 0x7b610
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x64a70
movq %rax, %rdi
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
callq 0x7b550
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movb (%rax), %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movslq %eax, %rdi
movabsq $-0x7000000000000, %rax # imm = 0xFFF9000000000000
orq %rax, %rdi
callq 0x7b460
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cvtsi2sd %eax, %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movswl (%rax), %eax
cvtsi2sd %eax, %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
cvtsi2sdl (%rax), %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
cvtsi2sd %eax, %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
cvtsi2sd %eax, %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
callq 0x7b820
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x3b880
movq %rax, -0x8(%rbp)
jmp 0x34e91
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x3b8d0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nop