// File: tonymugen[P]sampleSNPs/varfiles.cpp
// Function: sampFiles::TpedFileI::_famCopy(std::basic_fstream<char, std::char_traits<char>>&)
void TpedFileI::_famCopy(fstream &fam){
	if (_tfamFile.is_open()) {
        _tfamFile.close();
    }
    string tfamName = _fileStub + ".tfam";
    try {
        _tfamFile.open(tfamName.c_str(), ios::in);
		if (!_tfamFile.is_open()) {
			cerr << "ERROR: failed to open .tfam file " << tfamName << " for input" << endl;
			exit(2);
		}

    } catch (system_error &error) {
        cerr << "ERROR: cannot open .tfam file " << tfamName << " for input: " << error.code().message() << flush;
        perror(" ");
        exit(1);

    }
    if (!fam.is_open()) {
        throw string("Output .fam filestream not open");
    }

    const size_t bufSize = BUF_SIZE;
    char *buf;
    try {
        buf = new char[bufSize];
    } catch (bad_alloc& error) {
        cerr << "ERROR: failed to allocate buffer in TpedFile::_famCopy(): " << error.what() << endl;
        exit(4);
    }

    while (_tfamFile) {
        _tfamFile.read(buf, bufSize);
        fam.write(buf, _tfamFile.gcount());
    }
    _tfamFile.close();
    delete [] buf;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x90(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x45e0
testb $0x1, %al
jne 0x198b0
jmp 0x198c3
movq -0x90(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0x4060
movq -0x90(%rbp), %rsi
addq $0x450, %rsi            # imm = 0x450
leaq 0xa34f(%rip), %rdx      # 0x23c27
leaq -0x30(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x7920
movq -0x90(%rbp), %rax
movq -0xa0(%rbp), %rdi
addq $0x240, %rax            # imm = 0x240
movq %rax, -0x98(%rbp)
callq 0x4140
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0x1991e
movq -0x90(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0x45e0
movb %al, -0xa1(%rbp)
jmp 0x19939
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x19a99
jmp 0x19949
movq 0x126a0(%rip), %rdi     # 0x2bff0
leaq 0xa2d6(%rip), %rsi      # 0x23c2d
callq 0x4310
movq %rax, -0xb0(%rbp)
jmp 0x19965
movq -0xb0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x42e0
movq %rax, -0xb8(%rbp)
jmp 0x1997e
movq -0xb8(%rbp), %rdi
leaq 0x9bc8(%rip), %rsi      # 0x23554
callq 0x4310
movq %rax, -0xc0(%rbp)
jmp 0x1999a
movq -0xc0(%rbp), %rdi
movq 0x12608(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x199af
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x19d55
movq -0x38(%rbp), %rdi
callq 0x4130
movq %rax, -0x48(%rbp)
movq 0x12607(%rip), %rdi     # 0x2bff0
leaq 0xa25f(%rip), %rsi      # 0x23c4f
callq 0x4310
movq %rax, -0xc8(%rbp)
jmp 0x199fe
movq -0xc8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x42e0
movq %rax, -0xd0(%rbp)
jmp 0x19a17
movq -0xd0(%rbp), %rdi
leaq 0x9fc0(%rip), %rsi      # 0x239e5
callq 0x4310
movq %rax, -0xd8(%rbp)
jmp 0x19a33
movq -0x48(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x1eeb0
jmp 0x19a4a
movq -0xd8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x42e0
movq %rax, -0xe0(%rbp)
jmp 0x19a63
movq -0xe0(%rbp), %rdi
movq 0x12557(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x19a78
leaq -0x68(%rbp), %rdi
callq 0x46d8
leaq 0x9d72(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x19a8f
movl $0x1, %edi
callq 0x4400
jmp 0x19aca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x19abe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x19ac5
jmp 0x19d55
movq -0x10(%rbp), %rdi
callq 0x45e0
movb %al, -0xe1(%rbp)
jmp 0x19adb
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x19b95
jmp 0x19aeb
movb $0x1, -0x6a(%rbp)
movl $0x20, %edi
callq 0x4180
movq %rax, -0xf8(%rbp)
movq %rax, -0x100(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x4620
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rdx
leaq 0x9cd0(%rip), %rsi      # 0x237fc
callq 0x7470
jmp 0x19b33
movq -0x100(%rbp), %rdi
movb $0x0, -0x6a(%rbp)
leaq 0x11d4b(%rip), %rsi     # 0x2b890
movq 0x1246c(%rip), %rdx     # 0x2bfb8
callq 0x45c0
jmp 0x19d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x19d55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x4380
testb $0x1, -0x6a(%rbp)
jne 0x19b84
jmp 0x19b90
movq -0x100(%rbp), %rdi
callq 0x4250
jmp 0x19d55
movq $0xa00000, -0x78(%rbp)  # imm = 0xA00000
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, -0x108(%rbp)
jmp 0x19bb0
movq -0x108(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x19c67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x19d55
movq -0x38(%rbp), %rdi
callq 0x4130
movq %rax, -0x88(%rbp)
movq 0x123fd(%rip), %rdi     # 0x2bff0
leaq 0xa0ec(%rip), %rsi      # 0x23ce6
callq 0x4310
movq %rax, -0x110(%rbp)
jmp 0x19c08
movq -0x88(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x110(%rbp), %rdi
movq %rax, %rsi
callq 0x4310
movq %rax, -0x118(%rbp)
jmp 0x19c30
movq -0x118(%rbp), %rdi
movq 0x12372(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x19c45
movl $0x4, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x4580
jmp 0x19c62
jmp 0x19d55
jmp 0x19c69
movq -0x90(%rbp), %rax
movq 0x240(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0x240(%rax,%rcx), %rdi
callq 0x4440
movb %al, -0x119(%rbp)
jmp 0x19c90
movb -0x119(%rbp), %al
testb $0x1, %al
jne 0x19c9c
jmp 0x19d11
movq -0x90(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
movq -0x80(%rbp), %rsi
movl $0xa00000, %edx         # imm = 0xA00000
callq 0x4450
jmp 0x19cba
movq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x138(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x130(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x46c0
movq %rax, -0x128(%rbp)
jmp 0x19cf0
movq -0x128(%rbp), %rdx
movq -0x130(%rbp), %rsi
movq -0x138(%rbp), %rdi
callq 0x44a0
jmp 0x19d0c
jmp 0x19c69
movq -0x90(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0x4060
jmp 0x19d26
movq -0x80(%rbp), %rax
movq %rax, -0x140(%rbp)
cmpq $0x0, %rax
je 0x19d43
movq -0x140(%rbp), %rdi
callq 0x4480
leaq -0x30(%rbp), %rdi
callq 0x46d8
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x46d8
movq -0x38(%rbp), %rdi
callq 0x4610
movq %rax, %rdi
callq 0x82c0
nop