// File: tedsharpe[P]ORFCall/ORFCall.cc
// Function: (anonymous namespace)::Reference::readPlan(char const*)
void Reference::readPlan( char const* planFile ) {
    std::ifstream ifs(planFile,std::ios_base::in|std::ios_base::binary);
    if ( !ifs )
        FatalErr("Can't open plan file: " << planFile);

    std::string line;
    if ( !std::getline(ifs,line) || line.size() != 64*3+63 )
        FatalErr("Can't read plan file header.");

    size_t nCodons = mWTCodons.size();
    size_t lineNo = 0;
    mPlannedMasks.reserve(nCodons);
    while ( std::getline(ifs,line) )
    {
        ++lineNo;
        if ( line.size() != 64+63 )
            FatalErr("Plan file line " << lineNo << " is weird:\n" << line);
        int64_t val = 0;
        for ( Codon codon = 0; codon < NCODONS-1; ++codon )
        {
            char chr = line[2*codon+1];
            if ( chr != '\t' && chr != ' ' )
                FatalErr("Plan file line " << lineNo << " is weird:\n" << line);
        }
        for ( Codon codon = 0; codon < NCODONS; ++codon )
        {
            switch (line[2*codon])
            {
            case '0': break;
            case '1': val |= 1ul << codon; break;
            case '2':
                if ( lineNo <= nCodons )
                {
                    Codon refCodon = mWTCodons[lineNo-1];
                    if ( refCodon != codon )
                        FatalErr("Plan file line " << lineNo <<
                                " indicates WT for codon " << seqFor(codon) <<
                                " but the reference sequence has codon "
                                << seqFor(refCodon) << " at that position.");
                }
                break;
            default:
                FatalErr("Plan file line " << lineNo << " is weird:\n" << line);
            }
        }
        mPlannedMasks.push_back(val);
    }
    if ( mPlannedMasks.size() > nCodons )
        FatalErr("Plan file has " << mPlannedMasks.size() <<
                    " lines, but there are only " << nCodons << " codons.");
    else if ( mPlannedMasks.size() < nCodons )
    {
        std::cerr << "Warning: Plan file has only " << mPlannedMasks.size() <<
            " lines, but there are " << nCodons << " codons." << std::endl;
        mPlannedMasks.resize(nCodons);
    }
}

// Assembly:
subq $0x408, %rsp            # imm = 0x408
movq %rdi, 0x400(%rsp)
movq %rsi, 0x3f8(%rsp)
movq 0x400(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x3f8(%rsp), %rax
movq %rax, 0x148(%rsp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x17350
movq 0x148(%rsp), %rsi
movl %eax, %edx
leaq 0x1f0(%rsp), %rdi
callq 0x4540
movq 0x1f0(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x1f0(%rsp,%rax), %rdi
callq 0x4150
movb %al, 0x157(%rsp)
jmp 0x87bf
movb 0x157(%rsp), %al
testb $0x1, %al
jne 0x87cc
jmp 0x8841
movq 0x2481d(%rip), %rdi     # 0x2cff0
leaq 0x190bd(%rip), %rsi     # 0x21897
callq 0x4290
movq %rax, 0x138(%rsp)
jmp 0x87e9
movq 0x138(%rsp), %rdi
movq 0x3f8(%rsp), %rsi
callq 0x4290
movq %rax, 0x130(%rsp)
jmp 0x8808
movq 0x130(%rsp), %rdi
movq 0x24791(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x881e
movl $0x1, %edi
callq 0x42f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e8(%rsp)
movl %eax, 0x1e4(%rsp)
jmp 0x9081
leaq 0x1c0(%rsp), %rdi
movq %rdi, 0x120(%rsp)
callq 0x43a0
movq 0x120(%rsp), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0x4050
movq %rax, 0x128(%rsp)
jmp 0x8875
movq 0x128(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4150
movb %al, 0x11f(%rsp)
jmp 0x8895
movb 0x11f(%rsp), %al
testb $0x1, %al
jne 0x88b7
jmp 0x88a2
leaq 0x1c0(%rsp), %rdi
callq 0x41c0
cmpq $0xff, %rax
je 0x890d
movq 0x24732(%rip), %rdi     # 0x2cff0
leaq 0x18fe9(%rip), %rsi     # 0x218ae
callq 0x4290
movq %rax, 0x110(%rsp)
jmp 0x88d4
movq 0x110(%rsp), %rdi
movq 0x246c5(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x88ea
movl $0x1, %edi
callq 0x42f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e8(%rsp)
movl %eax, 0x1e4(%rsp)
jmp 0x9074
movq 0x140(%rsp), %rdi
addq $0x90, %rdi
callq 0x18600
movq 0x140(%rsp), %rdi
movq %rax, 0x1b8(%rsp)
movq $0x0, 0x1b0(%rsp)
addq $0xa8, %rdi
movq 0x1b8(%rsp), %rsi
callq 0x18e00
jmp 0x8953
jmp 0x8955
leaq 0x1f0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x4050
movq %rax, 0x108(%rsp)
jmp 0x8974
movq 0x108(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4300
movb %al, 0x107(%rsp)
jmp 0x8994
movb 0x107(%rsp), %al
testb $0x1, %al
jne 0x89a4
jmp 0x8ea8
movq 0x1b0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1b0(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x41c0
cmpq $0x7f, %rax
je 0x8a68
movq 0x2461a(%rip), %rdi     # 0x2cff0
leaq 0x18eee(%rip), %rsi     # 0x218cb
callq 0x4290
movq %rax, 0xf8(%rsp)
jmp 0x89ec
movq 0xf8(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
callq 0x4070
movq %rax, 0xf0(%rsp)
jmp 0x8a0b
movq 0xf0(%rsp), %rdi
leaq 0x18ec1(%rip), %rsi     # 0x218db
callq 0x4290
movq %rax, 0xe8(%rsp)
jmp 0x8a29
movq 0xe8(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x4260
movq %rax, 0xe0(%rsp)
jmp 0x8a48
movq 0xe0(%rsp), %rdi
movq 0x24551(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x8a5e
movl $0x1, %edi
callq 0x42f0
movq $0x0, 0x1a8(%rsp)
movl $0x0, 0x1a4(%rsp)
cmpl $0x3f, 0x1a4(%rsp)
jae 0x8b97
movl 0x1a4(%rsp), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax), %eax
movl %eax, %esi
leaq 0x1c0(%rsp), %rdi
callq 0x45b0
movq %rax, 0xd8(%rsp)
jmp 0x8ab3
movq 0xd8(%rsp), %rax
movb (%rax), %al
movb %al, 0x1a3(%rsp)
movsbl 0x1a3(%rsp), %eax
cmpl $0x9, %eax
je 0x8b7f
movsbl 0x1a3(%rsp), %eax
cmpl $0x20, %eax
je 0x8b7f
movq 0x24503(%rip), %rdi     # 0x2cff0
leaq 0x18dd7(%rip), %rsi     # 0x218cb
callq 0x4290
movq %rax, 0xd0(%rsp)
jmp 0x8b03
movq 0xd0(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
callq 0x4070
movq %rax, 0xc8(%rsp)
jmp 0x8b22
movq 0xc8(%rsp), %rdi
leaq 0x18daa(%rip), %rsi     # 0x218db
callq 0x4290
movq %rax, 0xc0(%rsp)
jmp 0x8b40
movq 0xc0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x4260
movq %rax, 0xb8(%rsp)
jmp 0x8b5f
movq 0xb8(%rsp), %rdi
movq 0x2443a(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x8b75
movl $0x1, %edi
callq 0x42f0
jmp 0x8b81
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a4(%rsp)
jmp 0x8a7f
movl $0x0, 0x19c(%rsp)
cmpl $0x40, 0x19c(%rsp)
jae 0x8e85
movl 0x19c(%rsp), %eax
addl %eax, %eax
movl %eax, %esi
leaq 0x1c0(%rsp), %rdi
callq 0x45b0
movq %rax, 0xb0(%rsp)
jmp 0x8bd2
movq 0xb0(%rsp), %rax
movsbl (%rax), %eax
movl %eax, 0xac(%rsp)
subl $0x30, %eax
je 0x8c0a
jmp 0x8beb
movl 0xac(%rsp), %eax
subl $0x31, %eax
je 0x8c0f
jmp 0x8bf9
movl 0xac(%rsp), %eax
subl $0x32, %eax
je 0x8c35
jmp 0x8dec
jmp 0x8e6d
movl 0x19c(%rsp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
orq 0x1a8(%rsp), %rax
movq %rax, 0x1a8(%rsp)
jmp 0x8e6d
movq 0x1b0(%rsp), %rax
cmpq 0x1b8(%rsp), %rax
ja 0x8de7
movq 0x140(%rsp), %rdi
addq $0x90, %rdi
movq 0x1b0(%rsp), %rsi
subq $0x1, %rsi
callq 0x18f10
movl (%rax), %eax
movl %eax, 0x198(%rsp)
movl 0x198(%rsp), %eax
cmpl 0x19c(%rsp), %eax
je 0x8de5
movq 0x24361(%rip), %rdi     # 0x2cff0
leaq 0x18c35(%rip), %rsi     # 0x218cb
callq 0x4290
movq %rax, 0xa0(%rsp)
jmp 0x8ca5
movq 0xa0(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
callq 0x4070
movq %rax, 0x98(%rsp)
jmp 0x8cc4
movq 0x98(%rsp), %rdi
leaq 0x18c14(%rip), %rsi     # 0x218e7
callq 0x4290
movq %rax, 0x90(%rsp)
jmp 0x8ce2
movl 0x19c(%rsp), %esi
leaq 0x178(%rsp), %rdi
callq 0xa890
jmp 0x8cf8
movq 0x90(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x4260
movq %rax, 0x88(%rsp)
jmp 0x8d17
movq 0x88(%rsp), %rdi
leaq 0x18bda(%rip), %rsi     # 0x21900
callq 0x4290
movq %rax, 0x80(%rsp)
jmp 0x8d35
movl 0x198(%rsp), %esi
leaq 0x158(%rsp), %rdi
callq 0xa890
jmp 0x8d4b
movq 0x80(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x4260
movq %rax, 0x78(%rsp)
jmp 0x8d67
movq 0x78(%rsp), %rdi
leaq 0x18bb4(%rip), %rsi     # 0x21927
callq 0x4290
movq %rax, 0x70(%rsp)
jmp 0x8d7f
movq 0x70(%rsp), %rdi
movq 0x2421d(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x8d92
movl $0x1, %edi
callq 0x42f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e8(%rsp)
movl %eax, 0x1e4(%rsp)
jmp 0x8dd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e8(%rsp)
movl %eax, 0x1e4(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x41b0
leaq 0x178(%rsp), %rdi
callq 0x41b0
jmp 0x9074
jmp 0x8de7
jmp 0x8e6d
movq 0x241fd(%rip), %rdi     # 0x2cff0
leaq 0x18ad1(%rip), %rsi     # 0x218cb
callq 0x4290
movq %rax, 0x68(%rsp)
jmp 0x8e06
movq 0x68(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
callq 0x4070
movq %rax, 0x60(%rsp)
jmp 0x8e1f
movq 0x60(%rsp), %rdi
leaq 0x18ab0(%rip), %rsi     # 0x218db
callq 0x4290
movq %rax, 0x58(%rsp)
jmp 0x8e37
movq 0x58(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x4260
movq %rax, 0x50(%rsp)
jmp 0x8e50
movq 0x50(%rsp), %rdi
movq 0x2414c(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x8e63
movl $0x1, %edi
callq 0x42f0
jmp 0x8e6f
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x8ba2
movq 0x140(%rsp), %rdi
addq $0xa8, %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x18f30
jmp 0x8ea3
jmp 0x8955
movq 0x140(%rsp), %rdi
addq $0xa8, %rdi
callq 0x18fa0
cmpq 0x1b8(%rsp), %rax
jbe 0x8f72
movq 0x2411f(%rip), %rdi     # 0x2cff0
leaq 0x18a62(%rip), %rsi     # 0x2193a
callq 0x4290
movq %rax, 0x48(%rsp)
jmp 0x8ee4
movq 0x140(%rsp), %rdi
addq $0xa8, %rdi
callq 0x18fa0
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x4070
movq %rax, 0x40(%rsp)
jmp 0x8f0c
movq 0x40(%rsp), %rdi
leaq 0x18a31(%rip), %rsi     # 0x21949
callq 0x4290
movq %rax, 0x38(%rsp)
jmp 0x8f24
movq 0x38(%rsp), %rdi
movq 0x1b8(%rsp), %rsi
callq 0x4070
movq %rax, 0x30(%rsp)
jmp 0x8f3d
movq 0x30(%rsp), %rdi
leaq 0x18a1c(%rip), %rsi     # 0x21965
callq 0x4290
movq %rax, 0x28(%rsp)
jmp 0x8f55
movq 0x28(%rsp), %rdi
movq 0x24047(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x8f68
movl $0x1, %edi
callq 0x42f0
movq 0x140(%rsp), %rdi
addq $0xa8, %rdi
callq 0x18fa0
cmpq 0x1b8(%rsp), %rax
jae 0x9050
movq 0x24055(%rip), %rdi     # 0x2cff0
leaq 0x189cc(%rip), %rsi     # 0x2196e
callq 0x4290
movq %rax, 0x20(%rsp)
jmp 0x8fae
movq 0x140(%rsp), %rdi
addq $0xa8, %rdi
callq 0x18fa0
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x4070
movq %rax, 0x18(%rsp)
jmp 0x8fd6
movq 0x18(%rsp), %rdi
leaq 0x189a9(%rip), %rsi     # 0x2198b
callq 0x4290
movq %rax, 0x10(%rsp)
jmp 0x8fee
movq 0x10(%rsp), %rdi
movq 0x1b8(%rsp), %rsi
callq 0x4070
movq %rax, 0x8(%rsp)
jmp 0x9007
movq 0x8(%rsp), %rdi
leaq 0x18952(%rip), %rsi     # 0x21965
callq 0x4290
movq %rax, (%rsp)
jmp 0x901e
movq (%rsp), %rdi
movq 0x23f7f(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x9030
movq 0x140(%rsp), %rdi
addq $0xa8, %rdi
movq 0x1b8(%rsp), %rsi
callq 0x18fc0
jmp 0x904e
jmp 0x9050
jmp 0x9052
leaq 0x1c0(%rsp), %rdi
callq 0x41b0
leaq 0x1f0(%rsp), %rdi
callq 0x4080
addq $0x408, %rsp            # imm = 0x408
retq
leaq 0x1c0(%rsp), %rdi
callq 0x41b0
leaq 0x1f0(%rsp), %rdi
callq 0x4080
movq 0x1e8(%rsp), %rdi
callq 0x4510
nopl (%rax,%rax)