// File: BenLangmead[P]bowtie/pat.cpp
// Function: CFilePatternSource::open()
void CFilePatternSource::open() {
	if(is_open_) {
		is_open_ = false;
		if (compressed_) {
			gzclose(zfp_);
			zfp_ = NULL;
		}
		else if (fp_ != stdin) {
			fclose(fp_);
			fp_ = NULL;
		}
		if(qfp_ != NULL && qfp_ != stdin) {
			fclose(qfp_);
			qfp_ = NULL;
		}
	}
	while(filecur_ < infiles_.size()) {
		// Open read
		if(infiles_[filecur_] == "-") {
			compressed_ = true;
			int fn = dup(fileno(stdin));
			zfp_ = gzdopen(fn, "rb");
		}
		else {
			compressed_ = false;
			if (is_gzipped_file(infiles_[filecur_])) {
				compressed_ = true;
				zfp_ = gzopen(infiles_[filecur_].c_str(), "rb");
			}
			else {
				fp_ = fopen(infiles_[filecur_].c_str(), "rb");
			}
			if ((compressed_ && zfp_ == NULL) || (!compressed_ && fp_ == NULL)) {
				if(!errs_[filecur_]) {
					cerr << "Warning: Could not open read file \""
					     << infiles_[filecur_] << "\" for reading; skipping..."
					     << endl;
					errs_[filecur_] = true;
				}
				filecur_++;
				continue;
			}
		}
		is_open_ = true;
		if (compressed_) {
#if ZLIB_VERNUM < 0x1235
			cerr << "Warning: gzbuffer added in zlib v1.2.3.5. Unable to change "
			        "buffer size from default of 8192." << endl;
#else
			gzbuffer(zfp_, 64*1024);
#endif
		}
		else {
			setvbuf(fp_, buf_, _IOFBF, 64*1024);
		}
		if(!qinfiles_.empty()) {
			if(qinfiles_[filecur_] == "-") {
				qfp_ = stdin;
			} else if((qfp_ = fopen(qinfiles_[filecur_].c_str(), "rb")) == NULL) {
				if(!errs_[filecur_]) {
					cerr << "Warning: Could not open quality file \""
					     << qinfiles_[filecur_] << "\" for reading; skipping..."
						 << endl;
					errs_[filecur_] = true;
				}
				filecur_++;
				continue;
			}
			assert(qfp_ != NULL);
			setvbuf(qfp_, qbuf_, _IOFBF, 64*1024);
		}
		return;
	}
	throw 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
testb $0x1, 0xa0(%rax)
je 0x7f1b4
movq -0x18(%rbp), %rax
movb $0x0, 0xa0(%rax)
testb $0x1, 0x200a2(%rax)
je 0x7f136
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0xaad0
movq -0x18(%rbp), %rax
movq $0x0, 0x98(%rax)
jmp 0x7f16e
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x28e50(%rip), %rcx     # 0xa7f98
cmpq (%rcx), %rax
je 0x7f16c
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0xa5e0
movq -0x18(%rbp), %rax
movq $0x0, 0x88(%rax)
jmp 0x7f16e
movq -0x18(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x7f1b2
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rax
movq 0x28e0a(%rip), %rcx     # 0xa7f98
cmpq (%rcx), %rax
je 0x7f1b2
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0xa5e0
movq -0x18(%rbp), %rax
movq $0x0, 0x90(%rax)
jmp 0x7f1b4
jmp 0x7f1b6
movq -0x18(%rbp), %rdi
movq 0x80(%rdi), %rax
movq %rax, -0x20(%rbp)
addq $0x20, %rdi
callq 0x26400
movq %rax, %rcx
movq -0x20(%rbp), %rax
cmpq %rcx, %rax
jae 0x7f5a6
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq %rax, %rdi
leaq 0xdd24(%rip), %rsi      # 0x8cf23
callq 0x28440
testb $0x1, %al
jne 0x7f20a
jmp 0x7f250
movq -0x18(%rbp), %rax
movb $0x1, 0x200a2(%rax)
movq 0x28d7c(%rip), %rax     # 0xa7f98
movq (%rax), %rdi
callq 0xa660
movl %eax, %edi
callq 0xa990
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %edi
leaq 0xa600(%rip), %rsi      # 0x89838
callq 0xaba0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x98(%rax)
jmp 0x7f3ed
movq -0x18(%rbp), %rax
movb $0x0, 0x200a2(%rax)
movq %rax, %rdi
addq $0x20, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x82c00
testb $0x1, %al
jne 0x7f280
jmp 0x7f2c5
movq -0x18(%rbp), %rax
movb $0x1, 0x200a2(%rax)
movq %rax, %rdi
addq $0x20, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq %rax, %rdi
callq 0xa210
movq %rax, %rdi
leaq 0xa588(%rip), %rsi      # 0x89838
callq 0xa970
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x98(%rax)
jmp 0x7f301
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq %rax, %rdi
callq 0xa210
movq %rax, %rdi
leaq 0xa54a(%rip), %rsi      # 0x89838
callq 0xa6e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x18(%rbp), %rax
testb $0x1, 0x200a2(%rax)
je 0x7f31c
movq -0x18(%rbp), %rax
cmpq $0x0, 0x98(%rax)
je 0x7f33f
movq -0x18(%rbp), %rax
testb $0x1, 0x200a2(%rax)
jne 0x7f3eb
movq -0x18(%rbp), %rax
cmpq $0x0, 0x88(%rax)
jne 0x7f3eb
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x60, %rdi
movq 0x80(%rax), %rsi
callq 0x82e10
testb $0x1, (%rax)
jne 0x7f3d0
movq 0x28c8e(%rip), %rdi     # 0xa7ff0
leaq 0xef69(%rip), %rsi      # 0x8e2d2
callq 0xa5d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq %rax, %rdi
addq $0x20, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0xa540
movq %rax, %rdi
leaq 0xef54(%rip), %rsi      # 0x8e2f6
callq 0xa5d0
movq %rax, %rdi
movq 0x28bb7(%rip), %rsi     # 0xa7f68
callq 0xa640
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x60, %rdi
movq 0x80(%rax), %rsi
callq 0x82e10
movb $0x1, (%rax)
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x80(%rax)
jmp 0x7f1b6
jmp 0x7f3ed
movq -0x18(%rbp), %rax
movb $0x1, 0xa0(%rax)
testb $0x1, 0x200a2(%rax)
je 0x7f418
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
movl $0x10000, %esi          # imm = 0x10000
callq 0xa460
jmp 0x7f436
movq -0x18(%rbp), %rsi
movq 0x88(%rsi), %rdi
addq $0xa2, %rsi
xorl %edx, %edx
movl $0x10000, %ecx          # imm = 0x10000
callq 0xa060
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
callq 0x28840
testb $0x1, %al
jne 0x7f5a0
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x40, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq %rax, %rdi
leaq 0xdab7(%rip), %rsi      # 0x8cf23
callq 0x28440
testb $0x1, %al
jne 0x7f477
jmp 0x7f491
movq -0x18(%rbp), %rax
movq 0x28b16(%rip), %rcx     # 0xa7f98
movq (%rcx), %rcx
movq %rcx, 0x90(%rax)
jmp 0x7f582
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x40, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq %rax, %rdi
callq 0xa210
movq %rax, %rdi
leaq 0xa37e(%rip), %rsi      # 0x89838
callq 0xa6e0
movq -0x18(%rbp), %rcx
movq %rax, 0x90(%rcx)
cmpq $0x0, %rax
jne 0x7f580
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x60, %rdi
movq 0x80(%rax), %rsi
callq 0x82e10
testb $0x1, (%rax)
jne 0x7f565
movq 0x28af9(%rip), %rdi     # 0xa7ff0
leaq 0xee13(%rip), %rsi      # 0x8e311
callq 0xa5d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq %rax, %rdi
addq $0x40, %rdi
movq 0x80(%rax), %rsi
callq 0x27460
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0xa540
movq %rax, %rdi
leaq 0xedbf(%rip), %rsi      # 0x8e2f6
callq 0xa5d0
movq %rax, %rdi
movq 0x28a22(%rip), %rsi     # 0xa7f68
callq 0xa640
movq -0x18(%rbp), %rax
movq %rax, %rdi
addq $0x60, %rdi
movq 0x80(%rax), %rsi
callq 0x82e10
movb $0x1, (%rax)
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x80(%rax)
jmp 0x7f1b6
jmp 0x7f582
movq -0x18(%rbp), %rsi
movq 0x90(%rsi), %rdi
addq $0x100a2, %rsi          # imm = 0x100A2
xorl %edx, %edx
movl $0x10000, %ecx          # imm = 0x10000
callq 0xa060
addq $0x30, %rsp
popq %rbp
retq
movl $0x4, %edi
callq 0xa290
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x28990(%rip), %rsi     # 0xa7f50
xorl %eax, %eax
movl %eax, %edx
callq 0xab10
nopl (%rax)