// File: /workspace/github_cpp_makefile_star2_O2/Sherhang[P]redis-for-cpp/credis.cpp
// Function: Redis::zscan(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::zscan(const std::string& key, int32_t cursor, const std::string& pattern, int32_t count, std::map<std::string, std::string>& score_member)
{
    
     if(_context==NULL)
    {
        //DEBUG<<"NULL"<<std::endl;
        return -1;
    }
    
    if (count <= 0)
    {
        // DEBUG
        return 0;
    }
    std::string cmd = "ZSCAN " + 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;
    score_member.clear();
    if(len & 0x01)
    {
        //DEBUG<<"return not match"<<std::endl;
        return -4;
    }
    for(uint32_t i=0;i<len;i=i+2)
    {
        std::string mem(sub_reply->element[i]->str, sub_reply->element[i]->len);
        std::string sco(sub_reply->element[i+1]->str, sub_reply->element[i+1]->len);
        score_member[sco] = mem;
    }
    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, 0x30(%rsp)
movl %edx, 0xc(%rsp)
movl %r8d, 0x8(%rsp)
cmpq $0x0, 0x8(%rdi)
je 0x67f2
testl %r8d, %r8d
jle 0x67fa
movq %rcx, %r15
movq %rsi, %rax
movq %rdi, %rbx
leaq 0xaa2e(%rip), %rsi      # 0x111a5
leaq 0x128(%rsp), %r12
movq %r12, %rdi
movq %rax, %rdx
callq 0x7822
leaq 0xb461(%rip), %rdx      # 0x11bf2
leaq 0xe8(%rsp), %rdi
movq %r12, %rsi
callq 0x78ff
leaq 0xc8(%rsp), %rdi
leaq 0xc(%rsp), %rdx
movq %rbx, %rsi
callq 0x3de4
leaq 0x48(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
callq 0x7898
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x6801
leaq 0xa90d(%rip), %rsi      # 0x110ed
leaq 0xa8(%rsp), %rdi
movq %r15, %rdx
callq 0x7822
jmp 0x681a
pushq $-0x1
popq %rbx
jmp 0x6a14
xorl %ebx, %ebx
jmp 0x6a14
leaq 0xaa9c(%rip), %rsi      # 0x112a4
leaq 0xa8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3140
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x7898
movl 0x8(%rsp), %ebp
testl %ebp, %ebp
js 0x6866
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %rbx, %rsi
callq 0x3de4
leaq 0xa8a3(%rip), %rsi      # 0x110f5
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x7994
jmp 0x687f
leaq 0xaa37(%rip), %rsi      # 0x112a4
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x3140
leaq 0x108(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x7898
leaq 0x88(%rsp), %rdi
callq 0x3180
testl %ebp, %ebp
js 0x68b4
leaq 0x68(%rsp), %rdi
callq 0x3180
leaq 0x10(%rsp), %rdi
callq 0x3180
leaq 0xa8(%rsp), %rdi
callq 0x3180
testq %r12, %r12
leaq 0x48(%rsp), %rdi
callq 0x3180
leaq 0xc8(%rsp), %rdi
callq 0x3180
leaq 0xe8(%rsp), %rdi
callq 0x3180
leaq 0x128(%rsp), %rdi
callq 0x3180
movq 0x8(%rbx), %rdi
movq 0x108(%rsp), %rsi
xorl %eax, %eax
callq 0xb190
movq %rax, %r14
testq %rax, %rax
je 0x69ed
cmpl $0x2, (%r14)
jne 0x69f8
movq 0x28(%r14), %rax
movq 0x8(%rax), %rbp
movq 0x20(%rbp), %r15
movq 0x30(%rsp), %rdi
callq 0x7f24
testb $0x1, %r15b
jne 0x6a04
movq %r14, 0x40(%rsp)
movq %rbx, 0x38(%rsp)
pushq $0x1
popq %r14
leaq 0x58(%rsp), %rbx
leaq 0x10(%rsp), %r12
leaq 0x48(%rsp), %r13
leal -0x1(%r14), %eax
cmpl %r15d, %eax
jae 0x6a28
movq 0x28(%rbp), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
movq 0x18(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r12, %rdi
callq 0x7cd0
movq 0x28(%rbp), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
movq %rbx, 0x48(%rsp)
movq %r13, %rdi
callq 0x7cd0
movq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x7c32
movq %rax, %rdi
movq %r12, %rsi
callq 0x31e0
movq %r13, %rdi
callq 0x3180
movq %r12, %rdi
callq 0x3180
addl $0x2, %r14d
jmp 0x6965
xorl %esi, %esi
callq 0x43f8
pushq $-0x2
jmp 0x6a06
movq %r14, %rdi
callq 0x8ae0
pushq $-0x3
jmp 0x6a06
pushq $-0x4
popq %rbx
leaq 0x108(%rsp), %rdi
callq 0x3180
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rsp), %r14
movq 0x28(%r14), %rax
movq (%rax), %rax
movq 0x18(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, (%rdi)
callq 0x7cd0
leaq 0x10(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x7a78
movl %eax, %ebx
movq %r14, %rdi
callq 0x8ae0
leaq 0x10(%rsp), %rdi
callq 0x3180
jmp 0x6a07
jmp 0x6b0d
jmp 0x6b12
jmp 0x6a87
movq %rax, %rbx
jmp 0x6aa0
movq %rax, %rbx
jmp 0x6aaa
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x3180
testl %ebp, %ebp
js 0x6aaa
leaq 0x68(%rsp), %rdi
callq 0x3180
leaq 0x10(%rsp), %rdi
callq 0x3180
jmp 0x6ab9
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x3180
jmp 0x6acb
movq %rax, %rbx
testq %r12, %r12
leaq 0x48(%rsp), %rdi
callq 0x3180
leaq 0xc8(%rsp), %rdi
callq 0x3180
leaq 0xe8(%rsp), %rdi
callq 0x3180
leaq 0x128(%rsp), %rdi
jmp 0x6b36
movq %rax, %rbx
jmp 0x6ad8
movq %rax, %rbx
jmp 0x6ae5
movq %rax, %rbx
jmp 0x6af2
jmp 0x6b0d
movq %rax, %rbx
jmp 0x6b2e
movq %rax, %rbx
jmp 0x6b24
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3180
leaq 0x10(%rsp), %rdi
callq 0x3180
leaq 0x108(%rsp), %rdi
callq 0x3180
movq %rbx, %rdi
callq 0x35a0
nop