// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/value.c
// Function: janet_length
int32_t janet_length(Janet x) {
    switch (janet_type(x)) {
        default:
            janet_panicf("expected %T, got %v", JANET_TFLAG_LENGTHABLE, x);
        case JANET_STRING:
        case JANET_SYMBOL:
        case JANET_KEYWORD:
            return janet_string_length(janet_unwrap_string(x));
        case JANET_ARRAY:
            return janet_unwrap_array(x)->count;
        case JANET_BUFFER:
            return janet_unwrap_buffer(x)->count;
        case JANET_TUPLE:
            return janet_tuple_length(janet_unwrap_tuple(x));
        case JANET_STRUCT:
            return janet_struct_length(janet_unwrap_struct(x));
        case JANET_TABLE:
            return janet_unwrap_table(x)->count;
        case JANET_ABSTRACT: {
            void *abst = janet_unwrap_abstract(x);
            const JanetAbstractType *type = janet_abstract_type(abst);
            if (type->length != NULL) {
                size_t len = type->length(abst, janet_abstract_size(abst));
                if (len > INT32_MAX) {
                    janet_panicf("invalid integer length %u", len);
                }
                return (int32_t)(len);
            }
            Janet argv[1] = { x };
            Janet len = janet_mcall("length", 1, argv);
            if (!janet_checkint(len))
                janet_panicf("invalid integer length %v", len);
            return janet_unwrap_integer(len);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x7003e
jmp 0x7004f
movq -0x10(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
movl %eax, -0x3c(%rbp)
jmp 0x70056
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
jmp 0x70056
movl -0x3c(%rbp), %eax
addl $-0x4, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0xa, %eax
ja 0x7007b
movq -0x48(%rbp), %rax
leaq 0x28b92(%rip), %rcx     # 0x98c04
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdx
leaq 0x11061(%rip), %rdi     # 0x810e7
movl $0xff0, %esi            # imm = 0xFF0
movb $0x0, %al
callq 0x1ac40
movq -0x10(%rbp), %rdi
callq 0x7b260
movl -0x8(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x701b6
movq -0x10(%rbp), %rdi
callq 0x7b260
movl 0x10(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x701b6
movq -0x10(%rbp), %rdi
callq 0x7b260
movl 0x10(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x701b6
movq -0x10(%rbp), %rdi
callq 0x7b260
movl -0x10(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x701b6
movq -0x10(%rbp), %rdi
callq 0x7b260
movl -0x18(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x701b6
movq -0x10(%rbp), %rdi
callq 0x7b260
movl 0x10(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x701b6
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x7016d
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq -0x8(%rcx), %rsi
callq *%rax
movq %rax, -0x28(%rbp)
cmpq $0x7fffffff, -0x28(%rbp) # imm = 0x7FFFFFFF
jbe 0x70164
movq -0x28(%rbp), %rsi
leaq 0x28bbb(%rip), %rdi     # 0x98d18
movb $0x0, %al
callq 0x1ac40
movq -0x28(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x701b6
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdx
leaq 0x2516a(%rip), %rdi     # 0x952ea
movl $0x1, %esi
callq 0x7a510
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x6d480
cmpl $0x0, %eax
jne 0x701ae
movq -0x38(%rbp), %rsi
leaq 0x28b8b(%rip), %rdi     # 0x98d32
movb $0x0, %al
callq 0x1ac40
cvttsd2si -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop