// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq %rdx, %rsi
callq 0x4440
leaq 0x70(%rsp), %rdi
callq 0x4360
testb %bpl, %bpl
je 0x26db9
movq 0xd21e(%rip), %rdi      # 0x33fb8
leaq 0x57a3(%rip), %rsi      # 0x2c544
callq 0x42d0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4270
movq %rax, %rdi
callq 0x4130
leaq 0x398a(%rip), %rdx      # 0x2a74a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xf2e5
leaq 0xf32c(%rip), %rdx      # 0x36100
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1b182
leaq 0x30(%rsp), %r15
movq (%r15), %rdi
pushq $0x4
popq %rsi
callq 0x4580
movl %eax, %r13d
movq %r15, %rdi
callq 0x46c8
leaq 0x10(%rsp), %rdi
callq 0x46c8
testl %r13d, %r13d
jne 0x26e20
leaq 0xf2cc(%rip), %rdi      # 0x360e0
leaq 0xf2e5(%rip), %rsi      # 0x36100
callq 0x4150
leaq 0x3923(%rip), %rdx      # 0x2a74a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xf2e5
leaq 0xf2a5(%rip), %rdx      # 0x360e0
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1b182
movq 0x30(%rsp), %rsi
leaq 0x70(%rsp), %rdi
pushq $0xc
popq %rdx
callq 0x4180
leaq 0x30(%rsp), %rdi
callq 0x46c8
leaq 0x10(%rsp), %rdi
callq 0x46c8
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
callq 0x40a0
testb %al, %al
jne 0x27185
testb %bpl, %bpl
je 0x26ea8
movq 0xd124(%rip), %rdi      # 0x33fb8
leaq 0x56b1(%rip), %rsi      # 0x2c54c
callq 0x42d0
movq %rax, %rdi
callq 0x4130
leaq 0x70(%rsp), %rdi
callq 0x4080
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4150
leaq 0x5696(%rip), %rsi      # 0x2c55a
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x42a0
cmpq $-0x1, %rax
je 0x26ef4
pushq $-0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4090
leaq 0x5673(%rip), %rsi      # 0x2c55d
movq %rbx, %rdi
callq 0x4660
jmp 0x26f03
leaq 0x5663(%rip), %rsi      # 0x2c55e
movq %rbx, %rdi
callq 0x4670
movq %rbx, %rdi
movq %r14, %rsi
callq 0x46b0
testb %bpl, %bpl
je 0x26f39
movq 0xd09e(%rip), %rdi      # 0x33fb8
leaq 0x5623(%rip), %rsi      # 0x2c544
callq 0x42d0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4270
movq %rax, %rdi
callq 0x4130
leaq 0x380a(%rip), %rdx      # 0x2a74a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xf2e5
leaq 0xf18c(%rip), %rdx      # 0x360e0
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1b182
movq 0x30(%rsp), %rsi
leaq 0x70(%rsp), %rdi
pushq $0xc
popq %rdx
callq 0x4180
leaq 0x30(%rsp), %rdi
callq 0x46c8
leaq 0x10(%rsp), %rdi
callq 0x46c8
movq %r15, %rdi
callq 0x40a0
testb %al, %al
jne 0x27185
testb %bpl, %bpl
je 0x26fb9
movq 0xd013(%rip), %rdi      # 0x33fb8
leaq 0x55a0(%rip), %rsi      # 0x2c54c
callq 0x42d0
movq %rax, %rdi
callq 0x4130
leaq 0x70(%rsp), %rdi
callq 0x4080
leaq 0x559d(%rip), %rdi      # 0x2c567
callq 0x4390
testq %rax, %rax
je 0x27185
leaq 0x5588(%rip), %rdi      # 0x2c567
callq 0x4390
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %rax, %rsi
callq 0xd596
leaq 0x5568(%rip), %rdx      # 0x2c565
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1d630
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x1b182
leaq 0x30(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x43a0
movq %r12, %rdi
callq 0x46c8
leaq 0x10(%rsp), %rdi
callq 0x46c8
leaq 0x50(%rsp), %rdi
callq 0x46c8
testb %bpl, %bpl
je 0x27075
movq 0xcf62(%rip), %rdi      # 0x33fb8
leaq 0x54e7(%rip), %rsi      # 0x2c544
callq 0x42d0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4270
movq %rax, %rdi
callq 0x4130
leaq 0x36ce(%rip), %rdx      # 0x2a74a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xf2e5
leaq 0xf070(%rip), %rdx      # 0x36100
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1b182
leaq 0x30(%rsp), %r12
movq (%r12), %rdi
pushq $0x4
popq %rsi
callq 0x4580
movl %eax, %r13d
movq %r12, %rdi
callq 0x46c8
leaq 0x10(%rsp), %rdi
callq 0x46c8
testl %r13d, %r13d
jne 0x270dd
leaq 0xf00f(%rip), %rdi      # 0x360e0
leaq 0xf028(%rip), %rsi      # 0x36100
callq 0x4150
leaq 0x3666(%rip), %rdx      # 0x2a74a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xf2e5
leaq 0xefe8(%rip), %rdx      # 0x360e0
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1b182
movq 0x30(%rsp), %rsi
leaq 0x70(%rsp), %rdi
pushq $0xc
popq %rdx
callq 0x4180
leaq 0x30(%rsp), %rdi
callq 0x46c8
leaq 0x10(%rsp), %rdi
callq 0x46c8
movq %r15, %rdi
callq 0x40a0
testb %al, %al
je 0x2715b
testb %bpl, %bpl
je 0x27185
movq 0xce73(%rip), %rdi      # 0x33fb8
leaq 0x542a(%rip), %rsi      # 0x2c576
callq 0x42d0
movq %rax, %rdi
callq 0x4130
jmp 0x27185
testb %bpl, %bpl
je 0x2717b
movq 0xce51(%rip), %rdi      # 0x33fb8
leaq 0x53de(%rip), %rsi      # 0x2c54c
callq 0x42d0
movq %rax, %rdi
callq 0x4130
leaq 0x70(%rsp), %rdi
callq 0x4080
movq %r15, %rdi
callq 0x40a0
testb %al, %al
je 0x271b0
leaq 0x70(%rsp), %rdi
callq 0x40d0
movq %rbx, %rax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xce39(%rip), %rdi      # 0x33ff0
leaq 0x53c1(%rip), %rsi      # 0x2c57f
callq 0x42d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x4270
leaq 0x1d37(%rip), %rsi      # 0x28f0c
movq %rax, %rdi
callq 0x42d0
movq %rax, %rdi
callq 0x4130
pushq $0x4
popq %rdi
callq 0x4140
movl $0x1, (%rax)
movq 0xcd76(%rip), %rsi      # 0x33f70
movq %rax, %rdi
xorl %edx, %edx
callq 0x45b0
jmp 0x2722f
jmp 0x27242
jmp 0x2725a
jmp 0x27242
jmp 0x2725a
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x46c8
jmp 0x27220
movq %rax, %r14
leaq 0x50(%rsp), %rdi
jmp 0x2724a
jmp 0x2725a
jmp 0x2722f
jmp 0x27242
jmp 0x2725a
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x46c8
jmp 0x27245
jmp 0x27242
jmp 0x2725a
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x46c8
jmp 0x2725d
jmp 0x2725a
movq %rax, %r14
jmp 0x27267
jmp 0x2725a
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x46c8
movq %r14, %rdi
callq 0x45e0
nop