// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
callq 0x4510
movq (%rax), %rax
leal -0x1(%rbx), %r14d
movq %rbx, 0x10(%rsp)
movzbl (%rbx), %ecx
incq %rbx
incl %r14d
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x19ead
leaq -0x1(%rbx), %r8
cmpl $0x2b, %ecx
je 0x19ecb
cmpl $0x2d, %ecx
jne 0x19ed4
cmpl $0x2b, %ecx
sete %r9b
jmp 0x19eda
movb $0x1, %r9b
movq %r8, %rbx
movb (%rbx), %sil
xorl %ecx, %ecx
testb %sil, %sil
je 0x19f37
incq %rbx
xorl %r15d, %r15d
xorl %r13d, %r13d
movzbl %sil, %edx
testb $0x8, 0x1(%rax,%rdx,2)
jne 0x19f0d
testb $0x1, %bpl
je 0x19fbc
cmpb $0x2c, %sil
je 0x19f27
jmp 0x19fbc
incl %r15d
movsbq %sil, %rdx
leaq (,%r13,4), %rsi
addq %r13, %rsi
leaq (%rdx,%rsi,2), %r13
addq $-0x30, %r13
movb (%rbx), %sil
incq %rbx
testb %sil, %sil
jne 0x19eed
decq %rbx
jmp 0x19f3d
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %edx, %edx
movzbl (%rbx), %esi
leal -0x45(%rsi), %edi
cmpl $0x8, %edi
jbe 0x19f66
addl $-0x65, %esi
cmpl $0x8, %esi
ja 0x1a042
leaq 0x7e917(%rip), %rdi     # 0x98874
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
leaq 0x7e8e3(%rip), %rsi     # 0x98850
movslq (%rsi,%rdi,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
movzbl 0x1(%rbx), %ecx
cmpl $0x2d, %ecx
je 0x19f88
cmpl $0x2b, %ecx
jne 0x1a00b
addq $0x2, %rbx
cmpb $0x2d, %cl
sete %sil
jmp 0x1a010
incq %rbx
movl $0x6, %ecx
jmp 0x1a042
incq %rbx
movl $0x3, %ecx
jmp 0x1a042
incq %rbx
movl $0x9, %ecx
jmp 0x1a042
xorl %edx, %edx
cmpb $0x2e, %sil
jne 0x1a003
movzbl (%rbx), %esi
testb $0x8, 0x1(%rax,%rsi,2)
je 0x19f3f
xorl %edx, %edx
incl %edx
movsbq %sil, %rsi
leaq (,%r13,4), %rdi
addq %r13, %rdi
leaq (%rsi,%rdi,2), %r13
addq $-0x30, %r13
movzbl 0x1(%rbx), %esi
incq %rbx
testb $0x8, 0x1(%rax,%rsi,2)
jne 0x19fd4
addl %edx, %r15d
jmp 0x19f3f
decq %rbx
jmp 0x19f3f
incq %rbx
xorl %esi, %esi
movzbl (%rbx), %ecx
xorl %edi, %edi
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1a038
xorl %edi, %edi
movsbl %cl, %ecx
leal (%rdi,%rdi,4), %edi
leal (%rcx,%rdi,2), %edi
addl $-0x30, %edi
movzbl 0x1(%rbx), %ecx
incq %rbx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x1a01e
movl %edi, %ecx
negl %ecx
testb %sil, %sil
cmovel %edi, %ecx
movl %ecx, %esi
subl %edx, %esi
jle 0x1a05d
subl %edx, %ecx
incl %ecx
addq %r13, %r13
leaq (%r13,%r13,4), %r13
decl %ecx
cmpl $0x1, %ecx
jg 0x1a04c
xorl %esi, %esi
xorl %edi, %edi
testl %esi, %esi
jns 0x1a096
movabsq $-0x3333333333333333, %r10 # imm = 0xCCCCCCCCCCCCCCCD
movq %r13, %rcx
movq %r13, %rax
mulq %r10
movq %rdx, %r13
shrq $0x3, %r13
leal (,%r13,2), %eax
leal (%rax,%rax,4), %eax
subl %eax, %ecx
addl %ecx, %edi
incl %esi
jne 0x1a06d
testl %edi, %edi
setg %dil
testb %dil, %dil
je 0x1a0d8
movl %ebx, %ecx
subl %r14d, %ecx
leaq 0x7f52c(%rip), %rsi     # 0x995d3
leaq 0x7f537(%rip), %rdx     # 0x995e5
movl $0x3, %edi
xorl %eax, %eax
movq %r12, 0x8(%rsp)
movl %r9d, %r12d
movl %ebp, 0x4(%rsp)
movq %r8, %rbp
callq 0x14378
movq %rbp, %r8
movl 0x4(%rsp), %ebp
movl %r12d, %r9d
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x1a109
testl %r15d, %r15d
movq 0x10(%rsp), %rax
cmovgq %rbx, %rax
movq %rax, (%r12)
movq %r13, %rax
negq %rax
testb %r9b, %r9b
cmovneq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r15d, %r15d
je 0x1a148
movb (%rbx), %al
testb %al, %al
je 0x1a0ed
testb $0x1, %bpl
jne 0x1a11e
cmpb $0x2c, %al
je 0x1a0ed
movl %ebx, %ecx
subl %r14d, %ecx
leaq 0x7f4a9(%rip), %rsi     # 0x995d3
leaq 0x7f4fd(%rip), %rdx     # 0x9962e
movl $0x3, %edi
movl %r9d, %ebp
movq %rbx, %r9
xorl %eax, %eax
callq 0x14378
movl %ebp, %r9d
jmp 0x1a0ed
leaq 0x7f484(%rip), %rsi     # 0x995d3
leaq 0x7f4b2(%rip), %rdx     # 0x99608
movl $0x3, %edi
movq %r8, %rcx
xorl %eax, %eax
movl %r9d, %ebx
callq 0x14378
movl %ebx, %r9d
jmp 0x1a0ed