// File: /workspace/github_cpp_makefile_star2_O2/ksherlock[P]wdc-utils/afp/src/finder_info.cpp
// Function: afp::finder_info::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, afp::finder_info::open_mode, std::error_code&)
bool finder_info::open(const std::string &path, open_mode mode, std::error_code &ec) {
	ec.clear();
	close();
	clear();

	_fd = openX(path, ec);
	if (ec) return false;

	if (mode == read_only || mode == read_write) {
		auto ok = _(::read_xattr(_fd, XATTR_FINDERINFO_NAME, _finder_info, 32), ec);
		if (mode == read_only) close();
		if (ec) {
			remap_enoattr(ec);
			if (mode == read_only) return false;
			if (ec.value() == EOPNOTSUPP) {
				close();
				return false;
			}
		}
		finder_info_to_filetype(_finder_info, &_prodos_file_type, &_prodos_aux_type);
	}
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %r14
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %rbx
movq %rcx, %rdi
callq 0xcfae
movq %rbx, %rdi
callq 0xc9b8
andw $0x0, 0x4(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movups %xmm0, 0x18(%rbx)
andl $0x0, 0x28(%rbx)
movq (%r12), %rdi
movl $0x800, %esi            # imm = 0x800
xorl %eax, %eax
callq 0x21f0
movl %eax, %r13d
movl %eax, %edi
movq %r14, %rsi
callq 0xcd4f
testl %r13d, %r13d
js 0xcaa7
leaq 0x8(%rsp), %rsi
movl %r13d, %edi
callq 0x23b0
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0xcd4f
testl %ebp, %ebp
js 0xca9b
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpw $0x4000, %ax            # imm = 0x4000
je 0xca8c
cmpl $0x8000, %eax           # imm = 0x8000
je 0xcaa7
pushq $0x1d
jmp 0xca8e
pushq $0x15
popq %rbp
callq 0x2140
movl %ebp, (%r14)
movq %rax, 0x8(%r14)
movl %r13d, %edi
callq 0x2480
pushq $-0x1
popq %r13
movl %r13d, (%rbx)
cmpl $0x0, (%r14)
je 0xcac6
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %bpl
movl %r15d, %eax
orl $0x2, %eax
cmpl $0x3, %eax
jne 0xcab2
leaq 0xc(%rbx), %r12
leaq 0x1041(%rip), %rsi      # 0xdb20
pushq $0x20
popq %rcx
movl %r13d, %edi
movq %r12, %rdx
callq 0xcfc9
movq %rax, %rdi
movq %r14, %rsi
callq 0xcc69
cmpl $0x1, %r15d
jne 0xcb0e
movq %rbx, %rdi
callq 0xc9b8
cmpl $0x0, (%r14)
jne 0xcab0
jmp 0xcb1e
cmpl $0x5f, (%r14)
jne 0xcb1e
movq %rbx, %rdi
callq 0xc9b8
jmp 0xcab0
cmpl $0x736f6470, 0x10(%rbx) # imm = 0x736F6470
jne 0xcb4a
movzbl (%r12), %r14d
cmpl $0x70, %r14d
jne 0xcb6b
movzbl 0xd(%rbx), %eax
movw %ax, 0x4(%rbx)
movzwl 0xe(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
jmp 0xcc53
movl (%r12), %r15d
cmpl $0x414e4942, %r15d      # imm = 0x414E4942
je 0xcb8c
cmpl $0x54584554, %r15d      # imm = 0x54584554
jne 0xcb96
movw $0x4, 0x4(%rbx)
jmp 0xcc51
movl (%r12), %r15d
cmpl $0x36315350, %r15d      # imm = 0x36315350
je 0xcbd9
cmpl $0x53595350, %r15d      # imm = 0x53595350
jne 0xcbe1
movw $0xff, 0x4(%rbx)
jmp 0xcc51
andw $0x0, 0x4(%rbx)
jmp 0xcc51
movabsq $0x79704364676d4964, %rax # imm = 0x79704364676D4964
cmpq %rax, (%r12)
je 0xcc41
cmpl $0x43464941, %r15d      # imm = 0x43464941
je 0xcc5e
cmpl $0x46464941, %r15d      # imm = 0x46464941
je 0xcc4b
cmpl $0x4944494d, %r15d      # imm = 0x4944494D
jne 0xcab2
movw $0xd7, 0x4(%rbx)
jmp 0xcc51
movw $0xb3, 0x4(%rbx)
jmp 0xcc51
movl %r14d, %edi
callq 0x2490
testl %eax, %eax
jne 0xcb4e
movl %r15d, %r13d
shrl $0x8, %r13d
movzbl %r13b, %edi
callq 0x2490
testl %eax, %eax
sete %al
movl %r15d, %ecx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
cmpl $0x20200000, %ecx       # imm = 0x20200000
setne %cl
orb %al, %cl
jne 0xcb4e
movl %r14d, %edi
callq 0xcf82
movl %eax, %r14d
shll $0x8, %r14d
movzbl %r13b, %edi
callq 0xcf82
orl %r14d, %eax
movw %ax, 0x4(%rbx)
jmp 0xcc51
movw $0xe0, 0x4(%rbx)
pushq $0x5
jmp 0xcc66
movw $0xd8, 0x4(%rbx)
xorl %eax, %eax
addq $0x8, %rbx
movl %eax, (%rbx)
jmp 0xcab2
movw $0xd8, 0x4(%rbx)
pushq $0x1
popq %rax
jmp 0xcc53