// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/xxdp.c
// Function: xxdp_filesystem_recalc_radi
static int xxdp_filesystem_recalc_radi(xxdp_filesystem_t *_this) {
	xxdp_radi_t *radi = &_this->radi;
	xxdp_blocknr_t curblk;
	int ufd_blocks_num;

	radi->interleave = 1; // not used

	// 1) BOOT
	assert(radi->boot_block == 0); // always
	curblk = 1; // always next free block.

	// 2) MFD
	radi->mfd1 = 1;
	if (radi->mfd2 <= 0)
		curblk++; // MFD1/2
	else {
		radi->mfd2 = 2;
		curblk += 2; // MFD1 + MFD2
	}

	// 3) UFD
	radi->ufd_block_1 = curblk;
	// # of initial userdir entries
	// from XXDP: 1 UFD block serves ca. 280 file blocks
	// do not assign less than DEC table
	ufd_blocks_num = NEEDED_BLOCKS(XXDP_BLOCKSIZE, _this->image_size) / 280;
	if (ufd_blocks_num > radi->ufd_blocks_num)
		radi->ufd_blocks_num = ufd_blocks_num;
	curblk += radi->ufd_blocks_num;

	// 4) bitmap size: blocks/8 bytes
	radi->bitmap_block_1 = curblk;
	// one bitmap block has entires for 960 blocks
	radi->bitmaps_num = NEEDED_BLOCKS(960, _this->blockcount);

	curblk += radi->bitmaps_num;

	// 5) monitor
	radi->monitor_block = curblk;
	// normal monitor size is 32 (39 if interleave 5)
	curblk += 32;

	radi->prealloc_blocks_num = curblk;

	return ERROR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x1c(%rax)
movq -0x10(%rbp), %rax
movzwl 0x20(%rax), %eax
cmpl $0x0, %eax
jne 0xfa32
jmp 0xfa51
leaq 0xd2c4(%rip), %rdi      # 0x1ccfd
leaq 0xcfdb(%rip), %rsi      # 0x1ca1b
movl $0xb6, %edx
leaq 0xd2c7(%rip), %rcx      # 0x1cd13
callq 0x3200
movw $0x1, -0x12(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0xc(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jg 0xfa7a
movw -0x12(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x12(%rbp)
jmp 0xfa90
movq -0x10(%rbp), %rax
movl $0x2, 0x10(%rax)
movzwl -0x12(%rbp), %eax
addl $0x2, %eax
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x200, %eax            # imm = 0x200
subl $0x1, %eax
shrl $0x9, %eax
movl $0x118, %ecx            # imm = 0x118
xorl %edx, %edx
divl %ecx
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x6(%rcx), %ecx
cmpl %ecx, %eax
jle 0xfad7
movl -0x18(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x6(%rax)
movq -0x10(%rbp), %rax
movzwl 0x6(%rax), %ecx
movzwl -0x12(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl 0x4c(%rax), %eax
addl $0x3c0, %eax            # imm = 0x3C0
subl $0x1, %eax
movl $0x3c0, %ecx            # imm = 0x3C0
xorl %edx, %edx
divl %ecx
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xa(%rax)
movq -0x10(%rbp), %rax
movzwl 0xa(%rax), %ecx
movzwl -0x12(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movzwl -0x12(%rbp), %eax
addl $0x20, %eax
movw %ax, -0x12(%rbp)
movw -0x12(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x18(%rax)
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)