// File: /workspace/github_c_makefile_star2_O0/JimKent[P]linearSat/lib/errabort.c
// Function: getThreadVars
static struct perThreadAbortVars *getThreadVars()
/* Return a pointer to the perThreadAbortVars for the current pthread. */
{
pthread_t pid = pthread_self(); //  can be a pointer or a number
// Don't safef, theoretically that could abort.
char pidStr[64];
snprintf(pidStr, sizeof(pidStr), "%lld",  ptrToLL(pid));
pidStr[ArraySize(pidStr)-1] = '\0';

static char pidInUse[64] = "";  // use a string since there is no known unused value for pthread_t variable
if (sameString(pidStr, pidInUse)) // avoid deadlock on self
    {  // this only happens when it has aborted already due to out of memory
       // which should be a rare occurrence.
    char *errMsg = "errAbort re-entered due to out-of-memory condition. Exiting.";
    write(STDERR_FILENO, errMsg, strlen(errMsg)); 
    exit(1);
    }

static pthread_mutex_t ptavMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock( &ptavMutex );
snprintf(pidInUse, sizeof(pidInUse), "%lld",  ptrToLL(pid));
pidInUse[ArraySize(pidInUse)-1] = '\0';

static struct hash *perThreadVars = NULL;
if (perThreadVars == NULL)
    perThreadVars = hashNew(0);
struct hashEl *hel = hashLookup(perThreadVars, pidStr);
if (hel == NULL)
    {
    // if it is the first time, initialization the perThreadAbortVars
    struct perThreadAbortVars *ptav;
    AllocVar(ptav);
    ptav->debugPushPopErr = FALSE;
    ptav->errAbortInProgress = FALSE;
    ptav->warnIx = 0;
    ptav->warnArray[0] = defaultVaWarn;
    ptav->abortIx = 0;
    ptav->abortArray[0] = defaultAbort;
    hel = hashAdd(perThreadVars, pidStr, ptav);
    }
pidInUse[0] = '\0';
pthread_mutex_unlock( &ptavMutex );
return (struct perThreadAbortVars *)(hel->val);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
callq 0x35d0
movq %rax, -0x8(%rbp)
leaq -0x50(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x40, %esi
leaq 0x14629(%rip), %rdx     # 0x2487e
movb $0x0, %al
callq 0x3290
movb $0x0, -0x11(%rbp)
leaq -0x50(%rbp), %rdi
leaq 0x225f5(%rip), %rsi     # 0x32860
callq 0x3410
cmpl $0x0, %eax
jne 0x102ac
leaq 0x14894(%rip), %rax     # 0x24b10
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rdi
callq 0x31f0
movq -0x70(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x3190
movl $0x1, %edi
callq 0x36b0
leaq 0x225ed(%rip), %rdi     # 0x328a0
callq 0x3740
movq -0x8(%rbp), %rcx
leaq 0x2259d(%rip), %rdi     # 0x32860
movl $0x40, %esi
leaq 0x145af(%rip), %rdx     # 0x2487e
movb $0x0, %al
callq 0x3290
movb $0x0, 0x225c2(%rip)     # 0x3289f
cmpq $0x0, 0x225e3(%rip)     # 0x328c8
jne 0x102fa
xorl %edi, %edi
movl $0x1, %esi
callq 0x10f70
movq %rax, 0x225ce(%rip)     # 0x328c8
movq 0x225c7(%rip), %rdi     # 0x328c8
leaq -0x50(%rbp), %rsi
callq 0x104b0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x1038d
movl $0x118, %edi            # imm = 0x118
callq 0x152f0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movl $0x0, (%rax)
movq -0x68(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x68(%rbp), %rax
movl $0x0, 0xa8(%rax)
movq -0x68(%rbp), %rax
leaq -0x181(%rip), %rcx      # 0x101d0
movq %rcx, 0x8(%rax)
movq -0x68(%rbp), %rax
movl $0x0, 0x110(%rax)
movq -0x68(%rbp), %rax
leaq 0x42(%rip), %rcx        # 0x103b0
movq %rcx, 0xb0(%rax)
movq 0x2254c(%rip), %rdi     # 0x328c8
leaq -0x50(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0x10900
movq %rax, -0x60(%rbp)
movb $0x0, 0x224cc(%rip)     # 0x32860
leaq 0x22505(%rip), %rdi     # 0x328a0
callq 0x34e0
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x70, %rsp
popq %rbp
retq
nop