// File: zeeev[P]DASVC/bamtools/src/toolkit/bamtools_resolve.cpp
// Function: BamTools::ResolveTool::StatsFileReader::Read(BamTools::ResolveTool::ResolveSettings*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, ReadGroupResolver, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, ReadGroupResolver>>>&)
bool ResolveTool::StatsFileReader::Read(ResolveTool::ResolveSettings* settings,
                                        map<string, ReadGroupResolver>& readGroups)
{
    // up-front sanity checks
    if ( !m_stream.is_open() || settings == 0 )
        return false;

    // clear out read group data
    readGroups.clear();

    // initialize state
    State currentState = StatsFileReader::None;

    // read stats file
    string line = SkipCommentsAndWhitespace();
    while ( !line.empty() ) {

        bool foundError = false;

        // switch state on keyword found
        if ( Utilities::StartsWith(line, INPUT_TOKEN) )
            currentState = StatsFileReader::InInput;
        else if ( Utilities::StartsWith(line, OPTIONS_TOKEN) )
            currentState = StatsFileReader::InOptions;
        else if ( Utilities::StartsWith(line, READGROUPS_TOKEN) )
            currentState = StatsFileReader::InReadGroups;

        // otherwise parse data line, depending on state
        else {
            if ( currentState == StatsFileReader::InInput )
                foundError = !ParseInputLine(line);
            else if ( currentState == StatsFileReader::InOptions )
                foundError = !ParseOptionLine(line, settings);
            else if ( currentState == StatsFileReader::InReadGroups )
                foundError = !ParseReadGroupLine(line, readGroups);
            else
                foundError = true;
        }

        // break out if error found
        if ( foundError )
            return false;

        // get next line
        line = SkipCommentsAndWhitespace();
    }

    // if here, return success
    return true;
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdx, 0x78(%rsp)
movq 0x88(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x86c10
testb $0x1, %al
jne 0xc91b4
jmp 0xc91bf
cmpq $0x0, 0x80(%rsp)
jne 0xc91cc
movb $0x0, 0x97(%rsp)
jmp 0xc93d0
movq 0x78(%rsp), %rdi
callq 0xcfbe0
movq 0x10(%rsp), %rsi
movl $0x0, 0x74(%rsp)
leaq 0x50(%rsp), %rdi
callq 0xc9400
leaq 0x50(%rsp), %rdi
callq 0x86c90
movb %al, 0xf(%rsp)
jmp 0xc91fd
movb 0xf(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xc920c
jmp 0xc93a6
movb $0x0, 0x43(%rsp)
leaq 0x9caa8(%rip), %rsi     # 0x165cc0
leaq 0x50(%rsp), %rdi
callq 0x1160a0
movb %al, 0xe(%rsp)
jmp 0xc9228
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xc9232
jmp 0xc9252
movl $0x1, 0x74(%rsp)
jmp 0xc933e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
jmp 0xc93c2
leaq 0x9ca87(%rip), %rsi     # 0x165ce0
leaq 0x50(%rsp), %rdi
callq 0x1160a0
movb %al, 0xd(%rsp)
jmp 0xc9269
movb 0xd(%rsp), %al
testb $0x1, %al
jne 0xc9273
jmp 0xc9280
movl $0x2, 0x74(%rsp)
jmp 0xc933c
leaq 0x9ca79(%rip), %rsi     # 0x165d00
leaq 0x50(%rsp), %rdi
callq 0x1160a0
movb %al, 0xc(%rsp)
jmp 0xc9297
movb 0xc(%rsp), %al
testb $0x1, %al
jne 0xc92a1
jmp 0xc92ae
movl $0x3, 0x74(%rsp)
jmp 0xc933a
cmpl $0x1, 0x74(%rsp)
jne 0xc92ce
movq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xc88d0
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x43(%rsp)
jmp 0xc9338
cmpl $0x2, 0x74(%rsp)
jne 0xc9300
movq 0x10(%rsp), %rdi
movq 0x80(%rsp), %rdx
leaq 0x50(%rsp), %rsi
callq 0xc88e0
movb %al, 0xb(%rsp)
jmp 0xc92f2
movb 0xb(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x43(%rsp)
jmp 0xc9336
cmpl $0x3, 0x74(%rsp)
jne 0xc932f
movq 0x10(%rsp), %rdi
movq 0x78(%rsp), %rdx
leaq 0x50(%rsp), %rsi
callq 0xc8c40
movb %al, 0xa(%rsp)
jmp 0xc9321
movb 0xa(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x43(%rsp)
jmp 0xc9334
movb $0x1, 0x43(%rsp)
jmp 0xc9336
jmp 0xc9338
jmp 0xc933a
jmp 0xc933c
jmp 0xc933e
testb $0x1, 0x43(%rsp)
je 0xc9357
movb $0x0, 0x97(%rsp)
movl $0x1, 0x3c(%rsp)
jmp 0xc93b6
movq 0x10(%rsp), %rsi
leaq 0x18(%rsp), %rdi
callq 0xc9400
jmp 0xc9368
leaq 0x50(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x86070
jmp 0xc9379
leaq 0x18(%rsp), %rdi
callq 0x86f68
jmp 0xc9385
jmp 0xc91ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x86f68
jmp 0xc93a4
jmp 0xc93c2
movb $0x1, 0x97(%rsp)
movl $0x1, 0x3c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x86f68
jmp 0xc93d0
leaq 0x50(%rsp), %rdi
callq 0x86f68
jmp 0xc93ce
jmp 0xc93e1
movb 0x97(%rsp), %al
andb $0x1, %al
addq $0x98, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290
nopw %cs:(%rax,%rax)