// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbLoadLen
uint32_t rdbLoadLen(rio *rdb, int *isencoded) {
    unsigned char buf[2];
    uint32_t len;
    int type;

    if (isencoded) *isencoded = 0;

    // 读入 length ，这个值可能已经被编码，也可能没有
    if (rioRead(rdb,buf,1) == 0) return REDIS_RDB_LENERR;

    type = (buf[0]&0xC0)>>6;

    // 编码值，进行解码
    if (type == REDIS_RDB_ENCVAL) {
        /* Read a 6 bit encoding type. */
        if (isencoded) *isencoded = 1;
        return buf[0]&0x3F;

    // 6 位整数
    } else if (type == REDIS_RDB_6BITLEN) {
        /* Read a 6 bit len. */
        return buf[0]&0x3F;

    // 14 位整数
    } else if (type == REDIS_RDB_14BITLEN) {
        /* Read a 14 bit len. */
        if (rioRead(rdb,buf+1,1) == 0) return REDIS_RDB_LENERR;
        return ((buf[0]&0x3F)<<8)|buf[1];

    // 32 位整数
    } else {
        /* Read a 32 bit len. */
        if (rioRead(rdb,&len,4) == 0) return REDIS_RDB_LENERR;
        return ntohl(len);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x360a5
movl $0x0, (%r14)
movl $0x1, %eax
leaq 0x2(%rsp), %r15
testq %rax, %rax
je 0x36118
movq %rax, %rbp
movq 0x30(%rbx), %rax
cmpq %rbp, %rax
movq %rbp, %r12
cmovbq %rax, %r12
testq %rax, %rax
cmoveq %rbp, %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *(%rbx)
movq %rax, %r13
testq %rax, %rax
je 0x36102
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x360f3
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *%rax
addq %r12, %r15
movq %rbp, %rax
subq %r12, %rax
addq %r12, 0x28(%rbx)
jmp 0x36105
movq %rbp, %rax
testq %r13, %r13
jne 0x360af
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rbp, %rbp
jne 0x36248
movzbl 0x2(%rsp), %eax
movl %eax, %ecx
shrl $0x6, %ecx
cmpl $0x3, %ecx
jne 0x3613b
testq %r14, %r14
je 0x36133
movl $0x1, (%r14)
andl $0x3f, %eax
jmp 0x36248
cmpb $0x40, %al
jb 0x36248
cmpl $0x1, %ecx
jne 0x361d3
movl $0x1, %eax
leaq 0x3(%rsp), %r14
testq %rax, %rax
je 0x361bf
movq %rax, %r13
movq 0x30(%rbx), %rax
cmpq %r13, %rax
movq %r13, %r15
cmovbq %rax, %r15
testq %rax, %rax
cmoveq %r13, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *(%rbx)
movq %rax, %r12
testq %rax, %rax
je 0x361a9
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x3619a
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *%rax
addq %r15, %r14
movq %r13, %rax
subq %r15, %rax
addq %r15, 0x28(%rbx)
jmp 0x361ac
movq %r13, %rax
testq %r12, %r12
jne 0x36156
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r13, %r13
jne 0x36248
movzbl 0x2(%rsp), %ecx
andl $0x3f, %ecx
shll $0x8, %ecx
movzbl 0x3(%rsp), %eax
orl %ecx, %eax
jmp 0x36248
movl $0x4, %eax
leaq 0x4(%rsp), %r14
testq %rax, %rax
je 0x36242
movq %rax, %r13
movq 0x30(%rbx), %rax
cmpq %r13, %rax
movq %r13, %r15
cmovbq %rax, %r15
testq %rax, %rax
cmoveq %r13, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *(%rbx)
movq %rax, %r12
testq %rax, %rax
je 0x36230
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x36221
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *%rax
addq %r15, %r14
movq %r13, %rax
subq %r15, %rax
addq %r15, 0x28(%rbx)
jmp 0x36233
movq %r13, %rax
testq %r12, %r12
jne 0x361dd
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r13, %r13
jne 0x36248
movl 0x4(%rsp), %eax
bswapl %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq