// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/marsh.c
// Function: readint
static int32_t readint(UnmarshalState *st, const uint8_t **atdata) {
    const uint8_t *data = *atdata;
    int32_t ret;
    MARSH_EOS(st, data);
    if (*data < 128) {
        ret = *data++;
    } else if (*data < 192) {
        MARSH_EOS(st, data + 1);
        uint32_t uret = ((data[0] & 0x3F) << 8) + data[1];
        /* Sign extend 18 MSBs */
        uret |= (uret >> 13) ? 0xFFFFC000 : 0;
        ret = (int32_t)uret;
        data += 2;
    } else if (*data == LB_INTEGER) {
        MARSH_EOS(st, data + 4);
        uint32_t ui = ((uint32_t)(data[1]) << 24) |
                      ((uint32_t)(data[2]) << 16) |
                      ((uint32_t)(data[3]) << 8) |
                      (uint32_t)(data[4]);
        ret = (int32_t)ui;
        data += 5;
    } else {
        janet_panicf("expected integer, got byte %x at index %d",
                     *data,
                     data - st->start);
        ret = 0;
    }
    *atdata = data;
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0xf0(%rcx), %rax
jb 0x418f8
leaq 0x4b2f9(%rip), %rdi     # 0x8cbec
callq 0x1ad60
jmp 0x418fa
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x80, %eax
jge 0x41922
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x41a43
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xc0, %eax
jge 0x4199f
jmp 0x41932
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
cmpq 0xf0(%rcx), %rax
jb 0x41953
leaq 0x4b29e(%rip), %rdi     # 0x8cbec
callq 0x1ad60
jmp 0x41955
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0x8, %eax
movq -0x18(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %edx
shrl $0xd, %edx
xorl %eax, %eax
movl $0xffffc000, %ecx       # imm = 0xFFFFC000
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
jmp 0x41a41
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xcd, %eax
jne 0x41a18
jmp 0x419af
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq -0x8(%rbp), %rcx
cmpq 0xf0(%rcx), %rax
jb 0x419d0
leaq 0x4b221(%rip), %rdi     # 0x8cbec
callq 0x1ad60
jmp 0x419d2
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x18, %eax
movq -0x18(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x18(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x18(%rbp), %rcx
movzbl 0x4(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x18(%rbp)
jmp 0x41a3f
movq -0x18(%rbp), %rax
movzbl (%rax), %esi
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0xe8(%rax), %rax
subq %rax, %rdx
leaq 0x4b2dd(%rip), %rdi     # 0x8cd15
movb $0x0, %al
callq 0x1ac40
jmp 0x41a41
jmp 0x41a43
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)