// File: /workspace/github_cpp_makefile_star2_O1/conchoecia[P]fasta_stats/src/open_compressed.cc
// Function: find_suffix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
int find_suffix(std::string &filename, std::string &suffix) {
	const char *suffix_list[3] = { ".gz", ".bz2", ".Z" };
	const size_t suffix_size[3] = { 3, 4, 2 };
	suffix.clear();
	for (int i = 0; i != 3; ++i) {
		const size_t &j = suffix_size[i];
		if (filename.size() > j && filename.compare(filename.size() - j, j, suffix_list[i]) == 0) {
			suffix = suffix_list[i];
			break;
		}
	}
	struct stat buf;
	if (stat(filename.c_str(), &buf) == 0) {
		/* only open regular files */
		if ((buf.st_mode & S_IFDIR) != 0) {
			errno = EISDIR;
			return -1;
		} else {
			return 0;
		}
	} else if (errno != ENOENT) {
		fprintf(stderr, "Error: stat: %s: %s\n", filename.c_str(), strerror(errno));
		return -1;
	} else if (!suffix.empty()) {
		return -1;
	}
	for (int i = 0; i != 3; ++i) {
		const std::string s(filename + suffix_list[i]);
		if (stat(s.c_str(), &buf) == -1) {
			if (errno != ENOENT) {
				fprintf(stderr, "Error: stat: %s: %s\n", filename.c_str(), strerror(errno));
				return -1;
			}
		} else if ((buf.st_mode & S_IFDIR) == 0) {
			suffix = suffix_list[i];
			filename += suffix;
			return 0;
		}
	}
	errno = ENOENT;
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movq $0x0, 0x8(%rsi)
movq (%rsi), %rax
movb $0x0, (%rax)
xorl %r14d, %r14d
leaq 0x21db(%rip), %r12      # 0x68a0
leaq 0x46c4(%rip), %rbp      # 0x8d90
movq %rsi, 0x8(%rsp)
movq 0x8(%rbx), %rsi
movq (%r14,%r12), %rdx
subq %rdx, %rsi
jbe 0x46f1
movq (%r14,%rbp), %r15
movq %rbx, %rdi
movq %r15, %rcx
callq 0x2290
testl %eax, %eax
je 0x46fd
addq $0x8, %r14
cmpq $0x18, %r14
jne 0x46d1
jmp 0x4728
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r13
movq %r15, %rdi
callq 0x2130
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movq %r13, %rdx
movq 0x8(%rsp), %r13
movq %r15, %rcx
movq %rax, %r8
callq 0x2310
movq (%rbx), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2200
testl %eax, %eax
je 0x484a
callq 0x2040
movq %rax, 0x10(%rsp)
movl (%rax), %esi
cmpl $0x2, %esi
jne 0x4873
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq $0x0, 0x8(%r13)
jne 0x4880
xorl %r15d, %r15d
xorl %r12d, %r12d
leaq 0x4621(%rip), %rax      # 0x8d90
movq (%r15,%rax), %r13
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x565a
movq %r14, %rdi
movq %r13, %rsi
callq 0x23a0
movq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2200
cmpl $-0x1, %eax
je 0x47fc
movb $0x1, %r14b
testb $0x40, 0x51(%rsp)
jne 0x480b
movq 0x8(%rsp), %r14
movq 0x8(%r14), %rbp
movq %r13, %rdi
callq 0x2130
movq %r14, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0x2310
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x20e0
xorl %ebp, %ebp
jmp 0x480b
movq 0x10(%rsp), %rax
movl (%rax), %esi
movb $0x1, %r14b
cmpl $0x2, %esi
jne 0x4838
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x481f
callq 0x2220
testb %r14b, %r14b
je 0x4860
addq $0x8, %r15
cmpq $0x18, %r15
sete %r12b
jne 0x4768
jmp 0x4860
movq %rbx, %rdi
callq 0x24a9
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
jmp 0x480b
xorl %ebp, %ebp
testb $0x40, 0x51(%rsp)
je 0x4880
callq 0x2040
movl $0x15, (%rax)
jmp 0x487b
testb $0x1, %r12b
je 0x4880
movq 0x10(%rsp), %rax
movl $0x2, (%rax)
jmp 0x487b
movq %rbx, %rdi
callq 0x2473
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4896
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x48ad
callq 0x2220
movq %rbx, %rdi
callq 0x2370