// File: /workspace/github_cpp_makefile_star2_O3/Sherhang[P]redis-for-cpp/credis.cpp
// Function: Redis::hscan(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
int32_t Redis::hscan(const std::string& key, int32_t cursor, const std::string& pattern, int32_t count, std::map<std::string, std::string>& key_value)
{
    
     if(_context==NULL)
    {
        //DEBUG<<"NULL"<<std::endl;
        return -1;
    }
    
    if (count <= 0)
    {
        // DEBUG
        return 0;
    }
    std::string cmd = "HSCAN " + key + " " + num2str<int32_t>(cursor)
                    + (pattern.empty() ? "" : (" MATCH " + pattern))
                    + (count < 0 ? "" : " COUNT " + num2str<int32_t>(count));
    
    redisReply* _reply = (redisReply*)::redisCommand(_context, cmd.c_str());
    if(isError(_reply))
    {
        //DEBUG<<"isError"<<std::endl;
        freeReply(_reply);
        return -2;
    }
    //DEBUG<<"_reply->type "<<_reply->type<<std::endl;
    if(_reply->type != REDIS_REPLY_ARRAY)
    {
        //DEBUG<<"not array"<<std::endl;
        freeReply(_reply);
        return -3;
    }
    redisReply* sub_reply = (_reply->element[1]);
    uint32_t len = sub_reply->elements;
    key_value.clear();
    if(len & 0x01)
    {
        //DEBUG<<"return not match"<<std::endl;
        return -4;
    }
    for(uint32_t i=0;i<len;i=i+2)
    {
        std::string key(sub_reply->element[i]->str, sub_reply->element[i]->len);
        std::string val(sub_reply->element[i+1]->str, sub_reply->element[i+1]->len);
        key_value[key] = val;
    }
    int32_t ret = -1;
    std::string strTemp(_reply->element[0]->str, _reply->element[0]->len);
    ret = str2num<int32_t>(strTemp);
    freeReply(_reply);
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %r9, 0x78(%rsp)
movl %edx, 0x54(%rsp)
movl %r8d, 0x2c(%rsp)
cmpq $0x0, 0x8(%rdi)
je 0x9b0c
testl %r8d, %r8d
jle 0x9b16
movq %rcx, %r15
movq %rsi, %rax
movq %rdi, %r13
leaq 0xa73b(%rip), %rsi      # 0x141f4
leaq 0x128(%rsp), %r12
movq %r12, %rdi
movq %rax, %rdx
callq 0xa64c
leaq 0xb11f(%rip), %rsi      # 0x14bf2
movq %r12, %rdi
callq 0x3600
leaq 0xd0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9b1d
movq %rdx, 0xc0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xd0(%rsp)
jmp 0x9b25
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xa094
xorl %ebp, %ebp
jmp 0xa094
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0xc8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xe8(%rsp), %rdi
leaq 0x54(%rsp), %rdx
movq %r13, %rsi
callq 0x41be
movq 0xc0(%rsp), %rcx
movq 0xc8(%rsp), %r8
movq 0xf0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r12, %rcx
je 0x9b83
movq 0xd0(%rsp), %rdi
movq 0xe8(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x9baf
leaq 0xf8(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x9baa
movq 0xf8(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x9bbe
leaq 0xc0(%rsp), %rdi
callq 0x3110
jmp 0x9bcf
leaq 0xe8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33e0
leaq 0x40(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x9bf3
movq %rsi, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x9bf9
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
cmpq $0x0, 0x8(%r15)
je 0x9c36
leaq 0xa4f1(%rip), %rsi      # 0x14115
leaq 0xa0(%rsp), %rdi
movq %r15, %rdx
callq 0xa64c
jmp 0x9c59
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xa659(%rip), %rdx      # 0x142a2
leaq 0xa0(%rsp), %rdi
movq %rdx, %rsi
callq 0x42ba
leaq 0x40(%rsp), %rsi
movq -0x10(%rsi), %rcx
movq -0x8(%rsi), %r8
movq 0xa8(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %rsi, %rcx
je 0x9c81
movq 0x40(%rsp), %rdi
movq 0xa0(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x9cad
leaq 0xb0(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x9ca8
movq 0xb0(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x9cb9
leaq 0x30(%rsp), %rdi
callq 0x3110
jmp 0x9cca
leaq 0xa0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33e0
leaq 0x18(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x9cee
movq %rsi, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x9cf4
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movl 0x2c(%rsp), %ebp
testl %ebp, %ebp
js 0x9d73
leaq 0x108(%rsp), %rdi
leaq 0x2c(%rsp), %rdx
movq %r13, %rsi
callq 0x41be
leaq 0xa3e8(%rip), %rcx      # 0x1411d
leaq 0x108(%rsp), %rdi
movl $0x7, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x33e0
leaq 0x68(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x9d92
movq %rsi, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x9d98
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xa51f(%rip), %rdx      # 0x142a2
leaq 0x58(%rsp), %rdi
movq %rdx, %rsi
callq 0x42ba
jmp 0x9db0
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x60(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x18(%rsp), %rsi
movq -0x10(%rsi), %rcx
movq -0x8(%rsi), %r8
movq 0x60(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %rsi, %rcx
je 0x9dd5
movq 0x18(%rsp), %rdi
movq 0x58(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x9df8
leaq 0x68(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x9df3
movq 0x68(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x9e04
leaq 0x8(%rsp), %rdi
callq 0x3110
jmp 0x9e12
leaq 0x58(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33e0
leaq 0x90(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x9e3f
movq %rsi, 0x80(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x90(%rsp)
jmp 0x9e45
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x88(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9e78
callq 0x3350
testl %ebp, %ebp
js 0x9e92
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9e92
callq 0x3350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9ea6
callq 0x3350
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9ebc
callq 0x3350
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x9ed0
callq 0x3350
leaq 0xf8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9ee6
callq 0x3350
movq 0xc0(%rsp), %rdi
cmpq %r12, %rdi
je 0x9ef8
callq 0x3350
leaq 0x138(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9f0e
callq 0x3350
movq 0x8(%r13), %rdi
movq 0x80(%rsp), %rsi
xorl %eax, %eax
callq 0xe1b0
movq %rax, %r15
testq %rax, %rax
je 0xa06a
cmpl $0x2, (%r15)
jne 0xa071
movq 0x28(%r15), %rax
movq 0x8(%rax), %rbx
movq 0x20(%rbx), %r14
movq 0x78(%rsp), %rdi
callq 0xae64
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
testb $0x1, %r14b
jne 0xa07e
movq %r13, 0xe0(%rsp)
testl %r14d, %r14d
je 0xa014
xorl %ebp, %ebp
leaq 0x8(%rsp), %r12
leaq 0x30(%rsp), %r13
movq 0x28(%rbx), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x42ba
movq 0x28(%rbx), %rax
leal 0x1(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r13, %rdi
callq 0x42ba
movq 0x78(%rsp), %rdi
movq %r12, %rsi
callq 0xab6e
movq %rax, %rdi
movq %r13, %rsi
callq 0x3200
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x9ff4
callq 0x3350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa008
callq 0x3350
addl $0x2, %ebp
cmpl %r14d, %ebp
jb 0x9f79
movq 0x28(%r15), %rax
movq (%rax), %rax
movq 0x18(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
callq 0x42ba
leaq 0x8(%rsp), %rsi
movq 0xe0(%rsp), %rdi
callq 0xa8e4
movl %eax, %ebp
movq %r15, %rdi
callq 0xbb00
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa07e
callq 0x3350
jmp 0xa07e
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
jmp 0xa07e
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
movq %r15, %rdi
callq 0xbb00
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa094
callq 0x3350
movl %ebp, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa177
jmp 0xa17c
jmp 0xa0b9
movq %rax, %rbx
jmp 0xa0d8
movq %rax, %rbx
jmp 0xa0ee
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa0d4
callq 0x3350
testl %ebp, %ebp
js 0xa0ee
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa0ee
callq 0x3350
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa106
callq 0x3350
jmp 0xa106
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa121
callq 0x3350
jmp 0xa121
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa139
callq 0x3350
jmp 0xa139
movq %rax, %rbx
leaq 0xf8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa154
callq 0x3350
jmp 0xa154
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r12, %rdi
je 0xa16b
callq 0x3350
jmp 0xa16b
movq %rax, %rbx
leaq 0x138(%rsp), %rax
jmp 0xa1b4
jmp 0xa177
movq %rax, %rbx
jmp 0xa1ac
movq %rax, %rbx
jmp 0xa198
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xa198
callq 0x3350
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa1ac
callq 0x3350
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa1c2
callq 0x3350
movq %rbx, %rdi
callq 0x35b0