// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/xxdp.c
// Function: render_mfd
static void render_mfd(xxdp_filesystem_t *_this) {
	int i, n;
	xxdp_blocknr_t blknr;
	// link blocks
	xxdp_blocklist_set(_this, _this->mfd_blocklist);
	if (_this->mfd_variety == 1) {
		// two block MFD1, MFD2
		assert(_this->mfd_blocklist->count == 2);
		// write MFD1
		blknr = _this->mfd_blocklist->blocknr[0];
		xxdp_image_set_word(_this, blknr, 1, _this->interleave);
		xxdp_image_set_word(_this, blknr, 2, _this->bitmap->blocklist.blocknr[0]);
		// direct list of bitmap blocks
		n = _this->bitmap->blocklist.count;
		assert(n < 252); // space for 256 - 3 - 2 = 251 bitmap blocks
		for (i = 0; i < n; i++)
			xxdp_image_set_word(_this, blknr, i + 3, _this->bitmap->blocklist.blocknr[i]);
		// terminate list
		xxdp_image_set_word(_this, blknr, n + 3, 0);

		// write MFD2
		blknr = _this->mfd_blocklist->blocknr[1];
		xxdp_image_set_word(_this, blknr, 1, 0401); // UIC[1,1]
		xxdp_image_set_word(_this, blknr, 2, _this->ufd_blocklist->blocknr[0]); // start of UFDs
		xxdp_image_set_word(_this, blknr, 3, XXDP_UFD_ENTRY_WORDCOUNT);
		xxdp_image_set_word(_this, blknr, 4, 0);
	} else if (_this->mfd_variety == 2) {
		// MFD1/2
		assert(_this->mfd_blocklist->count == 1);
		blknr = _this->mfd_blocklist->blocknr[0];
		xxdp_image_set_word(_this, blknr, 1, _this->ufd_blocklist->blocknr[0]); // ptr to 1st UFD blk
		xxdp_image_set_word(_this, blknr, 2, _this->ufd_blocklist->count);
		xxdp_image_set_word(_this, blknr, 3, _this->bitmap->blocklist.blocknr[0]); // ptr to bitmap
		xxdp_image_set_word(_this, blknr, 4, _this->bitmap->blocklist.count);
		xxdp_image_set_word(_this, blknr, 5, blknr); // to self
		xxdp_image_set_word(_this, blknr, 6, 0);
		xxdp_image_set_word(_this, blknr, 7, _this->blockcount); // # of supported blocks
		xxdp_image_set_word(_this, blknr, 8, _this->preallocated_blockcount);
		xxdp_image_set_word(_this, blknr, 9, _this->interleave);
		xxdp_image_set_word(_this, blknr, 10, 0);
		xxdp_image_set_word(_this, blknr, 11, _this->monitor->blocknr); // 1st of monitor core img
		xxdp_image_set_word(_this, blknr, 12, 0);
		// bad sector position: needs to be define in RADI for each device
		xxdp_image_set_word(_this, blknr, 13, 0);
		xxdp_image_set_word(_this, blknr, 14, 0);
		xxdp_image_set_word(_this, blknr, 15, 0);
		xxdp_image_set_word(_this, blknr, 16, 0);
	} else
		fatal("MFD variety must be 1 or 2");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rsi
callq 0x134b0
movq -0x8(%rbp), %rax
cmpl $0x1, 0x58(%rax)
jne 0x11581
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
cmpl $0x2, (%rax)
jne 0x113f0
jmp 0x1140f
leaq 0xbe75(%rip), %rdi      # 0x1d26c
leaq 0xb61d(%rip), %rsi      # 0x1ca1b
movl $0x32d, %edx            # imm = 0x32D
leaq 0xbe83(%rip), %rcx      # 0x1d28d
callq 0x3200
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movw 0x4(%rax), %ax
movw %ax, -0x12(%rbp)
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
movl $0x1, %edx
movzwl %cx, %esi
movzwl %ax, %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movl $0x2, %edx
movzwl %cx, %esi
movzwl 0x4(%rax), %ecx
callq 0x13540
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movl (%rax), %eax
movl %eax, -0x10(%rbp)
cmpl $0xfc, -0x10(%rbp)
jge 0x11480
jmp 0x1149f
leaq 0xbe2b(%rip), %rdi      # 0x1d2b2
leaq 0xb58d(%rip), %rsi      # 0x1ca1b
movl $0x334, %edx            # imm = 0x334
leaq 0xbdf3(%rip), %rcx      # 0x1d28d
callq 0x3200
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x114e8
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %si
movl -0xc(%rbp), %eax
addl $0x3, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0xc(%rbp), %rcx
movzwl %si, %esi
movzbl %dl, %edx
movzwl 0x4(%rax,%rcx,2), %ecx
callq 0x13540
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x114a6
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %dx
movl -0x10(%rbp), %eax
addl $0x3, %eax
xorl %ecx, %ecx
movzwl %dx, %esi
movzbl %al, %edx
callq 0x13540
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movw 0x6(%rax), %ax
movw %ax, -0x12(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %edx
movl $0x101, %ecx            # imm = 0x101
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
movl $0x2, %edx
movzwl %cx, %esi
movzwl 0x4(%rax), %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0x3, %edx
movl $0x9, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0x4, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
jmp 0x1179a
movq -0x8(%rbp), %rax
cmpl $0x2, 0x58(%rax)
jne 0x1178a
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
cmpl $0x1, (%rax)
jne 0x115a1
jmp 0x115c0
leaq 0xbd12(%rip), %rdi      # 0x1d2ba
leaq 0xb46c(%rip), %rsi      # 0x1ca1b
movl $0x342, %edx            # imm = 0x342
leaq 0xbcd2(%rip), %rcx      # 0x1d28d
callq 0x3200
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movw 0x4(%rax), %ax
movw %ax, -0x12(%rbp)
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
movl $0x1, %edx
movzwl %cx, %esi
movzwl 0x4(%rax), %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
movl (%rax), %eax
movl $0x2, %edx
movzwl %cx, %esi
movzwl %ax, %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movl $0x3, %edx
movzwl %cx, %esi
movzwl 0x4(%rax), %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movl (%rax), %eax
movl $0x4, %edx
movzwl %cx, %esi
movzwl %ax, %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %ax
movl $0x5, %edx
movzwl %ax, %esi
movzwl -0x12(%rbp), %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0x6, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movl 0x4c(%rax), %eax
movl $0x7, %edx
movzwl %cx, %esi
movzwl %ax, %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movl $0x8, %edx
movzwl %cx, %esi
movzwl 0x50(%rax), %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
movl $0x9, %edx
movzwl %cx, %esi
movzwl %ax, %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0xa, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl $0xb, %edx
movzwl %cx, %esi
movzwl (%rax), %ecx
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0xc, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0xd, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0xe, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0xf, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
movq -0x8(%rbp), %rdi
movl $0x10, %edx
xorl %ecx, %ecx
movzwl -0x12(%rbp), %esi
callq 0x13540
jmp 0x11798
leaq 0xb9f4(%rip), %rdi      # 0x1d185
movb $0x0, %al
callq 0xd140
jmp 0x1179a
addq $0x20, %rsp
popq %rbp
retq