// File: /workspace/github_c_makefile_star2_O1/JimKent[P]linearSat/lib/linefile.c
// Function: lineFileCheckAllIntsNoAbort
int lineFileCheckAllIntsNoAbort(char *s, void *val, 
    boolean isSigned, int byteCount, char *typeString, boolean noNeg, 
    char *errMsg, int errMsgSize)
/* Convert string to (signed) integer of the size specified.  
 * Unlike atol assumes all of string is number, no trailing trash allowed.
 * Returns 0 if conversion possible, and value is returned in 'val'
 * Otherwise 1 for empty string or trailing chars, and 2 for numeric overflow,
 * and 3 for (-) sign in unsigned number.
 * Error messages if any are written into the provided buffer.
 * Pass NULL val if you only want validation.
 * Use noNeg if negative values are not allowed despite the type being signed,
 * returns 4. */
{
unsigned long long res = 0, oldRes = 0;
boolean isMinus = FALSE;

if ((byteCount != 1) 
 && (byteCount != 2)
 && (byteCount != 4)
 && (byteCount != 8))
    errAbort("Unexpected error: Invalid byte count for integer size in lineFileCheckAllIntsNoAbort, expected 1 2 4 or 8, got %d.", byteCount);

unsigned long long limit = 0xFFFFFFFFFFFFFFFFULL >> (8*(8-byteCount));

if (isSigned) 
    limit >>= 1;

char *p, *p0 = s;

if (*p0 == '-')
    {
    if (isSigned)
	{
	if (noNeg)
	    {
	    safef(errMsg, errMsgSize, "Negative value not allowed");
	    return 4; 
	    }
	p0++;
	++limit;
	isMinus = TRUE;
	}
    else
	{
	safef(errMsg, errMsgSize, "Unsigned %s may not begin with minus sign (-)", typeString);
	return 3; 
	}
    }
p = p0;
while ((*p >= '0') && (*p <= '9'))
    {
    res *= 10;
    if (res < oldRes)
	{
	safef(errMsg, errMsgSize, "%s%s overflowed", isSigned ? "signed ":"", typeString);
	return 2; 
	}
    oldRes = res;
    res += *p - '0';
    if (res < oldRes)
	{
	safef(errMsg, errMsgSize, "%s%s overflowed", isSigned ? "signed ":"", typeString);
	return 2; 
	}
    if (res > limit)
	{
	safef(errMsg, errMsgSize, "%s%s overflowed, limit=%s%llu", isSigned ? "signed ":"", typeString, isMinus ? "-" : "", limit);
	return 2; 
	}
    oldRes = res;
    p++;
    }
/* test for invalid character, empty, or just a minus */
if (*p != '\0')
    {
    safef(errMsg, errMsgSize, "Trailing characters parsing %s%s", isSigned ? "signed ":"", typeString);
    return 1;
    }
if (p == p0)
    {
    safef(errMsg, errMsgSize, "Empty string parsing %s%s", isSigned ? "signed ":"", typeString);
    return 1;
    }

if (!val)
    return 0;  // only validation required

switch (byteCount)
    {
    case 1:
	if (isSigned)
	    {
	    if (isMinus)
		*(char *)val = -res;
	    else
		*(char *)val = res;
	    }
	else
	    *(unsigned char *)val = res;
	break;
    case 2:
	if (isSigned)
	    {
	    if (isMinus)
		*(short *)val = -res;
	    else
		*(short *)val = res;
	    }
	else
	    *(unsigned short *)val = res;
	break;
    case 4:
	if (isSigned)
	    {
	    if (isMinus)
		*(int *)val = -res;
	    else
		*(int *)val = res;
	    }
	else
	    *(unsigned *)val = res;
	break;
    case 8:
	if (isSigned)
	    {
	    if (isMinus)
		*(long long *)val = -res;
	    else
		*(long long *) val =res;
	    }
	else
	    *(unsigned long long *)val = res;
	break;
    }


return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %r13d
movq %r8, %rbx
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
cmpl $0x8, %ecx
ja 0xe00c
movl $0x116, %eax            # imm = 0x116
btl %r15d, %eax
jae 0xe00c
leal (,%r15,8), %ecx
xorl %edx, %edx
testl %ebp, %ebp
sete %dl
shlq $0x3f, %rdx
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
orq %rdx, %rax
negb %cl
shrq %cl, %rax
movl 0x48(%rsp), %esi
movq 0x40(%rsp), %rdi
movb (%r12), %dl
cmpb $0x2d, %dl
jne 0xe040
testl %ebp, %ebp
je 0xe01f
testl %r13d, %r13d
je 0xe03a
leaq 0xc0e7(%rip), %rdx      # 0x1a0e2
xorl %eax, %eax
callq 0xa2ce
movl $0x4, %eax
jmp 0xe15b
leaq 0xc05c(%rip), %rdi      # 0x1a06f
movl %r15d, %esi
xorl %eax, %eax
callq 0xb8d7
jmp 0xdfb4
leaq 0xc0d7(%rip), %rdx      # 0x1a0fd
movq %rbx, %rcx
xorl %eax, %eax
callq 0xa2ce
movl $0x3, %eax
jmp 0xe15b
incq %r12
incq %rax
movb (%r12), %r8b
leal -0x30(%r8), %ecx
cmpb $0x9, %cl
ja 0xe08a
xorl %ecx, %ecx
movq %r12, %r9
movq %rcx, %r10
addq %rcx, %rcx
leaq (%rcx,%rcx,4), %rcx
cmpq %r10, %rcx
jb 0xe0c3
addb $-0x30, %r8b
movzbl %r8b, %r8d
addq %r8, %rcx
jb 0xe0c3
cmpq %rax, %rcx
ja 0xe11f
movb 0x1(%r9), %r8b
incq %r9
leal -0x30(%r8), %r10d
cmpb $0xa, %r10b
jb 0xe052
jmp 0xe08f
xorl %ecx, %ecx
movq %r12, %r9
testb %r8b, %r8b
je 0xe0ea
testl %ebp, %ebp
leaq 0xbc25(%rip), %rax      # 0x19cc2
leaq 0xc097(%rip), %rcx      # 0x1a13b
cmoveq %rax, %rcx
leaq 0xc0b2(%rip), %rdx      # 0x1a161
movq %rbx, %r8
xorl %eax, %eax
callq 0xa2ce
movl $0x1, %eax
jmp 0xe15b
testl %ebp, %ebp
leaq 0xbbf6(%rip), %rax      # 0x19cc2
leaq 0xc068(%rip), %rcx      # 0x1a13b
cmoveq %rax, %rcx
leaq 0xc04d(%rip), %rdx      # 0x1a12b
movq %rbx, %r8
xorl %eax, %eax
callq 0xa2ce
jmp 0xe156
cmpq %r12, %r9
je 0xe16a
xorl %eax, %eax
testq %r14, %r14
je 0xe15b
decl %r15d
cmpl $0x7, %r15d
ja 0xe15b
leaq 0xbb8e(%rip), %rsi      # 0x19c94
movslq (%rsi,%r15,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
testl %ebp, %ebp
je 0xe11a
cmpb $0x2d, %dl
jne 0xe11a
negb %cl
movb %cl, (%r14)
jmp 0xe15b
testl %ebp, %ebp
leaq 0xbb9a(%rip), %r8       # 0x19cc2
leaq 0xc00c(%rip), %rcx      # 0x1a13b
cmoveq %r8, %rcx
cmpb $0x2d, %dl
leaq 0xcab9(%rip), %r9       # 0x1abf6
cmovneq %r8, %r9
movq %rax, (%rsp)
leaq 0xbff7(%rip), %rdx      # 0x1a143
movq %rbx, %r8
xorl %eax, %eax
callq 0xa2ce
movl $0x2, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
leaq 0xbb4f(%rip), %rax      # 0x19cc2
leaq 0xbfc1(%rip), %rcx      # 0x1a13b
cmoveq %rax, %rcx
leaq 0xbffd(%rip), %rdx      # 0x1a182
jmp 0xe0af
testl %ebp, %ebp
je 0xe195
cmpb $0x2d, %dl
jne 0xe195
negl %ecx
movl %ecx, (%r14)
jmp 0xe15b
testl %ebp, %ebp
je 0xe1a5
cmpb $0x2d, %dl
jne 0xe1a5
negl %ecx
movw %cx, (%r14)
jmp 0xe15b
testl %ebp, %ebp
je 0xe1b7
cmpb $0x2d, %dl
jne 0xe1b7
negq %rcx
movq %rcx, (%r14)
jmp 0xe15b