// File: /workspace/github_cpp_makefile_star2_O2/helayzhang[P]sorted_set/example.cc
// Function: main
int main()
{
    unsigned long rank;
    double score;
    SortedSet<int> sortedSet;
    sortedSet.zadd(300001, 300);
    sortedSet.zadd(300002, 299.9);
    sortedSet.zadd(300003, 100000);

    std::vector< std::pair<int, double> > result;

    sortedSet.zrange_withscores(0, -1, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    sortedSet.zadd(300004, 40);
    sortedSet.zrange_withscores(0, -1, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    sortedSet.zadd(300005, 40);
    sortedSet.zrange_withscores(0, -1, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    std::cout << sortedSet.zcount(40, 300, true, true) << std::endl;
    std::cout << std::endl;

    sortedSet.zrem(300005);
    sortedSet.zrange_withscores(0, -1, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    sortedSet.zincrby(300004, 500);
    sortedSet.zrange_withscores(0, -1, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    if (sortedSet.zscore(300003, score))
        std::cout << score << std::endl;
    else 
        std::cout << "nil" << std::endl;
    std::cout << std::endl;

    if (sortedSet.zrank(300002, rank)) 
        std::cout << rank << std::endl;
    else 
        std::cout << "nil" << std::endl;
    if (sortedSet.zrevrank(300002, rank)) 
        std::cout << rank << std::endl;
    else 
        std::cout << "nil" << std::endl;
    std::cout << std::endl;

    sortedSet.zrevrange_withscores(0, 1, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    sortedSet.zrangebyscore_withscores(300, 1000, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    sortedSet.zremrangebyrank(1, 2);
    sortedSet.zrange_withscores(0, -1, result);
    std::for_each(result.begin(), result.end(), echo_ranking);
    std::cout << std::endl;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x80, %rsp
leaq -0x88(%rbp), %rbx
movq %rbx, %rdi
callq 0x1776
movsd 0x1cc7(%rip), %xmm0     # 0x3008
movq %rbx, %rdi
movl $0x493e1, %esi          # imm = 0x493E1
callq 0x17f0
leaq -0x88(%rbp), %rdi
movsd 0x1cb3(%rip), %xmm0     # 0x3010
movl $0x493e2, %esi          # imm = 0x493E2
callq 0x17f0
leaq -0x88(%rbp), %rdi
movsd 0x1ca2(%rip), %xmm0     # 0x3018
movl $0x493e3, %esi          # imm = 0x493E3
callq 0x17f0
xorps %xmm0, %xmm0
leaq -0x30(%rbp), %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
leaq -0x88(%rbp), %rdi
pushq $-0x1
popq %rdx
xorl %esi, %esi
callq 0x17fc
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x13bb
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x13a8
movq 0x4c0e(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
movsd 0x1c4a(%rip), %xmm0     # 0x3020
movl $0x493e4, %esi          # imm = 0x493E4
callq 0x17f0
leaq -0x88(%rbp), %rdi
pushq $-0x1
popq %rdx
leaq -0x30(%rbp), %rcx
xorl %esi, %esi
callq 0x17fc
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x1410
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x13fd
movq 0x4bb9(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
movsd 0x1bf5(%rip), %xmm0     # 0x3020
movl $0x493e5, %esi          # imm = 0x493E5
callq 0x17f0
leaq -0x88(%rbp), %rdi
pushq $-0x1
popq %rdx
leaq -0x30(%rbp), %rcx
xorl %esi, %esi
callq 0x17fc
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x1465
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x1452
movq 0x4b64(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
movsd 0x1ba0(%rip), %xmm0     # 0x3020
movsd 0x1b80(%rip), %xmm1     # 0x3008
pushq $0x1
popq %rdx
movl %edx, %esi
callq 0x180c
movq 0x4b37(%rip), %rdi      # 0x5fd0
movq %rax, %rsi
callq 0x10c0
movq %rax, %rdi
callq 0x1070
movq 0x4b20(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
movl $0x493e5, %esi          # imm = 0x493E5
callq 0x1892
leaq -0x88(%rbp), %rdi
pushq $-0x1
popq %rdx
leaq -0x30(%rbp), %rcx
xorl %esi, %esi
callq 0x17fc
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x14f6
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x14e3
movq 0x4ad3(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
movsd 0x1b17(%rip), %xmm0     # 0x3028
movl $0x493e4, %esi          # imm = 0x493E4
callq 0x18fa
leaq -0x88(%rbp), %rdi
pushq $-0x1
popq %rdx
leaq -0x30(%rbp), %rcx
xorl %esi, %esi
callq 0x17fc
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x154b
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x1538
movq 0x4a7e(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rdx
movl $0x493e3, %esi          # imm = 0x493E3
callq 0x190a
testb %al, %al
je 0x1589
movsd -0x90(%rbp), %xmm0
movq 0x4a4e(%rip), %rdi      # 0x5fd0
callq 0x1150
jmp 0x159c
movq 0x4a40(%rip), %rdi      # 0x5fd0
leaq 0x1ab3(%rip), %rsi      # 0x304a
callq 0x1100
movq %rax, %rdi
callq 0x1070
movq 0x4a25(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl $0x493e2, %esi          # imm = 0x493E2
callq 0x1956
testb %al, %al
je 0x15db
movq -0x38(%rbp), %rsi
movq 0x49fc(%rip), %rdi      # 0x5fd0
callq 0x10c0
jmp 0x15ee
movq 0x49ee(%rip), %rdi      # 0x5fd0
leaq 0x1a61(%rip), %rsi      # 0x304a
callq 0x1100
movq %rax, %rdi
callq 0x1070
leaq -0x88(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl $0x493e2, %esi          # imm = 0x493E2
callq 0x1966
testb %al, %al
je 0x1621
movq -0x38(%rbp), %rsi
movq 0x49b6(%rip), %rdi      # 0x5fd0
callq 0x10c0
jmp 0x1634
movq 0x49a8(%rip), %rdi      # 0x5fd0
leaq 0x1a1b(%rip), %rsi      # 0x304a
callq 0x1100
movq %rax, %rdi
callq 0x1070
movq 0x498d(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
pushq $0x1
popq %rdx
leaq -0x30(%rbp), %rcx
xorl %esi, %esi
callq 0x1978
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x1678
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x1665
movq 0x4951(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
movsd 0x1975(%rip), %xmm0     # 0x3008
movsd 0x1995(%rip), %xmm1     # 0x3030
leaq -0x30(%rbp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x198a
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x16c3
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x16b0
movq 0x4906(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x88(%rbp), %rdi
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
callq 0x199e
leaq -0x88(%rbp), %rdi
pushq $-0x1
popq %rdx
leaq -0x30(%rbp), %rcx
xorl %esi, %esi
callq 0x17fc
movq -0x30(%rbp), %rbx
movq -0x28(%rbp), %r14
cmpq %r14, %rbx
je 0x1711
movq %rbx, %rdi
callq 0x12cc
addq $0x10, %rbx
jmp 0x16fe
movq 0x48b8(%rip), %rdi      # 0x5fd0
callq 0x1070
leaq -0x30(%rbp), %rdi
callq 0x2452
leaq -0x88(%rbp), %rdi
callq 0x19f0
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
jmp 0x1761
jmp 0x1755
jmp 0x1755
jmp 0x1755
jmp 0x1755
jmp 0x1755
jmp 0x1755
jmp 0x1755
jmp 0x1755
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x2452
leaq -0x88(%rbp), %rdi
callq 0x19f0
movq %rbx, %rdi
callq 0x1180
nop