// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x21f3
xorl %eax, %eax
movl %eax, %edi
callq 0x1810
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2990
movq %rax, %rsi
movq %rsi, -0x10(%rbp)
leaq -0x208(%rbp), %rdi
movl $0x1f8, %edx            # imm = 0x1F8
callq 0x10b0
movq -0x10(%rbp), %rdi
callq 0x1040
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2cc0
cmpl $0x0, %eax
je 0x224e
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x2ac0
movq %rax, -0x218(%rbp)
jmp 0x2259
xorl %eax, %eax
movq %rax, -0x218(%rbp)
jmp 0x2259
movq -0x218(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2cc0
cmpl $0x0, %eax
jne 0x2411
movq -0x8(%rbp), %rdi
callq 0x1ad0
movl %eax, -0x20c(%rbp)
cmpl $0x1, -0x204(%rbp)
jne 0x23c8
leaq 0x5e80(%rip), %rax      # 0x8120
cmpq %rax, -0x70(%rbp)
jne 0x22c2
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl -0x58(%rbp), %r8d
xorl %esi, %esi
callq 0x2d10
jmp 0x23c6
movq -0x70(%rbp), %rdi
leaq 0x5e73(%rip), %rsi      # 0x8140
callq 0x2170
cmpl $0x0, %eax
je 0x2338
cmpl $0x0, -0x20c(%rbp)
je 0x2338
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x27f0
movl $0x1, %edi
callq 0x1870
movq 0x5f3a(%rip), %rax      # 0x8238
movq %rax, -0x220(%rbp)
callq 0x1100
movq -0x220(%rbp), %rdi
movl %eax, %esi
callq 0x32f0
movq %rax, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1870
movq -0x70(%rbp), %rax
movl 0x18(%rax), %edi
callq 0x1030
jmp 0x23c4
leaq 0x5ec1(%rip), %rax      # 0x8200
cmpq %rax, -0x70(%rbp)
jne 0x239a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x27f0
movl $0x1, %edi
callq 0x1870
movq 0x5ed5(%rip), %rax      # 0x8238
movq %rax, -0x228(%rbp)
callq 0x1100
movq -0x228(%rbp), %rdi
movl %eax, %esi
callq 0x32f0
movq %rax, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1870
movq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x1070
movq 0x5c57(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x60(%rbp), %rcx
movl -0x58(%rbp), %r8d
leaq 0x2d64(%rip), %rsi      # 0x511f
movb $0x0, %al
callq 0x10a0
jmp 0x23c4
jmp 0x23c6
jmp 0x23c8
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x27f0
movl $0x1, %edi
callq 0x1870
movq 0x5e52(%rip), %rax      # 0x8238
movq %rax, -0x230(%rbp)
callq 0x1100
movq -0x230(%rbp), %rdi
movl %eax, %esi
callq 0x32f0
movq %rax, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1870
jmp 0x2458
cmpl $0x1, -0x204(%rbp)
jne 0x2456
leaq 0x5ddf(%rip), %rax      # 0x8200
cmpq %rax, -0x70(%rbp)
jne 0x243b
cmpl $0x0, -0x4c(%rbp)
je 0x243b
movq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x1070
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl -0x58(%rbp), %r8d
callq 0x1dd0
jmp 0x2456
jmp 0x2458
xorl %eax, %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw %cs:(%rax,%rax)