// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/xxdp.c
// Function: xxdp_filesystem_print_diag
void xxdp_filesystem_print_diag(xxdp_filesystem_t *_this, FILE *stream) {
	xxdp_blocknr_t blknr;
	int file_idx ;
	unsigned i, n;
	char line[256];
	char buff[256];
	int used;
	fprintf(stream, "Filesystem has %d blocks, usage:\n", _this->blockcount);
	for (blknr = 0; blknr < _this->blockcount; blknr++) {
		int blkoffset ;
		line[0] = 0;
		if (blknr == 0) {
			sprintf(buff, " BOOTBLOCK \"%s.%s\"", XXDP_BOOTBLOCK_FILNAM, XXDP_BOOTBLOCK_EXT);
			strcat(line, buff);
		}

		// monitor
		n = _this->monitor->blockcount;
		blkoffset = blknr - _this->monitor->blocknr;
		if (blkoffset >= 0 && blkoffset < (int)n) {
			sprintf(buff, " MONITOR \"%s.%s\" - %d/%d", XXDP_MONITOR_FILNAM, XXDP_MONITOR_EXT,
					blkoffset, n);
			strcat(line, buff);
		}

		// search mfd1, mfd2
		n = _this->mfd_blocklist->count;
		for (i = 0; i < n; i++)
			if (_this->mfd_blocklist->blocknr[i] == blknr) {
				sprintf(buff, " MFD - %d/%d", i, n);
				strcat(line, buff);
			}
		// search ufd
		n = _this->ufd_blocklist->count;
		for (i = 0; i < n; i++)
			if (_this->ufd_blocklist->blocknr[i] == blknr) {
				sprintf(buff, " UFD - %d/%d", i, n);
				strcat(line, buff);
			}
		// search bitmap
		n = _this->bitmap->blocklist.count;
		for (i = 0; i < n; i++)
			if (_this->bitmap->blocklist.blocknr[i] == blknr) {
				sprintf(buff, " BITMAP - %d/%d", i, n);
				strcat(line, buff);
			}
		// search file
		for (file_idx = 0; file_idx < _this->file_count; file_idx++) {
			unsigned j ;
			xxdp_file_t *f = _this->file[file_idx];
			n = f->blocklist.count;
			for (j = 0; j < n; j++)
				if (f->blocklist.blocknr[j] == blknr) {
					sprintf(buff, " file #%d: \"%s.%s\" - %d/%d", file_idx, f->filnam, f->ext, j, n);
					strcat(line, buff);
				}
		}
		// block marked in bitmap?
		used = _this->bitmap->used[blknr];
		if ((!used && line[0]) || (used && !line[0])) {
			sprintf(buff, " Bitmap mismatch, marked as %s!", used ? "USED" : "NOT USED");
			strcat(line, buff);
		}
		if (line[0]) {
			int offset = (IMAGE_BLOCKNR2PTR(_this, blknr) - IMAGE_BLOCKNR2PTR(_this, 0));
			fprintf(stream, "%5d @ 0x%06x = %#08o:  %s\n", blknr, offset, offset, line);
		}
	}
	n = xxdp_bitmap_count(_this);
	fprintf(stream, "Blocks marked as \"used\" in bitmap: %d. Free: %d - %d = %d.\n", n,
			_this->blockcount, n, _this->blockcount - n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x4c(%rax), %edx
leaq 0x9d9c(%rip), %rsi      # 0x1cbc1
movb $0x0, %al
callq 0x3300
movw $0x0, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4c(%rcx), %eax
jae 0x13244
movb $0x0, -0x120(%rbp)
movzwl -0x12(%rbp), %eax
cmpl $0x0, %eax
jne 0x12e89
leaq -0x220(%rbp), %rdi
leaq 0x9d82(%rip), %rsi      # 0x1cbe3
leaq 0x9d42(%rip), %rdx      # 0x1cbaa
leaq 0x9c73(%rip), %rcx      # 0x1cae2
movb $0x0, %al
callq 0x3520
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3500
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x20(%rbp)
movzwl -0x12(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x88(%rcx), %rcx
movzwl (%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x228(%rbp)
cmpl $0x0, -0x228(%rbp)
jl 0x12f0a
movl -0x228(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x12f0a
leaq -0x220(%rbp), %rdi
movl -0x228(%rbp), %r8d
movl -0x20(%rbp), %r9d
leaq 0x9d14(%rip), %rsi      # 0x1cbf6
leaq 0x9cbb(%rip), %rdx      # 0x1cba4
leaq 0x9c15(%rip), %rcx      # 0x1cb05
movb $0x0, %al
callq 0x3520
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3500
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x12f7f
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movl -0x1c(%rbp), %ecx
movzwl 0x4(%rax,%rcx,2), %eax
movzwl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jne 0x12f72
leaq -0x220(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x9cb7(%rip), %rsi      # 0x1cc0f
movb $0x0, %al
callq 0x3520
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3500
jmp 0x12f74
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x12f21
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x12ff4
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
movl -0x1c(%rbp), %ecx
movzwl 0x4(%rax,%rcx,2), %eax
movzwl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jne 0x12fe7
leaq -0x220(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x9c4f(%rip), %rsi      # 0x1cc1c
movb $0x0, %al
callq 0x3520
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3500
jmp 0x12fe9
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x12f96
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x13069
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movl -0x1c(%rbp), %ecx
movzwl 0x4(%rax,%rcx,2), %eax
movzwl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jne 0x1305c
leaq -0x220(%rbp), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x9be7(%rip), %rsi      # 0x1cc29
movb $0x0, %al
callq 0x3520
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3500
jmp 0x1305e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1300b
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xa8(%rcx), %eax
jge 0x13153
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq 0xb0(%rax,%rcx,8), %rax
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x22c(%rbp)
movl -0x22c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x13143
movq -0x238(%rbp), %rax
movl -0x22c(%rbp), %ecx
movzwl 0x4(%rax,%rcx,2), %eax
movzwl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jne 0x1312d
leaq -0x220(%rbp), %rdi
movl -0x18(%rbp), %edx
movq -0x238(%rbp), %rcx
addq $0x808, %rcx            # imm = 0x808
movq -0x238(%rbp), %r8
addq $0x858, %r8             # imm = 0x858
movl -0x22c(%rbp), %r9d
movl -0x20(%rbp), %eax
leaq 0x9b29(%rip), %rsi      # 0x1cc39
movl %eax, (%rsp)
movb $0x0, %al
callq 0x3520
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3500
jmp 0x1312f
movl -0x22c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x22c(%rbp)
jmp 0x130b0
jmp 0x13145
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x13070
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movzwl -0x12(%rbp), %ecx
movzbl 0x804(%rax,%rcx), %eax
movl %eax, -0x224(%rbp)
cmpl $0x0, -0x224(%rbp)
jne 0x13185
movsbl -0x120(%rbp), %eax
cmpl $0x0, %eax
jne 0x13197
cmpl $0x0, -0x224(%rbp)
je 0x131da
cmpb $0x0, -0x120(%rbp)
jne 0x131da
leaq -0x220(%rbp), %rdi
movl -0x224(%rbp), %ecx
leaq 0x9ac9(%rip), %rdx      # 0x1cc74
leaq 0x9ac6(%rip), %rax      # 0x1cc78
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x9a94(%rip), %rsi      # 0x1cc54
movb $0x0, %al
callq 0x3520
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3500
cmpb $0x0, -0x120(%rbp)
je 0x13231
movq -0x8(%rbp), %rax
movq (%rax), %rax
movzwl -0x12(%rbp), %ecx
shll $0x9, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x23c(%rbp)
movq -0x10(%rbp), %rdi
movzwl -0x12(%rbp), %edx
movl -0x23c(%rbp), %ecx
movl -0x23c(%rbp), %r8d
leaq -0x120(%rbp), %r9
leaq 0x9a53(%rip), %rsi      # 0x1cc7d
movb $0x0, %al
callq 0x3300
jmp 0x13233
movw -0x12(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x12(%rbp)
jmp 0x12e32
movq -0x8(%rbp), %rdi
callq 0x12cf0
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0x4c(%rax), %ecx
movl -0x20(%rbp), %r8d
movq -0x8(%rbp), %rax
movl 0x4c(%rax), %r9d
subl -0x20(%rbp), %r9d
leaq 0x9a23(%rip), %rsi      # 0x1cc98
movb $0x0, %al
callq 0x3300
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopw %cs:(%rax,%rax)