// File: mouda[P]LTE_random_access-simulate/ap.cpp
// Function: alglib_impl::ae_str2double(char const*, alglib_impl::ae_state*, char const**)
double ae_str2double(const char *buf, ae_state *state, const char **pasttheend)
{
    const char *emsg = "ALGLIB: unable to read double value from stream";
    ae_int_t sixbits[12];
    ae_int_t sixbitsread, i;
    union _u
    {
        double dval;
        unsigned char bytes[9];
    } u;
    
    
     /* 
      * skip leading spaces
      */
    while( *buf==' ' || *buf=='\t' || *buf=='\n' || *buf=='\r' )
        buf++;
      
    /*
     * Handle special cases
     */
    if( *buf=='.' )
    {
        const char *s_nan =    ".nan_______";
        const char *s_posinf = ".posinf____";
        const char *s_neginf = ".neginf____";
        if( strncmp(buf, s_nan, strlen(s_nan))==0 )
        {
            *pasttheend = buf+strlen(s_nan);
            return state->v_nan;
        }
        if( strncmp(buf, s_posinf, strlen(s_posinf))==0 )
        {
            *pasttheend = buf+strlen(s_posinf);
            return state->v_posinf;
        }
        if( strncmp(buf, s_neginf, strlen(s_neginf))==0 )
        {
            *pasttheend = buf+strlen(s_neginf);
            return state->v_neginf;
        }
        ae_break(state, ERR_ASSERTION_FAILED, emsg);
    }
    
    /* 
     * General case:
     * 1. read and decode six-bit digits
     * 2. check that all 11 digits were read
     * 3. set last 12th digit to zero (needed for simplicity of conversion)
     * 4. convert to 8 bytes
     * 5. convert to big endian representation, if needed
     */
    sixbitsread = 0;
    while( *buf!=' ' && *buf!='\t' && *buf!='\n' && *buf!='\r' && *buf!=0 )
    {
        ae_int_t d;
        d = ae_char2sixbits(*buf);
        if( d<0 || sixbitsread>=AE_SER_ENTRY_LENGTH )
            ae_break(state, ERR_ASSERTION_FAILED, emsg);
        sixbits[sixbitsread] = d;
        sixbitsread++;
        buf++;
    }
    *pasttheend = buf;
    if( sixbitsread!=AE_SER_ENTRY_LENGTH )
        ae_break(state, ERR_ASSERTION_FAILED, emsg);
    sixbits[AE_SER_ENTRY_LENGTH] = 0;
    ae_foursixbits2threebytes(sixbits+0, u.bytes+0);
    ae_foursixbits2threebytes(sixbits+4, u.bytes+3);
    ae_foursixbits2threebytes(sixbits+8, u.bytes+6);
    if( state->endianness==AE_BIG_ENDIAN )
    {
        for(i=0; i<sizeof(double)/2; i++)
        {
            unsigned char tc;
            tc = u.bytes[i];
            u.bytes[i] = u.bytes[sizeof(double)-1-i];
            u.bytes[sizeof(double)-1-i] = tc;
        }
    }
    return u.dval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq 0x19bb0(%rip), %rax     # 0x5823e
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0xd2(%rbp)
je 0x3e6e1
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, -0xd2(%rbp)
je 0x3e6e1
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0xa, %ecx
movb %al, -0xd2(%rbp)
je 0x3e6e1
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
sete %al
movb %al, -0xd2(%rbp)
movb -0xd2(%rbp), %al
testb $0x1, %al
jne 0x3e6ed
jmp 0x3e6fb
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x3e692
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x3e8b8
leaq 0x19b08(%rip), %rax     # 0x5821a
movq %rax, -0xb8(%rbp)
leaq 0x19b06(%rip), %rax     # 0x58226
movq %rax, -0xc0(%rbp)
leaq 0x19b04(%rip), %rax     # 0x58232
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x3110
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq %rax, %rdx
callq 0x3120
cmpl $0x0, %eax
jne 0x3e7b0
movq -0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x3110
movq -0xf0(%rbp), %rcx
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x3eaac
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x3110
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movq %rax, %rdx
callq 0x3120
cmpl $0x0, %eax
jne 0x3e82b
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x3110
movq -0x108(%rbp), %rcx
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x3eaac
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x3110
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rsi
movq %rax, %rdx
callq 0x3120
cmpl $0x0, %eax
jne 0x3e8a6
movq -0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x3110
movq -0x120(%rbp), %rcx
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x3eaac
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x3, %esi
callq 0x3ab10
movq $0x0, -0x98(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
movb %al, -0x121(%rbp)
je 0x3e926
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x9, %ecx
movb %al, -0x121(%rbp)
je 0x3e926
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x121(%rbp)
je 0x3e926
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xd, %ecx
movb %al, -0x121(%rbp)
je 0x3e926
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x121(%rbp)
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x3e932
jmp 0x3e9a4
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x3dca0
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
jl 0x3e959
cmpq $0xb, -0x98(%rbp)
jl 0x3e96b
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x3, %esi
callq 0x3ab10
movq -0xd0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x90(%rbp,%rax,8)
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x3e8c3
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
cmpq $0xb, -0x98(%rbp)
je 0x3e9cb
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x3, %esi
callq 0x3ab10
movq $0x0, -0x38(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3dd80
leaq -0x90(%rbp), %rdi
addq $0x20, %rdi
leaq -0xb0(%rbp), %rsi
addq $0x3, %rsi
callq 0x3dd80
leaq -0x90(%rbp), %rdi
addq $0x40, %rdi
leaq -0xb0(%rbp), %rsi
addq $0x6, %rsi
callq 0x3dd80
movq -0x18(%rbp), %rax
cmpq $0x2, (%rax)
jne 0x3ea9f
movq $0x0, -0xa0(%rbp)
cmpq $0x4, -0xa0(%rbp)
jae 0x3ea9d
movq -0xa0(%rbp), %rax
movb -0xb0(%rbp,%rax), %al
movb %al, -0xd1(%rbp)
movl $0x7, %eax
subq -0xa0(%rbp), %rax
movb -0xb0(%rbp,%rax), %cl
movq -0xa0(%rbp), %rax
movb %cl, -0xb0(%rbp,%rax)
movb -0xd1(%rbp), %cl
movl $0x7, %eax
subq -0xa0(%rbp), %rax
movb %cl, -0xb0(%rbp,%rax)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x3ea31
jmp 0x3ea9f
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw (%rax,%rax)