// File: BenLangmead[P]bowtie/ebwt.cpp
// Function: adjustEbwtBase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
string adjustEbwtBase(const string& cmdline,
                      const string& ebwtFileBase,
                      bool verbose = false)
{
	string str = ebwtFileBase;
	ifstream in;
	if(verbose) cout << "Trying " << str << endl;
	if (access((str + ".1." + gBt2_ext).c_str(), R_OK) == 0) {
		gEbwt_ext = gBt2_ext;
	}
	in.open((str + ".1." + gEbwt_ext).c_str(), ios_base::in | ios::binary);
	if(!in.is_open()) {
		if(verbose) cout << "  didn't work" << endl;
		in.close();
		str = cmdline;
		size_t st = str.find_last_of("/\\");
		if(st != string::npos) {
			str.erase(st);
			str += "/indexes/";
		} else {
			str = "indexes/";
		}
		str += ebwtFileBase;
		if(verbose) cout << "Trying " << str << endl;
		in.open((str + ".1." + gEbwt_ext).c_str(), ios_base::in | ios::binary);
		if(!in.is_open()) {
			if(verbose) cout << "  didn't work" << endl;
			in.close();
			if(getenv("BOWTIE_INDEXES") != NULL) {
				str = string(getenv("BOWTIE_INDEXES")) + "/" + ebwtFileBase;
				if(verbose) cout << "Trying " << str << endl;
				if (access((str + ".1." + gBt2_ext).c_str(), R_OK) == 0) {
					gEbwt_ext = gBt2_ext;
				}
				in.open((str + ".1." + gEbwt_ext).c_str(), ios_base::in | ios::binary);
				if(!in.is_open()) {
					if(verbose) cout << "  didn't work" << endl;
					in.close();
				} else {
					if(verbose) cout << "  worked" << endl;
				}
			}
		}
	}
	if(!in.is_open()) {
		cerr << "Could not locate a Bowtie index corresponding to basename \"" << ebwtFileBase << "\"" << endl;
		throw 1;
	}
	return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4c0, %rsp            # imm = 0x4C0
movq %rdi, -0x3f8(%rbp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, -0x3f0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movb $0x0, -0x1a(%rbp)
movq -0x18(%rbp), %rsi
callq 0x5160
leaq -0x228(%rbp), %rdi
callq 0x5470
jmp 0x3ceea
testb $0x1, -0x19(%rbp)
je 0x3cf6d
movq 0xd0c9(%rip), %rdi      # 0x49fc0
leaq 0x68d4(%rip), %rsi      # 0x437d2
callq 0x5360
movq %rax, -0x400(%rbp)
jmp 0x3cf0c
movq -0x3f8(%rbp), %rsi
movq -0x400(%rbp), %rdi
callq 0x52f0
movq %rax, -0x408(%rbp)
jmp 0x3cf28
movq -0x408(%rbp), %rdi
movq 0xd04a(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3cf3d
jmp 0x3cf6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x3d84c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x3d822
movq -0x3f8(%rbp), %rsi
leaq 0x4988(%rip), %rdx      # 0x41903
leaq -0x278(%rbp), %rdi
callq 0x1a930
jmp 0x3cf89
leaq 0xf270(%rip), %rdx      # 0x4c200
leaq -0x258(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x2bdc0
jmp 0x3cfa5
leaq -0x258(%rbp), %rdi
callq 0x5150
movq %rax, %rdi
movl $0x4, %esi
callq 0x56e0
movl %eax, -0x40c(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x5888
leaq -0x278(%rbp), %rdi
callq 0x5888
movl -0x40c(%rbp), %eax
cmpl $0x0, %eax
jne 0x3d021
leaq 0xf1f2(%rip), %rdi      # 0x4c1e0
leaq 0xf20b(%rip), %rsi      # 0x4c200
callq 0x5040
jmp 0x3cffc
jmp 0x3d021
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x5888
jmp 0x3d822
movq -0x3f8(%rbp), %rsi
leaq 0x48d4(%rip), %rdx      # 0x41903
leaq -0x2b8(%rbp), %rdi
callq 0x1a930
jmp 0x3d03d
leaq 0xf19c(%rip), %rdx      # 0x4c1e0
leaq -0x298(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x2bdc0
jmp 0x3d059
leaq -0x298(%rbp), %rdi
callq 0x5150
movq %rax, -0x418(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x2f850
movl %eax, -0x410(%rbp)
jmp 0x3d083
movl -0x410(%rbp), %edx
movq -0x418(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x51d0
jmp 0x3d09e
leaq -0x298(%rbp), %rdi
callq 0x5888
leaq -0x2b8(%rbp), %rdi
callq 0x5888
leaq -0x228(%rbp), %rdi
callq 0x5680
movb %al, -0x419(%rbp)
jmp 0x3d0ca
movb -0x419(%rbp), %al
testb $0x1, %al
jne 0x3d75b
jmp 0x3d0da
testb $0x1, -0x19(%rbp)
je 0x3d156
movq 0xced9(%rip), %rdi      # 0x49fc0
leaq 0x66ec(%rip), %rsi      # 0x437da
callq 0x5360
movq %rax, -0x428(%rbp)
jmp 0x3d0fc
movq -0x428(%rbp), %rdi
movq 0xce76(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3d111
jmp 0x3d156
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x3d145
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x5888
leaq -0x2b8(%rbp), %rdi
callq 0x5888
jmp 0x3d822
leaq -0x228(%rbp), %rdi
callq 0x50a0
jmp 0x3d164
movq -0x3f8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5040
jmp 0x3d176
movq -0x3f8(%rbp), %rdi
leaq 0x6664(%rip), %rsi      # 0x437e8
movq $-0x1, %rdx
callq 0x5320
movq %rax, -0x2c0(%rbp)
cmpq $-0x1, -0x2c0(%rbp)
je 0x3d1d4
movq -0x3f8(%rbp), %rdi
movq -0x2c0(%rbp), %rsi
movq $-0x1, %rdx
callq 0x50b0
jmp 0x3d1bd
movq -0x3f8(%rbp), %rdi
leaq 0x6620(%rip), %rsi      # 0x437eb
callq 0x5340
jmp 0x3d1d2
jmp 0x3d1eb
movq -0x3f8(%rbp), %rdi
leaq 0x660a(%rip), %rsi      # 0x437ec
callq 0x5570
jmp 0x3d1e9
jmp 0x3d1eb
movq -0x3f8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5500
jmp 0x3d1fd
testb $0x1, -0x19(%rbp)
je 0x3d252
movq 0xcdb6(%rip), %rdi      # 0x49fc0
leaq 0x65c1(%rip), %rsi      # 0x437d2
callq 0x5360
movq %rax, -0x430(%rbp)
jmp 0x3d21f
movq -0x3f8(%rbp), %rsi
movq -0x430(%rbp), %rdi
callq 0x52f0
movq %rax, -0x438(%rbp)
jmp 0x3d23b
movq -0x438(%rbp), %rdi
movq 0xcd37(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3d250
jmp 0x3d252
movq -0x3f8(%rbp), %rsi
leaq 0x46a3(%rip), %rdx      # 0x41903
leaq -0x300(%rbp), %rdi
callq 0x1a930
jmp 0x3d26e
leaq 0xef6b(%rip), %rdx      # 0x4c1e0
leaq -0x2e0(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x2bdc0
jmp 0x3d28a
leaq -0x2e0(%rbp), %rdi
callq 0x5150
movq %rax, -0x448(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x2f850
movl %eax, -0x43c(%rbp)
jmp 0x3d2b4
movl -0x43c(%rbp), %edx
movq -0x448(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x51d0
jmp 0x3d2cf
leaq -0x2e0(%rbp), %rdi
callq 0x5888
leaq -0x300(%rbp), %rdi
callq 0x5888
leaq -0x228(%rbp), %rdi
callq 0x5680
movb %al, -0x449(%rbp)
jmp 0x3d2fb
movb -0x449(%rbp), %al
testb $0x1, %al
jne 0x3d759
jmp 0x3d30b
testb $0x1, -0x19(%rbp)
je 0x3d387
movq 0xcca8(%rip), %rdi      # 0x49fc0
leaq 0x64bb(%rip), %rsi      # 0x437da
callq 0x5360
movq %rax, -0x458(%rbp)
jmp 0x3d32d
movq -0x458(%rbp), %rdi
movq 0xcc45(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3d342
jmp 0x3d387
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x3d376
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x5888
leaq -0x300(%rbp), %rdi
callq 0x5888
jmp 0x3d822
leaq -0x228(%rbp), %rdi
callq 0x50a0
jmp 0x3d395
leaq 0x6459(%rip), %rdi      # 0x437f5
callq 0x54b0
cmpq $0x0, %rax
je 0x3d757
leaq 0x6443(%rip), %rdi      # 0x437f5
callq 0x54b0
movq %rax, -0x468(%rbp)
leaq -0x361(%rbp), %rdi
movq %rdi, -0x460(%rbp)
callq 0x5780
movq -0x468(%rbp), %rsi
movq -0x460(%rbp), %rdx
leaq -0x360(%rbp), %rdi
callq 0x17fb0
jmp 0x3d3ed
leaq 0x63ff(%rip), %rdx      # 0x437f3
leaq -0x340(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x2fb20
jmp 0x3d409
movq -0x18(%rbp), %rdx
leaq -0x320(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x2bdc0
jmp 0x3d422
movq -0x3f8(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x54c0
leaq -0x320(%rbp), %rdi
callq 0x5888
leaq -0x340(%rbp), %rdi
callq 0x5888
leaq -0x360(%rbp), %rdi
callq 0x5888
leaq -0x361(%rbp), %rdi
callq 0x53f0
testb $0x1, -0x19(%rbp)
je 0x3d521
movq 0xcb4a(%rip), %rdi      # 0x49fc0
leaq 0x6355(%rip), %rsi      # 0x437d2
callq 0x5360
movq %rax, -0x470(%rbp)
jmp 0x3d48b
movq -0x3f8(%rbp), %rsi
movq -0x470(%rbp), %rdi
callq 0x52f0
movq %rax, -0x478(%rbp)
jmp 0x3d4a7
movq -0x478(%rbp), %rdi
movq 0xcacb(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3d4bc
jmp 0x3d521
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x3d510
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x3d504
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x5888
leaq -0x360(%rbp), %rdi
callq 0x5888
leaq -0x361(%rbp), %rdi
callq 0x53f0
jmp 0x3d822
movq -0x3f8(%rbp), %rsi
leaq 0x43d4(%rip), %rdx      # 0x41903
leaq -0x3a8(%rbp), %rdi
callq 0x1a930
jmp 0x3d53d
leaq 0xecbc(%rip), %rdx      # 0x4c200
leaq -0x388(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x2bdc0
jmp 0x3d559
leaq -0x388(%rbp), %rdi
callq 0x5150
movq %rax, %rdi
movl $0x4, %esi
callq 0x56e0
movl %eax, -0x47c(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x5888
leaq -0x3a8(%rbp), %rdi
callq 0x5888
movl -0x47c(%rbp), %eax
cmpl $0x0, %eax
jne 0x3d5d5
leaq 0xec3e(%rip), %rdi      # 0x4c1e0
leaq 0xec57(%rip), %rsi      # 0x4c200
callq 0x5040
jmp 0x3d5b0
jmp 0x3d5d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x5888
jmp 0x3d822
movq -0x3f8(%rbp), %rsi
leaq 0x4320(%rip), %rdx      # 0x41903
leaq -0x3e8(%rbp), %rdi
callq 0x1a930
jmp 0x3d5f1
leaq 0xebe8(%rip), %rdx      # 0x4c1e0
leaq -0x3c8(%rbp), %rdi
leaq -0x3e8(%rbp), %rsi
callq 0x2bdc0
jmp 0x3d60d
leaq -0x3c8(%rbp), %rdi
callq 0x5150
movq %rax, -0x488(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x2f850
movl %eax, -0x480(%rbp)
jmp 0x3d637
movl -0x480(%rbp), %edx
movq -0x488(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x51d0
jmp 0x3d652
leaq -0x3c8(%rbp), %rdi
callq 0x5888
leaq -0x3e8(%rbp), %rdi
callq 0x5888
leaq -0x228(%rbp), %rdi
callq 0x5680
movb %al, -0x489(%rbp)
jmp 0x3d67e
movb -0x489(%rbp), %al
testb $0x1, %al
jne 0x3d71a
jmp 0x3d68e
testb $0x1, -0x19(%rbp)
je 0x3d70a
movq 0xc925(%rip), %rdi      # 0x49fc0
leaq 0x6138(%rip), %rsi      # 0x437da
callq 0x5360
movq %rax, -0x498(%rbp)
jmp 0x3d6b0
movq -0x498(%rbp), %rdi
movq 0xc8c2(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3d6c5
jmp 0x3d70a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x3d6f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x5888
leaq -0x3e8(%rbp), %rdi
callq 0x5888
jmp 0x3d822
leaq -0x228(%rbp), %rdi
callq 0x50a0
jmp 0x3d718
jmp 0x3d755
testb $0x1, -0x19(%rbp)
je 0x3d753
movq 0xc899(%rip), %rdi      # 0x49fc0
leaq 0x60d6(%rip), %rsi      # 0x43804
callq 0x5360
movq %rax, -0x4a0(%rbp)
jmp 0x3d73c
movq -0x4a0(%rbp), %rdi
movq 0xc836(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3d751
jmp 0x3d753
jmp 0x3d755
jmp 0x3d757
jmp 0x3d759
jmp 0x3d75b
leaq -0x228(%rbp), %rdi
callq 0x5680
movb %al, -0x4a1(%rbp)
jmp 0x3d76f
movb -0x4a1(%rbp), %al
testb $0x1, %al
jne 0x3d80a
jmp 0x3d77f
movq 0xc86a(%rip), %rdi      # 0x49ff0
leaq 0x6080(%rip), %rsi      # 0x4380d
callq 0x5360
movq %rax, -0x4b0(%rbp)
jmp 0x3d79b
movq -0x4b0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x52f0
movq %rax, -0x4b8(%rbp)
jmp 0x3d7b4
movq -0x4b8(%rbp), %rdi
leaq 0x2761(%rip), %rsi      # 0x3ff23
callq 0x5360
movq %rax, -0x4c0(%rbp)
jmp 0x3d7d0
movq -0x4c0(%rbp), %rdi
movq 0xc7a2(%rip), %rsi      # 0x49f80
callq 0x53c0
jmp 0x3d7e5
movl $0x4, %edi
callq 0x5180
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0xc771(%rip), %rsi      # 0x49f70
xorl %eax, %eax
movl %eax, %edx
callq 0x5720
jmp 0x3d864
movb $0x1, -0x1a(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x50e0
testb $0x1, -0x1a(%rbp)
jne 0x3d83c
jmp 0x3d830
leaq -0x228(%rbp), %rdi
callq 0x50e0
jmp 0x3d84c
movq -0x3f8(%rbp), %rdi
callq 0x5888
movq -0x3f0(%rbp), %rax
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
movq -0x3f8(%rbp), %rdi
callq 0x5888
movq -0x230(%rbp), %rdi
callq 0x5760
nopw %cs:(%rax,%rax)
nop