// File: /workspace/github_c_makefile_star2_O1/meaning-matters[P]Except/Except.c
// Function: ExceptFinally
int ExceptFinally(
    Context *   pC)             /* pointer to thread exception context */
{
    Except *    pEx;
    Except      ex;

    if (pC == NULL)
        pC = ExceptGetContext(NULL);

    ex = *(pEx = LifoPop(pC->exStack));
    free(pEx);
    pC->pEx = LifoCount(pC->exStack) ? LifoPeek(pC->exStack, 1) : NULL;

    if (LifoCount(pC->exStack) == 0)
    {
        /* outermost level - default action */

        int     restored = ExceptRestoreHandlers(pC);

        if (ex.state == PENDING)
        {
            if (ex.class == FailedAssertion)
            {
                AssertAction(pC, DO_ABORT, ex.pData, ex.file, ex.line);
            }
            else if (ExceptIsDerived(ex.class, RuntimeException) && restored)
            {
                LifoDestroy(pC->exStack);
                if (MULTI_THREADING)
                {
                    EXCEPT_THREAD_MUTEX_FUNC(1);
                    free(HashRemove(pContextHash, EXCEPT_THREAD_ID_FUNC()));
                    EXCEPT_THREAD_MUTEX_FUNC(0);
                }
                else
                {
                    pC->exStack = NULL;
                }
             
                raise(ex.class->signalNumber);
            }
            else if (ex.class == ReturnEvent)
            {
                LifoDestroy(pC->exStack);
                if (MULTI_THREADING)
                {
                    EXCEPT_THREAD_MUTEX_FUNC(1);
                    free(HashRemove(pContextHash, EXCEPT_THREAD_ID_FUNC()));
                    EXCEPT_THREAD_MUTEX_FUNC(0);
                }
                else
                {
                    pC->exStack = NULL;
                }
                
                LONGJMP(*(JMP_BUF *)ex.pData, 1);
            }
            else
                fprintf(stderr, "%s lost: file \"%s\", line %d.\n",
                        ex.class->name, ex.file, ex.line);
        }
        LifoDestroy(pC->exStack);
        if (MULTI_THREADING)
        {
            EXCEPT_THREAD_MUTEX_FUNC(1);
            free(HashRemove(pContextHash, EXCEPT_THREAD_ID_FUNC()));
            EXCEPT_THREAD_MUTEX_FUNC(0);
        }
        else
        {
            pC->exStack = NULL;
        }
    }
    else     
    {
        /* inner level - propagate */

        if (ex.state == PENDING)
        {
            if (ex.class == ReturnEvent && ex.first)
            {            
                LONGJMP(*(JMP_BUF *)ex.pData, 1);    /* pData is returnBuf */
            }
            else
            {
                ExceptThrow(pC, ex.class, ex.pData, ex.file, ex.line);
            }
        }
    }
            
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x1ced
xorl %edi, %edi
callq 0x16ae
movq %rax, %rbx
movq 0x8(%rbx), %rdi
callq 0x223d
movl 0x4(%rax), %r13d
movq 0x198(%rax), %r15
movq 0x1a0(%rax), %rcx
movq %rcx, (%rsp)
movq 0x1a8(%rax), %r12
movl 0x1b0(%rax), %ebp
movl 0x1bc(%rax), %r14d
movq %rax, %rdi
callq 0x1040
movq 0x8(%rbx), %rdi
callq 0x2434
testl %eax, %eax
je 0x1d45
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0x2307
jmp 0x1d47
xorl %eax, %eax
movq %rax, (%rbx)
movq 0x8(%rbx), %rdi
callq 0x2434
testl %eax, %eax
je 0x1d90
cmpl $0x1, %r13d
jne 0x1e66
leaq 0x5498(%rip), %rax      # 0x7200
cmpq %rax, %r15
jne 0x1d76
testl %r14d, %r14d
jne 0x1edf
movq %rbx, %rdi
movq %r15, %rsi
movq (%rsp), %rdx
movq %r12, %rcx
movl %ebp, %r8d
callq 0x1a8d
jmp 0x1e66
callq 0x187c
cmpl $0x1, %r13d
jne 0x1e2e
leaq 0x537a(%rip), %rcx      # 0x7120
cmpq %rcx, %r15
je 0x1e1a
leaq 0x538e(%rip), %rcx      # 0x7140
movq %r15, %rsi
movq %rsi, %rdx
cmpq %rcx, %rsi
je 0x1dc6
movq 0x8(%rdx), %rsi
testq %rsi, %rsi
jne 0x1db5
cmpq %rcx, %rdx
jne 0x1e77
testl %eax, %eax
je 0x1e77
movq 0x8(%rbx), %rdi
callq 0x2124
movl $0x1, %edi
callq 0x16fd
movq 0x5447(%rip), %r14      # 0x7238
callq 0x10f0
movq %r14, %rdi
movl %eax, %esi
callq 0x2826
movq %rax, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x16fd
movl 0x18(%r15), %edi
callq 0x1030
jmp 0x1e2e
movq %rbx, %rdi
xorl %esi, %esi
movq (%rsp), %rdx
movq %r12, %rcx
movl %ebp, %r8d
callq 0x2468
movq 0x8(%rbx), %rdi
callq 0x2124
movl $0x1, %edi
callq 0x16fd
movq 0x53f0(%rip), %rbx      # 0x7238
callq 0x10f0
movq %rbx, %rdi
movl %eax, %esi
callq 0x2826
movq %rax, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x16fd
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5382(%rip), %rax      # 0x7200
cmpq %rax, %r15
je 0x1ea7
movq 0x516e(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movq 0x10(%r15), %rdx
leaq 0x2267(%rip), %rsi      # 0x40ff
movq %r12, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x10a0
jmp 0x1e2e
movq 0x8(%rbx), %rdi
callq 0x2124
movl $0x1, %edi
callq 0x16fd
movq 0x5377(%rip), %rbx      # 0x7238
callq 0x10f0
movq %rbx, %rdi
movl %eax, %esi
callq 0x2826
movq %rax, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x16fd
movq (%rsp), %rdi
movl $0x1, %esi
callq 0x1070