// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hashTypeConvertZiplist
void hashTypeConvertZiplist(robj *o, int enc) {
    redisAssert(o->encoding == REDIS_ENCODING_ZIPLIST);

    // 如果输入是 ZIPLIST ，那么不做动作
    if (enc == REDIS_ENCODING_ZIPLIST) {
        /* Nothing to do... */

    // 转换成 HT 编码
    } else if (enc == REDIS_ENCODING_HT) {

        hashTypeIterator *hi;
        dict *dict;
        int ret;

        // 创建哈希迭代器
        hi = hashTypeInitIterator(o);

        // 创建空白的新字典
        dict = dictCreate(&hashDictType, NULL);

        // 遍历整个 ziplist
        while (hashTypeNext(hi) != REDIS_ERR) {
            robj *field, *value;

            // 取出 ziplist 里的键
            field = hashTypeCurrentObject(hi, REDIS_HASH_KEY);
            field = tryObjectEncoding(field);

            // 取出 ziplist 里的值
            value = hashTypeCurrentObject(hi, REDIS_HASH_VALUE);
            value = tryObjectEncoding(value);

            // 将键值对添加到字典
            ret = dictAdd(dict, field, value);
            if (ret != DICT_OK) {
                redisLogHexDump(REDIS_WARNING,"ziplist with dup elements dump",
                    o->ptr,ziplistBlobLen(o->ptr));
                redisAssert(ret == DICT_OK);
            }
        }

        // 释放 ziplist 的迭代器
        hashTypeReleaseIterator(hi);

        // 释放对象原来的 ziplist
        zfree(o->ptr);

        // 更新哈希的编码和值对象
        o->encoding = REDIS_ENCODING_HT;
        o->ptr = dict;

    } else {
        redisPanic("Unknown hash encoding");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x55f12
jmp 0x55f34
leaq 0x8d72a(%rip), %rdi     # 0xe3643
leaq 0x8d749(%rip), %rsi     # 0xe3669
movl $0x274, %edx            # imm = 0x274
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
cmpl $0x5, -0xc(%rbp)
jne 0x55f3f
jmp 0x5608f
cmpl $0x2, -0xc(%rbp)
jne 0x5606b
movq -0x8(%rbp), %rdi
callq 0x559a0
movq %rax, -0x18(%rbp)
leaq 0xbca43(%rip), %rdi     # 0x1129a0
xorl %eax, %eax
movl %eax, %esi
callq 0x231a0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x55a90
cmpl $-0x1, %eax
je 0x56036
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x55d90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3acc0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movl $0x2, %esi
callq 0x55d90
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3acc0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x236d0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x56031
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x34000
movq -0x40(%rbp), %rdx
movq %rax, %rcx
movl $0x3, %edi
leaq 0x8d6fa(%rip), %rsi     # 0xe36fa
callq 0x65980
cmpl $0x0, -0x24(%rbp)
jne 0x5600d
jmp 0x5602f
leaq 0x8d705(%rip), %rdi     # 0xe3719
leaq 0x8d64e(%rip), %rsi     # 0xe3669
movl $0x298, %edx            # imm = 0x298
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
jmp 0x56031
jmp 0x55f6a
movq -0x18(%rbp), %rdi
callq 0x55a50
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2e3a0
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff0f, %ecx       # imm = 0xFFFFFF0F
orl $0x20, %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x5608d
leaq 0x8cb09(%rip), %rdi     # 0xe2b7b
leaq 0x8d5f0(%rip), %rsi     # 0xe3669
movl $0x2a7, %edx            # imm = 0x2A7
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x5608f
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)