// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/t_zset.c
// Function: zslInsert
zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj) {
    zskiplistNode *update[ZSKIPLIST_MAXLEVEL], *x;
    unsigned int rank[ZSKIPLIST_MAXLEVEL];
    int i, level;

    serverAssert(!isnan(score));
    x = zsl->header;
    for (i = zsl->level-1; i >= 0; i--) {
        /* store rank that is crossed to reach the insert position */
        rank[i] = i == (zsl->level-1) ? 0 : rank[i+1];
        while (x->level[i].forward &&
            (x->level[i].forward->score < score ||
                (x->level[i].forward->score == score &&
                compareStringObjects(x->level[i].forward->obj,obj) < 0))) {
            rank[i] += x->level[i].span;
            x = x->level[i].forward;
        }
        update[i] = x;
    }
    /* we assume the key is not already inside, since we allow duplicated
     * scores, and the re-insertion of score and redis object should never
     * happen since the caller of zslInsert() should test in the hash table
     * if the element is already inside or not. */
    level = zslRandomLevel();
    if (level > zsl->level) {
        for (i = zsl->level; i < level; i++) {
            rank[i] = 0;
            update[i] = zsl->header;
            update[i]->level[i].span = zsl->length;
        }
        zsl->level = level;
    }
    x = zslCreateNode(level,score,obj);
    for (i = 0; i < level; i++) {
        x->level[i].forward = update[i]->level[i].forward;
        update[i]->level[i].forward = x;

        /* update span covered by update[i] as x is inserted here */
        x->level[i].span = update[i]->level[i].span - (rank[0] - rank[i]);
        update[i]->level[i].span = (rank[0] - rank[i]) + 1;
    }

    /* increment span for untouched levels */
    for (i = level; i < zsl->level; i++) {
        update[i]->level[i].span++;
    }

    x->backward = (update[0] == zsl->header) ? NULL : update[0];
    if (x->level[0].forward)
        x->level[0].forward->backward = x;
    else
        zsl->tail = x;
    zsl->length++;
    return x;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, 0x10(%rsp)
ucomisd %xmm0, %xmm0
jp 0x47b74
movq %rdi, %rbx
movq (%rdi), %r12
movl 0x18(%rdi), %r15d
movsd %xmm0, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
testl %r15d, %r15d
jle 0x47a5c
movl 0x18(%rbx), %eax
xorl %ebp, %ebp
cmpq %rax, %r15
je 0x479f4
movl 0x20(%rsp,%r15,4), %ebp
decq %r15
movl %r15d, %ebx
movq %rbx, %r13
shlq $0x4, %r13
movl %ebp, 0x20(%rsp,%rbx,4)
movq 0x18(%r12,%r13), %rax
testq %rax, %rax
je 0x47a4d
leaq (%r12,%r13), %r14
addq $0x18, %r14
movsd 0x8(%rax), %xmm1
ucomisd %xmm1, %xmm0
ja 0x47a44
ucomisd %xmm0, %xmm1
jne 0x47a4d
jp 0x47a4d
movq (%rax), %rdi
movq 0x10(%rsp), %rsi
callq 0x3a702
movsd 0x8(%rsp), %xmm0
testl %eax, %eax
jns 0x47a4d
movq (%r14), %rax
addl 0x8(%r14), %ebp
movq %rax, %r12
jmp 0x47a01
movq %r12, 0xa0(%rsp,%rbx,8)
movq 0x18(%rsp), %rbx
jmp 0x479e0
callq 0x47990
movsd 0x8(%rsp), %xmm0
movl %eax, %r15d
movslq 0x18(%rbx), %rax
cmpl %eax, %r15d
jle 0x47aa7
movslq %r15d, %rcx
leaq (,%rax,4), %rdx
cmpq %rcx, %rax
jge 0x47aa3
andl $0x0, 0x20(%rsp,%rdx)
movq (%rbx), %rsi
movq %rsi, 0xa0(%rsp,%rdx,2)
movl 0x10(%rbx), %edi
movl %edi, 0x20(%rsi,%rdx,4)
incq %rax
addq $0x4, %rdx
jmp 0x47a7e
movl %r15d, 0x18(%rbx)
movslq %r15d, %r12
movl %r15d, %edi
movq 0x10(%rsp), %rsi
callq 0x478bc
movl 0x20(%rsp), %ecx
leal 0x1(%rcx), %edx
xorl %esi, %esi
testl %r15d, %r15d
cmovlel %esi, %r15d
shlq $0x2, %r15
cmpq %rsi, %r15
je 0x47b0d
movq 0xa0(%rsp,%rsi,2), %rdi
movq 0x18(%rdi,%rsi,4), %r8
movq %r8, 0x18(%rax,%rsi,4)
movq %rax, 0x18(%rdi,%rsi,4)
movl 0x20(%rdi,%rsi,4), %r8d
movl 0x20(%rsp,%rsi), %r9d
subl %ecx, %r8d
addl %r9d, %r8d
movl %r8d, 0x20(%rax,%rsi,4)
movl %edx, %r8d
subl %r9d, %r8d
movl %r8d, 0x20(%rdi,%rsi,4)
addq $0x4, %rsi
jmp 0x47acb
movslq 0x18(%rbx), %rcx
leaq (,%r12,8), %rdx
cmpq %rcx, %r12
jge 0x47b33
movq 0xa0(%rsp,%rdx), %rsi
incl 0x20(%rsi,%rdx,2)
incq %r12
addq $0x8, %rdx
jmp 0x47b19
movq 0xa0(%rsp), %rcx
xorl %edx, %edx
cmpq (%rbx), %rcx
cmovneq %rcx, %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rax), %rcx
leaq 0x8(%rbx), %rdx
leaq 0x10(%rcx), %rsi
testq %rcx, %rcx
cmoveq %rdx, %rsi
movq %rax, (%rsi)
incq 0x10(%rbx)
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6cfc9(%rip), %rdi     # 0xb4b44
leaq 0x6cfd0(%rip), %rsi     # 0xb4b52
pushq $0x73
popq %rdx
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0