// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/ufat.c
// Function: ufat_open
int ufat_open(struct ufat *uf, const struct ufat_device *dev)
{
	uf->dev = dev;

	uf->next_seq = 0;
	uf->cache_size = UFAT_CACHE_BYTES >> dev->log2_block_size;

	if (uf->cache_size > UFAT_CACHE_MAX_BLOCKS)
		uf->cache_size = UFAT_CACHE_MAX_BLOCKS;

	if (!uf->cache_size)
		return -UFAT_ERR_BLOCK_SIZE;

	uf->alloc_ptr = 0;
	memset(&uf->stat, 0, sizeof(uf->stat));
	memset(&uf->cache_desc, 0, sizeof(uf->cache_desc));

	return read_bpb(uf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, (%rdi)
movl $0x0, 0x70(%rdi)
movl (%rsi), %ecx
movl $0x2000, %eax           # imm = 0x2000
shrl %cl, %eax
cmpl $0x9, %ecx
movl $0x10, %ecx
cmovael %eax, %ecx
movl %ecx, 0x74(%rdi)
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testl %ecx, %ecx
je 0x1dbb
movq %rdi, %rbx
movl $0x0, 0x78(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movups %xmm0, 0x18(%rdi)
addq $0x80, %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x1110
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1ab8
movl %eax, %esi
testl %eax, %eax
js 0x1db9
movq (%rbx), %rax
movl (%rax), %ecx
shll %cl, %esi
movzwl 0x18b(%rbx,%rsi), %r15d
movzwl 0x191(%rbx,%rsi), %eax
shll $0x5, %eax
addl %r15d, %eax
decl %eax
cltd
idivl %r15d
cmpl $0x9, %ecx
jb 0x1dbb
movzwl 0x196(%rbx,%rsi), %r8d
movzwl 0x193(%rbx,%rsi), %edi
testl %edi, %edi
jne 0x1ccc
movl 0x1a0(%rbx,%rsi), %edi
testw %r8w, %r8w
jne 0x1cda
movl 0x1a4(%rbx,%rsi), %r8d
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
testl %r15d, %r15d
je 0x1dbb
movzwl 0x18e(%rbx,%rsi), %r14d
movzwl 0x1ae(%rbx,%rsi), %r9d
movzbl 0x18d(%rbx,%rsi), %r13d
movzbl 0x190(%rbx,%rsi), %r10d
movzwl 0x1ac(%rbx,%rsi), %r11d
xorl %r12d, %r12d
cmpl $0x1, %r15d
je 0x1d3c
xorl %r12d, %r12d
testb $0x1, %r15b
jne 0x1dbb
movl %r15d, %edx
shrl %edx
incl %r12d
cmpl $0x2, %r15d
movl %edx, %r15d
ja 0x1d21
testl %r13d, %r13d
je 0x1dbb
xorl %edx, %edx
cmpl $0x1, %r13d
je 0x1d62
xorl %edx, %edx
testb $0x1, %r13b
jne 0x1dbb
movl %r13d, %r15d
shrl %r15d
incl %edx
cmpl $0x2, %r13d
movl %r15d, %r13d
ja 0x1d4b
cmpw $0xaa55, 0x37e(%rbx,%rsi) # imm = 0xAA55
jne 0x1dbb
movl %r12d, %esi
subl %ecx, %esi
jae 0x1dcc
subl %r12d, %ecx
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
movl %edx, %esi
subl %ecx, %esi
jb 0x1dbb
movl %esi, 0x2c(%rbx)
movl %eax, %esi
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
shll %cl, %r15d
orl %r14d, %esi
orl %r8d, %esi
notl %r15d
testl %r15d, %esi
jne 0x1dbb
movl %r14d, %r12d
shrl %cl, %r12d
movl %r8d, %r15d
shrl %cl, %r15d
movq %r12, 0x30(%rbx)
movq %r15, 0x38(%rbx)
movl %eax, %ebp
shrl %cl, %ebp
jmp 0x1def
movl %esi, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal (%rdx,%rsi), %ecx
movl %ecx, 0x2c(%rbx)
movzwl %r14w, %ebp
movl %esi, %ecx
shll %cl, %ebp
movl %r8d, %r15d
shll %cl, %r15d
movslq %ebp, %r12
movq %r12, 0x30(%rbx)
movq %r15, 0x38(%rbx)
movl %eax, %ebp
shll %cl, %ebp
movl %ebp, %esi
movq %rsi, 0x60(%rbx)
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
testl %r10d, %r10d
je 0x1dbb
shll $0x10, %r9d
movl %r10d, 0x40(%rbx)
movzwl %r14w, %ecx
imull %r10d, %r8d
addl %eax, %ecx
addl %r8d, %ecx
subl %ecx, %edi
movl %edx, %ecx
shrl %cl, %edi
addl $0x2, %edi
movl %edi, 0x50(%rbx)
andl $0xfff0000, %r9d        # imm = 0xFFF0000
orl %r11d, %r9d
movl %r9d, 0x68(%rbx)
movl %r10d, %ecx
imulq %rcx, %r15
addq %r12, %r15
movq %r15, 0x58(%rbx)
addq %rsi, %r15
movq %r15, 0x48(%rbx)
testl %eax, %eax
je 0x1e62
movl $0x0, 0x68(%rbx)
xorl %eax, %eax
cmpl $0xff7, %edi            # imm = 0xFF7
setae %al
leal 0xc(,%rax,4), %eax
jmp 0x1e67
movl $0x20, %eax
movl %eax, 0x28(%rbx)
xorl %ebp, %ebp
jmp 0x1dbb