// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/hts.c
// Function: hts_parse_decimal
long long hts_parse_decimal(const char *str, char **strend, int flags)
{
    unsigned long long n = 0;
    int digits = 0, decimals = 0, e = 0, lost = 0;
    char sign = '+', esign = '+';
    const char *s, *str_orig = str;

    while (isspace_c(*str)) str++;
    s = str;

    if (*s == '+' || *s == '-') sign = *s++;
    while (*s)
        if (isdigit_c(*s)) digits++, n = push_digit(n, *s++);
        else if (*s == ',' && (flags & HTS_PARSE_THOUSANDS_SEP)) s++;
        else break;

    if (*s == '.') {
        s++;
        while (isdigit_c(*s)) decimals++, digits++, n = push_digit(n, *s++);
    }

    switch (*s) {
    case 'e': case 'E':
        s++;
        if (*s == '+' || *s == '-') esign = *s++;
        while (isdigit_c(*s)) e = push_digit(e, *s++);
        if (esign == '-') e = -e;
        break;

    case 'k': case 'K': e += 3; s++; break;
    case 'm': case 'M': e += 6; s++; break;
    case 'g': case 'G': e += 9; s++; break;
    }

    e -= decimals;
    while (e > 0) n *= 10, e--;
    while (e < 0) lost += n % 10, n /= 10, e++;

    if (lost > 0) {
        hts_log_warning("Discarding fractional part of %.*s", (int)(s - str), str);
    }

    if (strend) {
        // Set to the original input str pointer if not valid number syntax
        *strend = (digits > 0)? (char *)s : (char *)str_orig;
    } else if (digits == 0) {
        hts_log_warning("Invalid numeric value %.8s[truncated]", str);
    } else if (*s) {
        if ((flags & HTS_PARSE_THOUSANDS_SEP) || (!(flags & HTS_PARSE_THOUSANDS_SEP) && *s != ','))
            hts_log_warning("Ignoring unknown characters after %.*s[%s]", (int)(s - str), str, s);
    }

    return (sign == '+')? n : -n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, 0x1c(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %r12
leal -0x1(%rdi), %r15d
movq %rdi, %rbx
movsbl (%rbx), %r14d
movl %r14d, %edi
callq 0x15ecb
incq %rbx
incl %r15d
testl %eax, %eax
jne 0x15c2b
movzbl %r14b, %eax
leaq -0x1(%rbx), %rcx
cmpl $0x2b, %eax
movq %r12, 0x28(%rsp)
je 0x15c58
cmpl $0x2d, %eax
jne 0x15c61
cmpl $0x2b, %eax
sete %bpl
jmp 0x15c67
movb $0x1, %bpl
movq %rcx, %rbx
movq %rcx, 0x20(%rsp)
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movsbq (%rbx), %r14
testq %r14, %r14
je 0x15cbc
movsbl %r14b, %edi
callq 0x15ee4
testl %eax, %eax
je 0x15ca2
incl %r12d
imulq $0xa, %r13, %rax
leaq (%rax,%r14), %r13
addq $-0x30, %r13
jmp 0x15cb7
testb $0x1, 0x1c(%rsp)
je 0x15d95
cmpb $0x2c, %r14b
jne 0x15d95
incq %rbx
jmp 0x15c7b
xorl %edx, %edx
movq 0x20(%rsp), %r14
subl 0x10(%rsp), %edx
movl %edx, %eax
testl %eax, %eax
jle 0x15cd5
imulq $0xa, %r13, %r13
decl %eax
jmp 0x15cc9
movl %edx, %ecx
sarl $0x1f, %ecx
andl %edx, %ecx
xorl %esi, %esi
pushq $0xa
popq %rdi
testl %ecx, %ecx
je 0x15cf6
movq %r13, %rax
xorl %edx, %edx
divq %rdi
addl %edx, %esi
incl %ecx
movq %rax, %r13
jmp 0x15ce1
testl %esi, %esi
jle 0x15d1a
movl %ebx, %ecx
subl %r15d, %ecx
leaq 0x6295e(%rip), %rsi     # 0x78664
leaq 0x62969(%rip), %rdx     # 0x78676
pushq $0x3
popq %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x110c6
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x15d4f
testl %r12d, %r12d
movq 0x28(%rsp), %rcx
cmovgq %rbx, %rcx
movq %rcx, (%rax)
movq %r13, %rax
negq %rax
testb %bpl, %bpl
cmovneq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, %r12d
je 0x15dda
testb $0x1, 0x1c(%rsp)
sete %al
movb (%rbx), %dl
cmpb $0x2c, %dl
sete %cl
testb %dl, %dl
je 0x15d33
andb %cl, %al
jne 0x15d33
movl %ebx, %ecx
subl %r15d, %ecx
leaq 0x628e8(%rip), %rsi     # 0x78664
leaq 0x6293c(%rip), %rdx     # 0x786bf
pushq $0x3
popq %rdi
movq %r14, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x110c6
jmp 0x15d33
xorl %edx, %edx
cmpb $0x2e, %r14b
jne 0x15dfa
incq %rbx
movq $0x0, 0x10(%rsp)
movb (%rbx), %r14b
movsbl %r14b, %edi
callq 0x15ee4
testl %eax, %eax
je 0x15e05
movsbq %r14b, %rax
movq 0x10(%rsp), %rcx
incl %ecx
movq %rcx, 0x10(%rsp)
imulq $0xa, %r13, %rcx
leaq (%rcx,%rax), %r13
addq $-0x30, %r13
incq %rbx
jmp 0x15da9
leaq 0x62883(%rip), %rsi     # 0x78664
leaq 0x628b1(%rip), %rdx     # 0x78699
pushq $0x3
popq %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x110c6
jmp 0x15d33
movq $0x0, 0x10(%rsp)
jmp 0x15e0c
addl 0x10(%rsp), %r12d
xorl %edx, %edx
movzbl %r14b, %eax
leal -0x45(%rax), %ecx
cmpl $0x8, %ecx
jbe 0x15e39
addl $-0x65, %eax
cmpl $0x8, %eax
movq 0x20(%rsp), %r14
ja 0x15cc3
leaq 0x61aa4(%rip), %rcx     # 0x778d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x61a70(%rip), %rax     # 0x778b0
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
movq 0x20(%rsp), %r14
jmpq *%rcx
movzbl 0x1(%rbx), %eax
cmpl $0x2d, %eax
movb %bpl, 0xf(%rsp)
je 0x15e61
cmpl $0x2b, %eax
jne 0x15e89
addq $0x2, %rbx
cmpb $0x2d, %al
sete %al
movl %eax, 0x18(%rsp)
jmp 0x15e94
incq %rbx
pushq $0x6
jmp 0x15e83
incq %rbx
pushq $0x3
jmp 0x15e83
incq %rbx
pushq $0x9
popq %rdx
jmp 0x15cc3
incq %rbx
movl $0x0, 0x18(%rsp)
xorl %ebp, %ebp
movsbl (%rbx), %r14d
movl %r14d, %edi
callq 0x15ee4
testl %eax, %eax
je 0x15eb5
incq %rbx
imull $0xa, %ebp, %eax
leal (%rax,%r14), %ebp
addl $-0x30, %ebp
jmp 0x15e96
movl %ebp, %edx
negl %edx
cmpb $0x0, 0x18(%rsp)
cmovel %ebp, %edx
movb 0xf(%rsp), %bpl
jmp 0x15cbe