// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/quicklist.c
// Function: quicklistInsert
REDIS_STATIC void _quicklistInsert(quicklist *quicklist, quicklistEntry *entry,
                                   void *value, const size_t sz, int after) {
    int full = 0, at_tail = 0, at_head = 0, full_next = 0, full_prev = 0;
    int fill = quicklist->fill;
    quicklistNode *node = entry->node;
    quicklistNode *new_node = NULL;

    if (!node) {
        /* we have no reference node, so let's create only node in the list */
        D("No node given!");
        new_node = quicklistCreateNode();
        new_node->zl = ziplistPush(ziplistNew(), value, sz, ZIPLIST_HEAD);
        __quicklistInsertNode(quicklist, NULL, new_node, after);
        new_node->count++;
        quicklist->count++;
        return;
    }

    /* Populate accounting flags for easier boolean checks later */
    if (!_quicklistNodeAllowInsert(node, fill, sz)) {
        D("Current node is full with count %d with requested fill %lu",
          node->count, fill);
        full = 1;
    }

    if (after && (entry->offset == node->count)) {
        D("At Tail of current ziplist");
        at_tail = 1;
        if (!_quicklistNodeAllowInsert(node->next, fill, sz)) {
            D("Next node is full too.");
            full_next = 1;
        }
    }

    if (!after && (entry->offset == 0)) {
        D("At Head");
        at_head = 1;
        if (!_quicklistNodeAllowInsert(node->prev, fill, sz)) {
            D("Prev node is full too.");
            full_prev = 1;
        }
    }

    /* Now determine where and how to insert the new element */
    if (!full && after) {
        D("Not full, inserting after current position.");
        quicklistDecompressNodeForUse(node);
        unsigned char *next = ziplistNext(node->zl, entry->zi);
        if (next == NULL) {
            node->zl = ziplistPush(node->zl, value, sz, ZIPLIST_TAIL);
        } else {
            node->zl = ziplistInsert(node->zl, next, value, sz);
        }
        node->count++;
        quicklistNodeUpdateSz(node);
        quicklistRecompressOnly(quicklist, node);
    } else if (!full && !after) {
        D("Not full, inserting before current position.");
        quicklistDecompressNodeForUse(node);
        node->zl = ziplistInsert(node->zl, entry->zi, value, sz);
        node->count++;
        quicklistNodeUpdateSz(node);
        quicklistRecompressOnly(quicklist, node);
    } else if (full && at_tail && node->next && !full_next && after) {
        /* If we are: at tail, next has free space, and inserting after:
         *   - insert entry at head of next node. */
        D("Full and tail, but next isn't full; inserting next node head");
        new_node = node->next;
        quicklistDecompressNodeForUse(new_node);
        new_node->zl = ziplistPush(new_node->zl, value, sz, ZIPLIST_HEAD);
        new_node->count++;
        quicklistNodeUpdateSz(new_node);
        quicklistRecompressOnly(quicklist, new_node);
    } else if (full && at_head && node->prev && !full_prev && !after) {
        /* If we are: at head, previous has free space, and inserting before:
         *   - insert entry at tail of previous node. */
        D("Full and head, but prev isn't full, inserting prev node tail");
        new_node = node->prev;
        quicklistDecompressNodeForUse(new_node);
        new_node->zl = ziplistPush(new_node->zl, value, sz, ZIPLIST_TAIL);
        new_node->count++;
        quicklistNodeUpdateSz(new_node);
        quicklistRecompressOnly(quicklist, new_node);
    } else if (full && ((at_tail && node->next && full_next && after) ||
                        (at_head && node->prev && full_prev && !after))) {
        /* If we are: full, and our prev/next is full, then:
         *   - create new node and attach to quicklist */
        D("\tprovisioning new node...");
        new_node = quicklistCreateNode();
        new_node->zl = ziplistPush(ziplistNew(), value, sz, ZIPLIST_HEAD);
        new_node->count++;
        quicklistNodeUpdateSz(new_node);
        __quicklistInsertNode(quicklist, node, new_node, after);
    } else if (full) {
        /* else, node is full we need to split it. */
        /* covers both after and !after cases */
        D("\tsplitting node...");
        quicklistDecompressNodeForUse(node);
        new_node = _quicklistSplitNode(node, entry->offset, after);
        new_node->zl = ziplistPush(new_node->zl, value, sz,
                                   after ? ZIPLIST_HEAD : ZIPLIST_TAIL);
        new_node->count++;
        quicklistNodeUpdateSz(new_node);
        __quicklistInsertNode(quicklist, node, new_node, after);
        _quicklistMergeNodes(quicklist, node);
    }

    quicklist->count++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
shll $0x10, %eax
sarl $0x10, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x29094
callq 0x27820
movq %rax, -0x50(%rbp)
callq 0x40630
movq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x410b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl -0x24(%rbp), %ecx
xorl %eax, %eax
movl %eax, %esi
callq 0x27cf0
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
addl $0x1, %edx
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
jmp 0x29778
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x27f30
cmpl $0x0, %eax
jne 0x290b0
movl $0x1, -0x28(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x290f7
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x48(%rbp), %rcx
movl 0x1c(%rcx), %ecx
andl $0xffff, %ecx           # imm = 0xFFFF
cmpl %ecx, %eax
jne 0x290f7
movl $0x1, -0x2c(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x3c(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x27f30
cmpl $0x0, %eax
jne 0x290f5
movl $0x1, -0x34(%rbp)
jmp 0x290f7
cmpl $0x0, -0x24(%rbp)
jne 0x2912f
movq -0x10(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jne 0x2912f
movl $0x1, -0x30(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rdi
movl -0x3c(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x27f30
cmpl $0x0, %eax
jne 0x2912d
movl $0x1, -0x38(%rbp)
jmp 0x2912f
cmpl $0x0, -0x28(%rbp)
jne 0x2926b
cmpl $0x0, -0x24(%rbp)
je 0x2926b
jmp 0x29145
cmpq $0x0, -0x48(%rbp)
je 0x2917d
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x2917d
movq -0x48(%rbp), %rdi
callq 0x27a80
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0xffefffff, %ecx       # imm = 0xFFEFFFFF
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x1c(%rax)
jmp 0x2917f
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x412e0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x291c8
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
movl $0x1, %ecx
callq 0x410b0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x291ee
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x58(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movl %eax, %ecx
callq 0x41530
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
addl $0x1, %edx
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x2922a
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x14, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x29264
jmp 0x2923e
cmpq $0x0, -0x48(%rbp)
je 0x29260
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0x29260
movq -0x48(%rbp), %rdi
callq 0x27980
jmp 0x29262
jmp 0x29264
jmp 0x29266
jmp 0x29768
cmpl $0x0, -0x28(%rbp)
jne 0x29362
cmpl $0x0, -0x24(%rbp)
jne 0x29362
jmp 0x29281
cmpq $0x0, -0x48(%rbp)
je 0x292b9
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x292b9
movq -0x48(%rbp), %rdi
callq 0x27a80
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0xffefffff, %ecx       # imm = 0xFFEFFFFF
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x1c(%rax)
jmp 0x292bb
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movl %eax, %ecx
callq 0x41530
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
addl $0x1, %edx
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x29321
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x14, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2935b
jmp 0x29335
cmpq $0x0, -0x48(%rbp)
je 0x29357
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0x29357
movq -0x48(%rbp), %rdi
callq 0x27980
jmp 0x29359
jmp 0x2935b
jmp 0x2935d
jmp 0x29766
cmpl $0x0, -0x28(%rbp)
je 0x29480
cmpl $0x0, -0x2c(%rbp)
je 0x29480
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x29480
cmpl $0x0, -0x34(%rbp)
jne 0x29480
cmpl $0x0, -0x24(%rbp)
je 0x29480
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x293dd
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x293dd
movq -0x50(%rbp), %rdi
callq 0x27a80
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0xffefffff, %ecx       # imm = 0xFFEFFFFF
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x1c(%rax)
jmp 0x293df
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x410b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
addl $0x1, %edx
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x2943f
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x14, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x29479
jmp 0x29453
cmpq $0x0, -0x50(%rbp)
je 0x29475
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0x29475
movq -0x50(%rbp), %rdi
callq 0x27980
jmp 0x29477
jmp 0x29479
jmp 0x2947b
jmp 0x29764
cmpl $0x0, -0x28(%rbp)
je 0x2959f
cmpl $0x0, -0x30(%rbp)
je 0x2959f
movq -0x48(%rbp), %rax
cmpq $0x0, (%rax)
je 0x2959f
cmpl $0x0, -0x38(%rbp)
jne 0x2959f
cmpl $0x0, -0x24(%rbp)
jne 0x2959f
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x294f9
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x294f9
movq -0x50(%rbp), %rdi
callq 0x27a80
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0xffefffff, %ecx       # imm = 0xFFEFFFFF
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x1c(%rax)
jmp 0x294fb
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
movl $0x1, %ecx
callq 0x410b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
addl $0x1, %edx
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x2955e
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x14, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x29598
jmp 0x29572
cmpq $0x0, -0x50(%rbp)
je 0x29594
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0x29594
movq -0x50(%rbp), %rdi
callq 0x27980
jmp 0x29596
jmp 0x29598
jmp 0x2959a
jmp 0x29762
cmpl $0x0, -0x28(%rbp)
je 0x29672
cmpl $0x0, -0x2c(%rbp)
je 0x295c6
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x295c6
cmpl $0x0, -0x34(%rbp)
je 0x295c6
cmpl $0x0, -0x24(%rbp)
jne 0x295f2
cmpl $0x0, -0x30(%rbp)
je 0x29672
movq -0x48(%rbp), %rax
cmpq $0x0, (%rax)
je 0x29672
cmpl $0x0, -0x38(%rbp)
je 0x29672
cmpl $0x0, -0x24(%rbp)
jne 0x29672
callq 0x27820
movq %rax, -0x50(%rbp)
callq 0x40630
movq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x410b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
addl $0x1, %edx
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x27cf0
jmp 0x29760
cmpl $0x0, -0x28(%rbp)
je 0x2975e
jmp 0x2967e
cmpq $0x0, -0x48(%rbp)
je 0x296b6
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %eax
shrl $0x10, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x296b6
movq -0x48(%rbp), %rdi
callq 0x27a80
movq -0x48(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0xffefffff, %ecx       # imm = 0xFFEFFFFF
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x1c(%rax)
jmp 0x296b8
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %esi
movl -0x24(%rbp), %edx
callq 0x28e20
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
movl -0x24(%rbp), %r8d
movl $0x1, %ecx
xorl %eax, %eax
cmpl $0x0, %r8d
cmovnel %eax, %ecx
callq 0x410b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %edx
andl $0xffff, %edx           # imm = 0xFFFF
addl $0x1, %edx
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x27cf0
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x28c80
jmp 0x29760
jmp 0x29762
jmp 0x29764
jmp 0x29766
jmp 0x29768
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
addq $0x60, %rsp
popq %rbp
retq
nop