// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/xxdp.c
// Function: parse_ufd
static int parse_ufd(xxdp_filesystem_t *_this) {
	unsigned i, j;
	xxdp_blocknr_t blknr; // enumerates the directory blocks
	uint32_t file_entry_start_wordnr;
	uint16_t w;
	for (i = 0; i < _this->ufd_blocklist->count; i++) {
		blknr = _this->ufd_blocklist->blocknr[i];
		// hexdump(ferr, IMAGE_BLOCKNR2PTR(_this, blknr), 512, "Block %u = UFD block %u", blknr, i);
		// 28 dir entries per block
		for (j = 0; j < XXDP_UFD_ENTRIES_PER_BLOCK; j++) {
			xxdp_file_t *f;
			file_entry_start_wordnr = 1 + j * XXDP_UFD_ENTRY_WORDCOUNT; // point to start of file entry in block
			// filename: 2*3 radix50 chars
			w = xxdp_image_get_word(_this, blknr, file_entry_start_wordnr + 0);
			if (w == 0)
				continue; // invalid entry
			// create file entry
			f = malloc(sizeof(xxdp_file_t));
			f->data = NULL; //
			f->filnam[0] = 0;
			f->changed = 0;
			f->fixed = 0;
			// filnam: 6 chars
			strcat(f->filnam, rad50_decode(w));
			w = xxdp_image_get_word(_this, blknr, file_entry_start_wordnr + 1);
			strcat(f->filnam, rad50_decode(w));
			// extension: 3 chars
			w = xxdp_image_get_word(_this, blknr, file_entry_start_wordnr + 2);
			strcpy(f->ext, rad50_decode(w));

			w = xxdp_image_get_word(_this, blknr, file_entry_start_wordnr + 3);
			f->date = dos11date_decode(w);

			// start block, scan blocklist
			w = xxdp_image_get_word(_this, blknr, file_entry_start_wordnr + 5);
			xxdp_blocklist_get(_this, &(f->blocklist), w);

			// check: filelen?
			f->block_count = xxdp_image_get_word(_this, blknr, file_entry_start_wordnr + 6);
			if (f->block_count != f->blocklist.count)
				warning("XXDP UFD read: file %s.%s: saved file size is %d, blocklist len is %d.\n",
						f->filnam, f->ext, f->block_count, f->blocklist.count);

			// check: lastblock?
			w = xxdp_image_get_word(_this, blknr, file_entry_start_wordnr + 7);

			if (_this->file_count >= XXDP_MAX_FILES_PER_IMAGE)
				return error_set(ERROR_FILESYSTEM_OVERFLOW,
						"XXDP UFD read: more than %d files!",
						XXDP_MAX_FILES_PER_IMAGE);
			_this->file[_this->file_count++] = f; //save
		}
	}
	return ERROR_OK ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0xa0(%rcx), %rcx
cmpl (%rcx), %eax
jae 0x1091b
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movl -0x14(%rbp), %ecx
movw 0x4(%rax,%rcx,2), %ax
movw %ax, -0x1a(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x1c, -0x18(%rbp)
jae 0x1090b
imull $0x9, -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movw -0x1a(%rbp), %cx
movl -0x20(%rbp), %eax
addl $0x0, %eax
movzwl %cx, %esi
movzbl %al, %edx
callq 0x13420
movw %ax, -0x22(%rbp)
movzwl -0x22(%rbp), %eax
cmpl $0x0, %eax
jne 0x106b9
jmp 0x108fd
movl $0x8d0, %edi            # imm = 0x8D0
callq 0x33a0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq $0x0, 0x888(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x808(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x8c8(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x8cc(%rax)
movq -0x30(%rbp), %rax
addq $0x808, %rax            # imm = 0x808
movq %rax, -0x88(%rbp)
movzwl -0x22(%rbp), %edi
callq 0xd980
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x3500
movq -0x10(%rbp), %rdi
movw -0x1a(%rbp), %cx
movl -0x20(%rbp), %eax
addl $0x1, %eax
movzwl %cx, %esi
movzbl %al, %edx
callq 0x13420
movw %ax, -0x22(%rbp)
movq -0x30(%rbp), %rax
addq $0x808, %rax            # imm = 0x808
movq %rax, -0x80(%rbp)
movzwl -0x22(%rbp), %edi
callq 0xd980
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x3500
movq -0x10(%rbp), %rdi
movw -0x1a(%rbp), %cx
movl -0x20(%rbp), %eax
addl $0x2, %eax
movzwl %cx, %esi
movzbl %al, %edx
callq 0x13420
movw %ax, -0x22(%rbp)
movq -0x30(%rbp), %rax
addq $0x858, %rax            # imm = 0x858
movq %rax, -0x78(%rbp)
movzwl -0x22(%rbp), %edi
callq 0xd980
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x30c0
movq -0x10(%rbp), %rdi
movw -0x1a(%rbp), %cx
movl -0x20(%rbp), %eax
addl $0x3, %eax
movzwl %cx, %esi
movzbl %al, %edx
callq 0x13420
movw %ax, -0x22(%rbp)
movq -0x30(%rbp), %rax
addq $0x890, %rax            # imm = 0x890
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
movzwl -0x22(%rbp), %esi
callq 0xdd60
movq -0x70(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x38, %edx
callq 0x3330
movq -0x10(%rbp), %rdi
movw -0x1a(%rbp), %cx
movl -0x20(%rbp), %eax
addl $0x5, %eax
movzwl %cx, %esi
movzbl %al, %edx
callq 0x13420
movw %ax, -0x22(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movzwl -0x22(%rbp), %edx
callq 0x13370
movq -0x10(%rbp), %rdi
movw -0x1a(%rbp), %cx
movl -0x20(%rbp), %eax
addl $0x6, %eax
movzwl %cx, %esi
movzbl %al, %edx
callq 0x13420
movw %ax, %cx
movq -0x30(%rbp), %rax
movw %cx, 0x880(%rax)
movq -0x30(%rbp), %rax
movzwl 0x880(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
je 0x1088b
movq -0x30(%rbp), %rsi
addq $0x808, %rsi            # imm = 0x808
movq -0x30(%rbp), %rdx
addq $0x858, %rdx            # imm = 0x858
movq -0x30(%rbp), %rax
movzwl 0x880(%rax), %ecx
movq -0x30(%rbp), %rax
movl (%rax), %r8d
leaq 0xc83f(%rip), %rdi      # 0x1d0c3
movb $0x0, %al
callq 0xd050
movq -0x10(%rbp), %rdi
movw -0x1a(%rbp), %cx
movl -0x20(%rbp), %eax
addl $0x7, %eax
movzwl %cx, %esi
movzbl %al, %edx
callq 0x13420
movw %ax, -0x22(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3e8, 0xa8(%rax)      # imm = 0x3E8
jl 0x108d5
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
leaq 0xc847(%rip), %rsi      # 0x1d10b
movl $0x3e8, %edx            # imm = 0x3E8
movb $0x0, %al
callq 0xcd70
movl %eax, -0x4(%rbp)
jmp 0x10922
movq -0x30(%rbp), %rdx
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rsi
movl 0xa8(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0xa8(%rsi)
movslq %ecx, %rcx
movq %rdx, 0xb0(%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1067a
jmp 0x1090d
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x10646
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop