// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/quicklist.c
// Function: quicklistSplitNode
REDIS_STATIC quicklistNode *_quicklistSplitNode(quicklistNode *node, int offset,
                                                int after) {
    size_t zl_sz = node->sz;

    quicklistNode *new_node = quicklistCreateNode();
    new_node->zl = zmalloc(zl_sz);

    /* Copy original ziplist so we can split it */
    memcpy(new_node->zl, node->zl, zl_sz);

    /* -1 here means "continue deleting until the list ends" */
    int orig_start = after ? offset + 1 : 0;
    int orig_extent = after ? -1 : offset;
    int new_start = after ? 0 : offset;
    int new_extent = after ? offset + 1 : -1;

    D("After %d (%d); ranges: [%d, %d], [%d, %d]", after, offset, orig_start,
      orig_extent, new_start, new_extent);

    node->zl = ziplistDeleteRange(node->zl, orig_start, orig_extent);
    node->count = ziplistLen(node->zl);
    quicklistNodeUpdateSz(node);

    new_node->zl = ziplistDeleteRange(new_node->zl, new_start, new_extent);
    new_node->count = ziplistLen(new_node->zl);
    quicklistNodeUpdateSz(new_node);

    D("After split lengths: orig (%d), new (%d)", node->count, new_node->count);
    return new_node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movq %rax, -0x18(%rbp)
callq 0x27820
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3acd0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x26c60
cmpl $0x0, -0x10(%rbp)
je 0x28e84
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x28e8b
xorl %eax, %eax
movl %eax, -0x34(%rbp)
jmp 0x28e8b
movl -0x34(%rbp), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0x28ea1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x38(%rbp)
jmp 0x28ea7
movl -0xc(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0x28eba
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
jmp 0x28ec0
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0x28ed7
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x28ee1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x40(%rbp)
jmp 0x28ee1
movl -0x40(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x415d0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x419c0
movl %eax, %edx
movq -0x8(%rbp), %rax
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), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
callq 0x415d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x419c0
movl %eax, %edx
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %ecx
andl $0xffff, %edx           # imm = 0xFFFF
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
orl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x41a50
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)