// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hashTypeNext
int hashTypeNext(hashTypeIterator *hi) {

    // 迭代 ziplist
    if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
        unsigned char *zl;
        unsigned char *fptr, *vptr;

        zl = hi->subject->ptr;
        fptr = hi->fptr;
        vptr = hi->vptr;

        // 第一次执行时，初始化指针
        if (fptr == NULL) {
            /* Initialize cursor */
            redisAssert(vptr == NULL);
            fptr = ziplistIndex(zl, 0);

        // 获取下一个迭代节点
        } else {
            /* Advance cursor */
            redisAssert(vptr != NULL);
            fptr = ziplistNext(zl, vptr);
        }

        // 迭代完毕，或者 ziplist 为空
        if (fptr == NULL) return REDIS_ERR;

        /* Grab pointer to the value (fptr points to the field) */
        // 记录值的指针
        vptr = ziplistNext(zl, fptr);
        redisAssert(vptr != NULL);

        /* fptr, vptr now point to the first or next pair */
        // 更新迭代器指针
        hi->fptr = fptr;
        hi->vptr = vptr;

    // 迭代字典
    } else if (hi->encoding == REDIS_ENCODING_HT) {
        if ((hi->de = dictNext(hi->di)) == NULL) return REDIS_ERR;

    // 未知编码
    } else {
        redisPanic("Unknown hash encoding");
    }

    // 迭代成功
    return REDIS_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x5, 0x8(%rax)
jne 0x55bb9
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x55b14
cmpq $0x0, -0x28(%rbp)
jne 0x55ae1
jmp 0x55b03
leaq 0x8dbbc(%rip), %rdi     # 0xe36a4
leaq 0x8db7a(%rip), %rsi     # 0xe3669
movl $0x1d8, %edx            # imm = 0x1D8
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x32e50
movq %rax, -0x20(%rbp)
jmp 0x55b50
cmpq $0x0, -0x28(%rbp)
je 0x55b1d
jmp 0x55b3f
leaq 0x8db4e(%rip), %rdi     # 0xe3672
leaq 0x8db3e(%rip), %rsi     # 0xe3669
movl $0x1de, %edx            # imm = 0x1DE
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x33330
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x55b63
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x55c14
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x33330
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x55b7d
jmp 0x55b9f
leaq 0x8daee(%rip), %rdi     # 0xe3672
leaq 0x8dade(%rip), %rsi     # 0xe3669
movl $0x1e8, %edx            # imm = 0x1E8
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x55c0d
movq -0x10(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0x55be9
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x24270
movq -0x10(%rbp), %rcx
movq %rax, 0x28(%rcx)
cmpq $0x0, %rax
jne 0x55be7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x55c14
jmp 0x55c0b
leaq 0x8cf8b(%rip), %rdi     # 0xe2b7b
leaq 0x8da72(%rip), %rsi     # 0xe3669
movl $0x1f5, %edx            # imm = 0x1F5
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x55c0d
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)