// File: /workspace/github_c_makefile_star2_O3/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 0xddf4
movl $0x116, %eax            # imm = 0x116
btl %r15d, %eax
jae 0xddf4
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 0xdd66
testl %ebp, %ebp
je 0xde0a
testl %r13d, %r13d
je 0xde88
leaq 0xc39d(%rip), %rdx      # 0x1a0f2
xorl %eax, %eax
callq 0xa0ca
movl $0x4, %eax
jmp 0xded4
movl %edx, %r8d
leal -0x30(%r8), %ecx
cmpb $0x9, %cl
ja 0xddb7
xorl %ecx, %ecx
movq %r12, %r9
movq %rcx, %r10
addq %rcx, %rcx
leaq (%rcx,%rcx,4), %rcx
cmpq %r10, %rcx
jb 0xde25
addb $-0x30, %r8b
movzbl %r8b, %r8d
addq %r8, %rcx
jb 0xde25
cmpq %rax, %rcx
ja 0xde98
movb 0x1(%r9), %r8b
incq %r9
leal -0x30(%r8), %r10d
cmpb $0xa, %r10b
jb 0xdd77
jmp 0xddbc
xorl %ecx, %ecx
movq %r12, %r9
testb %r8b, %r8b
je 0xde4f
testl %ebp, %ebp
leaq 0xbf04(%rip), %rax      # 0x19cd2
leaq 0xc376(%rip), %rcx      # 0x1a14b
cmoveq %rax, %rcx
leaq 0xc391(%rip), %rdx      # 0x1a171
movq %rbx, %r8
xorl %eax, %eax
callq 0xa0ca
movl $0x1, %eax
jmp 0xded4
leaq 0xc284(%rip), %rdi      # 0x1a07f
movl %r15d, %esi
xorl %eax, %eax
callq 0xb6c8
jmp 0xdd06
leaq 0xc2fc(%rip), %rdx      # 0x1a10d
movq %rbx, %rcx
xorl %eax, %eax
callq 0xa0ca
movl $0x3, %eax
jmp 0xded4
testl %ebp, %ebp
leaq 0xbea4(%rip), %rax      # 0x19cd2
leaq 0xc316(%rip), %rcx      # 0x1a14b
cmoveq %rax, %rcx
leaq 0xc2fb(%rip), %rdx      # 0x1a13b
movq %rbx, %r8
xorl %eax, %eax
callq 0xa0ca
jmp 0xdecf
cmpq %r12, %r9
je 0xdee3
xorl %eax, %eax
testq %r14, %r14
je 0xded4
decl %r15d
cmpl $0x7, %r15d
ja 0xded4
leaq 0xbe35(%rip), %rsi      # 0x19ca4
movslq (%rsi,%r15,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
testl %ebp, %ebp
je 0xde83
cmpb $0x2d, %dl
jne 0xde83
negb %cl
movb %cl, (%r14)
jmp 0xded4
incq %rax
movb 0x1(%r12), %r8b
incq %r12
jmp 0xdd69
testl %ebp, %ebp
leaq 0xbe31(%rip), %r8       # 0x19cd2
leaq 0xc2a3(%rip), %rcx      # 0x1a14b
cmoveq %r8, %rcx
cmpb $0x2d, %dl
leaq 0xe69d(%rip), %r9       # 0x1c553
cmovneq %r8, %r9
movq %rax, (%rsp)
leaq 0xc28e(%rip), %rdx      # 0x1a153
movq %rbx, %r8
xorl %eax, %eax
callq 0xa0ca
movl $0x2, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
leaq 0xbde6(%rip), %rax      # 0x19cd2
leaq 0xc258(%rip), %rcx      # 0x1a14b
cmoveq %rax, %rcx
leaq 0xc294(%rip), %rdx      # 0x1a192
jmp 0xdde0
testl %ebp, %ebp
je 0xdf0e
cmpb $0x2d, %dl
jne 0xdf0e
negl %ecx
movl %ecx, (%r14)
jmp 0xded4
testl %ebp, %ebp
je 0xdf1e
cmpb $0x2d, %dl
jne 0xdf1e
negl %ecx
movw %cx, (%r14)
jmp 0xded4
testl %ebp, %ebp
je 0xdf30
cmpb $0x2d, %dl
jne 0xdf30
negq %rcx
movq %rcx, (%r14)
jmp 0xded4