// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 $0x198, %rsp            # imm = 0x198
ucomisd %xmm0, %xmm0
jp 0x53847
movq %rsi, %r14
movq %rdi, %rbx
movslq 0x18(%rdi), %r12
testq %r12, %r12
movq %rdi, (%rsp)
movsd %xmm0, 0x8(%rsp)
jle 0x536e2
movq (%rbx), %r15
movq %r12, %r13
movl 0x18(%rbx), %ecx
xorl %eax, %eax
cmpq %rcx, %r12
je 0x53667
movl 0x10(%rsp,%r13,4), %eax
leaq -0x1(%r13), %r12
movl %eax, 0x10(%rsp,%r12,4)
movq %r12, %rbp
shlq $0x4, %rbp
movq 0x18(%r15,%rbp), %rax
testq %rax, %rax
je 0x536cc
leaq (%r15,%rbp), %rbx
addq $0x18, %rbx
movsd 0x8(%rax), %xmm1
ucomisd %xmm1, %xmm0
ja 0x536b1
ucomisd %xmm0, %xmm1
jne 0x536cc
jp 0x536cc
movq (%rax), %rdi
movq %r14, %rsi
callq 0x446ab
movsd 0x8(%rsp), %xmm0
testl %eax, %eax
jns 0x536cc
movl 0x8(%rbx), %eax
addl %eax, 0x10(%rsp,%r12,4)
movq (%rbx), %r15
leaq (%r15,%rbp), %rbx
addq $0x18, %rbx
movq (%rbx), %rax
testq %rax, %rax
jne 0x53689
movq %r15, 0x90(%rsp,%r12,8)
cmpq $0x1, %r13
movq (%rsp), %rbx
jg 0x53655
xorl %r15d, %r15d
callq 0x26a40
incq %r15
testl $0xc000, %eax           # imm = 0xC000
je 0x536e5
cmpl $0x20, %r15d
movl $0x20, %ebp
cmovbl %r15d, %ebp
movslq 0x18(%rbx), %r12
cmpl %r12d, %ebp
jle 0x53760
movq %rbx, %rax
movq (%rbx), %rbx
movl 0x10(%rax), %r13d
leaq (%rsp,%r12,4), %rdi
addq $0x10, %rdi
movl %r12d, %eax
notl %eax
addl %ebp, %eax
leaq 0x4(,%rax,4), %rdx
xorl %esi, %esi
callq 0x26110
movl %ebp, %eax
movq %r12, %rcx
shlq $0x4, %rcx
addq %rbx, %rcx
addq $0x20, %rcx
movq %rbx, 0x90(%rsp,%r12,8)
movl %r13d, (%rcx)
incq %r12
addq $0x10, %rcx
cmpq %rax, %r12
jl 0x53742
movq (%rsp), %rbx
movl %ebp, 0x18(%rbx)
movl %ebp, %edi
shll $0x4, %edi
addl $0x18, %edi
callq 0x3b29d
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movq %r14, (%rax)
movl 0x10(%rsp), %ecx
leal 0x1(%rcx), %edx
cmpq $0x20, %r15
movl $0x20, %esi
cmovbq %r15, %rsi
shll $0x2, %esi
xorl %edi, %edi
movq 0x90(%rsp,%rdi,2), %r8
movq 0x18(%r8,%rdi,4), %r9
movq %r9, 0x18(%rax,%rdi,4)
movq %rax, 0x18(%r8,%rdi,4)
movl 0x20(%r8,%rdi,4), %r9d
movl 0x10(%rsp,%rdi), %r10d
subl %ecx, %r9d
addl %r10d, %r9d
movl %r9d, 0x20(%rax,%rdi,4)
movl %edx, %r9d
subl %r10d, %r9d
movl %r9d, 0x20(%r8,%rdi,4)
addq $0x4, %rdi
cmpq %rdi, %rsi
jne 0x53794
movslq 0x18(%rbx), %rcx
cmpl %ecx, %ebp
jge 0x53806
cmpq $0x20, %r15
movl $0x20, %edx
cmovbq %r15, %rdx
movl %edx, %esi
shll $0x4, %esi
movq 0x90(%rsp,%rdx,8), %rdi
incl 0x20(%rdi,%rsi)
incq %rdx
addq $0x10, %rsi
cmpq %rcx, %rdx
jl 0x537ee
movq 0x90(%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 $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x72dfa(%rip), %rdi     # 0xc6648
leaq 0x72e01(%rip), %rsi     # 0xc6656
movl $0x73, %edx
callq 0x654e1
movl $0x1, %edi
callq 0x263d0