// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
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 0x1edc
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 0x1ad5
movl %eax, %esi
testl %eax, %eax
js 0x1d3f
movq (%rbx), %rax
movl (%rax), %ecx
shll %cl, %esi
movzwl 0x18b(%rbx,%rsi), %r9d
movzbl 0x191(%rbx,%rsi), %eax
movzbl 0x192(%rbx,%rsi), %edx
shll $0xd, %edx
shll $0x5, %eax
orl %edx, %eax
addl %r9d, %eax
decl %eax
cltd
idivl %r9d
cmpl $0x9, %ecx
jb 0x1edc
movzwl 0x196(%rbx,%rsi), %r8d
movzwl 0x193(%rbx,%rsi), %edi
testl %edi, %edi
jne 0x1d02
movl 0x1a0(%rbx,%rsi), %edi
testw %r8w, %r8w
jne 0x1d10
movl 0x1a4(%rbx,%rsi), %r8d
testl %r9d, %r9d
je 0x1d46
xorl %r14d, %r14d
cmpl $0x1, %r9d
jne 0x1d34
xorl %r9d, %r9d
jmp 0x1d4c
movl %r9d, %edx
shrl %edx
incl %r14d
cmpl $0x2, %r9d
movl %edx, %r9d
jbe 0x1d1e
testb $0x1, %r9b
je 0x1d23
xorl %r14d, %r14d
jmp 0x1d4c
movl %esi, %ebp
jmp 0x1edc
movl %r9d, %r14d
movb $0x1, %r9b
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
testb $0x1, %r9b
jne 0x1edc
movzbl 0x18d(%rbx,%rsi), %r9d
testl %r9d, %r9d
je 0x1d91
xorl %edx, %edx
cmpl $0x1, %r9d
jne 0x1d87
xorl %r9d, %r9d
jmp 0x1d97
movl %r9d, %r10d
shrl %r10d
incl %edx
cmpl $0x2, %r9d
movl %r10d, %r9d
jbe 0x1d71
testb $0x1, %r9b
je 0x1d76
xorl %edx, %edx
jmp 0x1d97
movl %r9d, %edx
movb $0x1, %r9b
testb $0x1, %r9b
jne 0x1edc
cmpw $0xaa55, 0x37e(%rbx,%rsi) # imm = 0xAA55
jne 0x1edc
movzbl 0x1ae(%rbx,%rsi), %r12d
movzwl 0x18e(%rbx,%rsi), %r15d
movzbl 0x1af(%rbx,%rsi), %r9d
movzwl 0x1ac(%rbx,%rsi), %r11d
movzbl 0x190(%rbx,%rsi), %r10d
movl %r14d, %esi
subl %ecx, %esi
jae 0x1e30
subl %r14d, %ecx
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
movl %edx, %esi
subl %ecx, %esi
jb 0x1edc
movl %esi, 0x2c(%rbx)
movl %eax, %esi
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
shll %cl, %r14d
orl %r15d, %esi
orl %r8d, %esi
notl %r14d
testl %r14d, %esi
jne 0x1edc
movl %r15d, %esi
shrl %cl, %esi
movl %r8d, %r14d
shrl %cl, %r14d
movq %rsi, 0x30(%rbx)
movq %r14, 0x38(%rbx)
movl %eax, %ebp
shrl %cl, %ebp
jmp 0x1e55
leal (%rdx,%rsi), %ecx
movl %ecx, 0x2c(%rbx)
movzwl %r15w, %ebp
movl %esi, %ecx
shll %cl, %ebp
movl %r8d, %r14d
shll %cl, %r14d
movslq %ebp, %rcx
movq %rcx, 0x30(%rbx)
movq %r14, 0x38(%rbx)
movl %eax, %ebp
movl %esi, %ecx
shll %cl, %ebp
movl %ebp, %ecx
movq %rcx, 0x60(%rbx)
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
testl %r10d, %r10d
je 0x1edc
shll $0x10, %r12d
orl %r12d, %r11d
shll $0x18, %r9d
movl %r10d, 0x40(%rbx)
movzwl %r15w, %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 $0xf000000, %r9d        # imm = 0xF000000
orl %r11d, %r9d
movl %r9d, 0x68(%rbx)
movl %r10d, %ecx
imulq 0x38(%rbx), %rcx
addq 0x30(%rbx), %rcx
movq %rcx, 0x58(%rbx)
addq 0x60(%rbx), %rcx
movq %rcx, 0x48(%rbx)
testl %eax, %eax
je 0x1ed2
movl $0x0, 0x68(%rbx)
xorl %eax, %eax
cmpl $0xff7, %edi            # imm = 0xFF7
setae %al
leal 0xc(,%rax,4), %eax
jmp 0x1ed7
movl $0x20, %eax
movl %eax, 0x28(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq