// File: /workspace/github_c_makefile_star2_O0/meaning-matters[P]Except/List.c
// Function: ListSplitBefore
List * ListSplitBefore(
        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->pHead->pNext;
        while (pNodeOrg != pListOrg->pNodeLast)
        {
            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->pHead->pNext;
            pListNew->pHead->pNext->pPrev = pListNew->pHead;
            pListNew->pHead->pPrev = pListOrg->pNodeLast->pPrev;
            pListNew->pHead->pPrev->pNext = pListNew->pHead;

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

        pListNew->pNodeLast = NULL;

        return pListNew;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4515
jmp 0x453a
leaq 0x3d14(%rip), %rax      # 0x8230
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xeef(%rip), %rdx       # 0x5417
leaq 0xe9b(%rip), %rcx       # 0x53ca
movl $0x2ed, %r8d            # imm = 0x2ED
callq 0x2d10
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x4549
jmp 0x45fd
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x4555
jmp 0x457a
leaq 0x3cd4(%rip), %rax      # 0x8230
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xec0(%rip), %rdx       # 0x5428
leaq 0xe5b(%rip), %rcx       # 0x53ca
movl $0x2ee, %r8d            # imm = 0x2EE
callq 0x2d10
leaq 0x3caf(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x17b0
cmpl $-0x1, %eax
je 0x45f0
movl $0xc8, %edi
callq 0x10d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x3c85(%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 0x45e5
leaq 0x3c55(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x2470
jmp 0x45ee
movq -0x28(%rbp), %rdi
callq 0x1040
jmp 0x45f0
movq $0x0, -0x8(%rbp)
jmp 0x47f7
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x460d
jmp 0x46c2
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x461a
jmp 0x463f
leaq 0x3c0f(%rip), %rax      # 0x8230
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xe0f(%rip), %rdx       # 0x543c
leaq 0xd96(%rip), %rcx       # 0x53ca
movl $0x2ef, %r8d            # imm = 0x2EF
callq 0x2d10
leaq 0x3bea(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x17b0
cmpl $-0x1, %eax
je 0x46b5
movl $0xc8, %edi
callq 0x10d0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x3bc0(%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 0x46aa
leaq 0x3b90(%rip), %rax      # 0x8230
movq (%rax), %rdi
callq 0x2470
jmp 0x46b3
movq -0x30(%rbp), %rdi
callq 0x1040
jmp 0x46b5
movq $0x0, -0x8(%rbp)
jmp 0x47f7
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 (%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x4741
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 0x470c
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x4769
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 0x47e3
movq -0x10(%rbp), %rax
movq (%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 0x8(%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 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%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)