// File: /workspace/github_c_makefile_star2_O0/meaning-matters[P]Except/List.c
// Function: ListSplitAfter
List * ListSplitAfter(
        List *      pListOrg)       /* pointer to original list */
    {
        List *      pListNew;
        ListNode *  pNodeOrg;

        assert(pListOrg != NULL);
        validate(pListOrg->count > 0, NULL);
        validate(pListOrg->pNodeLast != NULL, NULL);

        pListNew = malloc(sizeof(List));

        pListNew->pHead = malloc(sizeof(ListNode));
        pListNew->pHead->pData = NULL;
        pListNew->count = 0;

        pNodeOrg = pListOrg->pNodeLast->pNext;
        while (pNodeOrg != pListOrg->pHead)
        {
            pListOrg->count--;
            pListNew->count++;

            pNodeOrg = pNodeOrg->pNext;
        }

        if (pListNew->count == 0)
        {
            pListNew->pHead->pPrev = pListNew->pHead->pNext = pListNew->pHead;
        }
        else
        {
            /* connect list part to new list */
            pListNew->pHead->pNext = pListOrg->pNodeLast->pNext;
            pListNew->pHead->pNext->pPrev = pListNew->pHead;
            pListNew->pHead->pPrev = pListOrg->pHead->pPrev;
            pListNew->pHead->pPrev->pNext = pListNew->pHead;

            /* bind last accessed node and original dummy node together */
            pListOrg->pNodeLast->pNext = pListOrg->pHead;
            pListOrg->pHead->pPrev = pListOrg->pNodeLast;
        }

        pListNew->pNodeLast = NULL;

        return pListNew;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4825
jmp 0x484a
leaq 0x3a04(%rip), %rax      # 0x8230
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xbdf(%rip), %rdx       # 0x5417
leaq 0xb8b(%rip), %rcx       # 0x53ca
movl $0x333, %r8d            # imm = 0x333
callq 0x2d10
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x4859
jmp 0x490d
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x4865
jmp 0x488a
leaq 0x39c4(%rip), %rax      # 0x8230
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xbb0(%rip), %rdx       # 0x5428
leaq 0xb4b(%rip), %rcx       # 0x53ca
movl $0x334, %r8d            # imm = 0x334
callq 0x2d10
leaq 0x399f(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x17b0
cmpl $-0x1, %eax
je 0x4900
movl $0xc8, %edi
callq 0x10d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x3975(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x1810
movq -0x38(%rbp), %rcx
movq (%rax), %rax
movq %rcx, 0x1a0(%rax)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
cmpl $0x0, %eax
jne 0x48f5
leaq 0x3945(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x2470
jmp 0x48fe
movq -0x28(%rbp), %rdi
callq 0x1040
jmp 0x4900
movq $0x0, -0x8(%rbp)
jmp 0x4b07
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x491d
jmp 0x49d2
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x492a
jmp 0x494f
leaq 0x38ff(%rip), %rax      # 0x8230
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xaff(%rip), %rdx       # 0x543c
leaq 0xa86(%rip), %rcx       # 0x53ca
movl $0x335, %r8d            # imm = 0x335
callq 0x2d10
leaq 0x38da(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x17b0
cmpl $-0x1, %eax
je 0x49c5
movl $0xc8, %edi
callq 0x10d0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x38b0(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x1810
movq -0x40(%rbp), %rcx
movq (%rax), %rax
movq %rcx, 0x1a0(%rax)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x1130
cmpl $0x0, %eax
jne 0x49ba
leaq 0x3880(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x2470
jmp 0x49c3
movq -0x30(%rbp), %rdi
callq 0x1040
jmp 0x49c5
movq $0x0, -0x8(%rbp)
jmp 0x4b07
movl $0x18, %edi
callq 0x10d0
movq %rax, -0x18(%rbp)
movl $0x18, %edi
callq 0x10d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x10(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
je 0x4a51
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4a1d
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x4a79
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x4af3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)