// File: 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
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x220(%rbp)
cmpq $0x0, 0x8(%rax)
jne 0x95f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9d85
cmpl $0x0, -0x2c(%rbp)
jg 0x9602
movl $0x0, -0x4(%rbp)
jmp 0x9d85
movq -0x18(%rbp), %rdx
leaq 0xeb98(%rip), %rsi      # 0x181a5
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0xb510
movq -0x228(%rbp), %rsi
leaq 0xf5a4(%rip), %rdx      # 0x18bd2
leaq -0xb8(%rbp), %rdi
callq 0xb6f0
jmp 0x963c
movq -0x220(%rbp), %rsi
leaq -0x108(%rbp), %rdi
leaq -0x1c(%rbp), %rdx
callq 0x4560
jmp 0x9655
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0xb620
jmp 0x9671
movq -0x28(%rbp), %rdi
callq 0x3610
movb $0x0, -0x12a(%rbp)
testb $0x1, %al
jne 0x9687
jmp 0x96bf
leaq -0x129(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x3670
movq -0x230(%rbp), %rdx
movb $0x1, -0x12a(%rbp)
leaq 0xebcb(%rip), %rsi      # 0x1827a
leaq -0x128(%rbp), %rdi
callq 0x3510
jmp 0x96bd
jmp 0x96da
movq -0x28(%rbp), %rdx
leaq 0xea23(%rip), %rsi      # 0x180ed
leaq -0x128(%rbp), %rdi
callq 0xb510
jmp 0x96d8
jmp 0x96da
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0xb620
jmp 0x96f3
movl -0x2c(%rbp), %eax
movb $0x0, -0x152(%rbp)
movb $0x0, -0x179(%rbp)
cmpl $0x0, %eax
jge 0x9741
leaq -0x151(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x3670
movq -0x238(%rbp), %rdx
movb $0x1, -0x152(%rbp)
leaq 0xeb49(%rip), %rsi      # 0x1827a
leaq -0x150(%rbp), %rdi
callq 0x3510
jmp 0x973f
jmp 0x977f
movq -0x220(%rbp), %rsi
leaq -0x178(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x4560
jmp 0x975a
movb $0x1, -0x179(%rbp)
leaq 0xe98d(%rip), %rsi      # 0x180f5
leaq -0x150(%rbp), %rdi
leaq -0x178(%rbp), %rdx
callq 0xb840
jmp 0x977d
jmp 0x977f
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0xb620
jmp 0x9795
leaq -0x150(%rbp), %rdi
callq 0x3290
testb $0x1, -0x179(%rbp)
jne 0x97ac
jmp 0x97b8
leaq -0x178(%rbp), %rdi
callq 0x3290
testb $0x1, -0x152(%rbp)
jne 0x97c3
jmp 0x97cf
leaq -0x151(%rbp), %rdi
callq 0x3410
leaq -0x78(%rbp), %rdi
callq 0x3290
leaq -0x128(%rbp), %rdi
callq 0x3290
testb $0x1, -0x12a(%rbp)
jne 0x97ef
jmp 0x97fb
leaq -0x129(%rbp), %rdi
callq 0x3410
leaq -0x98(%rbp), %rdi
callq 0x3290
leaq -0x108(%rbp), %rdi
callq 0x3290
leaq -0xb8(%rbp), %rdi
callq 0x3290
leaq -0xd8(%rbp), %rdi
callq 0x3290
movq -0x220(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x248(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3190
movq -0x248(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x11a60
movq %rax, -0x240(%rbp)
jmp 0x9860
movq -0x220(%rbp), %rdi
movq -0x240(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rsi
callq 0x59f0
testb $0x1, %al
jne 0x988a
jmp 0x9a13
movq -0x220(%rbp), %rdi
movq -0x188(%rbp), %rsi
callq 0x59c0
jmp 0x989f
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
movl $0x1, -0x18c(%rbp)
jmp 0x9d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x99eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x99df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x99d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x99b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x99a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x9984
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x996b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x3290
testb $0x1, -0x179(%rbp)
jne 0x9976
jmp 0x9982
leaq -0x178(%rbp), %rdi
callq 0x3290
jmp 0x9984
testb $0x1, -0x152(%rbp)
jne 0x998f
jmp 0x999b
leaq -0x151(%rbp), %rdi
callq 0x3410
leaq -0x78(%rbp), %rdi
callq 0x3290
leaq -0x128(%rbp), %rdi
callq 0x3290
testb $0x1, -0x12a(%rbp)
jne 0x99bb
jmp 0x99c7
leaq -0x129(%rbp), %rdi
callq 0x3410
leaq -0x98(%rbp), %rdi
callq 0x3290
leaq -0x108(%rbp), %rdi
callq 0x3290
leaq -0xb8(%rbp), %rdi
callq 0x3290
leaq -0xd8(%rbp), %rdi
callq 0x3290
jmp 0x9d91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x9d7a
movq -0x188(%rbp), %rax
cmpl $0x2, (%rax)
je 0x9a4a
movq -0x220(%rbp), %rdi
movq -0x188(%rbp), %rsi
callq 0x59c0
jmp 0x9a34
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
movl $0x1, -0x18c(%rbp)
jmp 0x9d6f
movq -0x188(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, -0x19c(%rbp)
movq -0x38(%rbp), %rdi
callq 0xbe70
movl -0x19c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x9a9e
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
movl $0x1, -0x18c(%rbp)
jmp 0x9d6f
movl $0x0, -0x1a0(%rbp)
movl -0x1a0(%rbp), %eax
cmpl -0x19c(%rbp), %eax
jae 0x9c62
movq -0x198(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x1a0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x258(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x260(%rbp)
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x3670
movq -0x260(%rbp), %rsi
movq -0x258(%rbp), %rdx
movq -0x250(%rbp), %rcx
leaq -0x1c0(%rbp), %rdi
callq 0x3450
jmp 0x9b1b
leaq -0x1c1(%rbp), %rdi
callq 0x3410
movq -0x198(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x1a0(%rbp), %ecx
incl %ecx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x270(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x278(%rbp)
leaq -0x1e9(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x3670
movq -0x278(%rbp), %rsi
movq -0x270(%rbp), %rdx
movq -0x268(%rbp), %rcx
leaq -0x1e8(%rbp), %rdi
callq 0x3450
jmp 0x9b8a
leaq -0x1e9(%rbp), %rdi
callq 0x3410
movq -0x38(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0xbe90
movq %rax, -0x280(%rbp)
jmp 0x9baf
movq -0x280(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3050
jmp 0x9bc4
leaq -0x1e8(%rbp), %rdi
callq 0x3290
leaq -0x1c0(%rbp), %rdi
callq 0x3290
movl -0x1a0(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1a0(%rbp)
jmp 0x9aa8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x1c1(%rbp), %rdi
callq 0x3410
jmp 0x9d7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x1e9(%rbp), %rdi
callq 0x3410
jmp 0x9c51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x3290
leaq -0x1c0(%rbp), %rdi
callq 0x3290
jmp 0x9d7a
movl $0xffffffff, -0x1f0(%rbp) # imm = 0xFFFFFFFF
movq -0x188(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x290(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x298(%rbp)
leaq -0x211(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x3670
movq -0x298(%rbp), %rsi
movq -0x290(%rbp), %rdx
movq -0x288(%rbp), %rcx
leaq -0x210(%rbp), %rdi
callq 0x3450
jmp 0x9cc6
leaq -0x211(%rbp), %rdi
callq 0x3410
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0xba20
movl %eax, -0x29c(%rbp)
jmp 0x9ced
movq -0x220(%rbp), %rdi
movl -0x29c(%rbp), %eax
movl %eax, -0x1f0(%rbp)
movq -0x188(%rbp), %rsi
callq 0x59c0
jmp 0x9d0e
movl -0x1f0(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x18c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3290
jmp 0x9d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x211(%rbp), %rdi
callq 0x3410
jmp 0x9d7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3290
jmp 0x9d7a
leaq -0x58(%rbp), %rdi
callq 0x3290
jmp 0x9d85
leaq -0x58(%rbp), %rdi
callq 0x3290
jmp 0x9d91
movl -0x4(%rbp), %eax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x3660
nopl (%rax)