// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/rt11.c
// Function: parse_homeblock
static int parse_homeblock(rt11_filesystem_t *_this) {
	uint16_t w;
	uint8_t *s ;
	int i;
	int sum;

	// bad block bitmap not needed

	// INIT/RESTORE area: ignore
	// BUP ignored

	_this->pack_cluster_size = rt11_image_get_word_at(_this, 1, 0722);
	_this->first_dir_blocknr = rt11_image_get_word_at(_this, 1, 0724);
	if (_this->first_dir_blocknr != 6)
		return error_set(ERROR_FILESYSTEM_FORMAT,
				"parse_homeblock(): first_dir_blocknr expected 6, is %d\n",
				_this->first_dir_blocknr);
	_this->first_dir_blocknr = rt11_image_get_word_at(_this, 1, 0724);
	w = rt11_image_get_word_at(_this, 1, 0726);
	strcpy(_this->system_version, rad50_decode(w));
	// 12 char volume id. V3A, or V05, ...
	s = IMAGE_BLOCKNR2PTR(_this, 1) + 0730;
	strncpy(_this->volume_id, (char *)s, 12);
	_this->volume_id[12] = 0;
	// 12 char owner name
	s = IMAGE_BLOCKNR2PTR(_this, 1) + 0744;
	strncpy(_this->owner_name, (char *)s, 12);
	_this->owner_name[12] = 0;
	// 12 char system id
	s = IMAGE_BLOCKNR2PTR(_this, 1) + 0760;
	strncpy(_this->system_id, (char *)s, 12);
	_this->system_id[12] = 0;
	_this->homeblock_chksum = rt11_image_get_word_at(_this, 1, 0776);
	// verify checksum. But found a RT-11 which writes 0000 here?
	for (sum = i = 0; i < 0776; i += 2)
		sum += rt11_image_get_word_at(_this, 1, i);
	sum &= 0xffff;
	/*
	 if (sum != _this->homeblock_chksum)
	 fprintf(ferr, "Home block checksum error: is 0x%x, expected 0x%x\n", sum,
	 (int) _this->homeblock_chksum);
	 */
	return ERROR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x16740
movzwl %ax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x16740
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x34(%rax)
movq -0x10(%rbp), %rax
movzwl 0x34(%rax), %eax
cmpl $0x6, %eax
je 0x13cf7
movq -0x10(%rbp), %rax
movzwl 0x34(%rax), %edx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x9b3e(%rip), %rsi      # 0x1d826
movb $0x0, %al
callq 0xcd70
movl %eax, -0x4(%rbp)
jmp 0x13e58
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x16740
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x34(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1d6, %edx            # imm = 0x1D6
callq 0x16740
movw %ax, -0x12(%rbp)
movq -0x10(%rbp), %rax
addq $0x36, %rax
movq %rax, -0x30(%rbp)
movzwl -0x12(%rbp), %edi
callq 0xd980
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x30c0
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x200, %rax            # imm = 0x200
addq $0x1d8, %rax            # imm = 0x1D8
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x3a, %rdi
movq -0x20(%rbp), %rsi
movl $0xc, %edx
callq 0x3090
movq -0x10(%rbp), %rax
movb $0x0, 0x46(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x200, %rax            # imm = 0x200
addq $0x1e4, %rax            # imm = 0x1E4
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x47, %rdi
movq -0x20(%rbp), %rsi
movl $0xc, %edx
callq 0x3090
movq -0x10(%rbp), %rax
movb $0x0, 0x53(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x200, %rax            # imm = 0x200
addq $0x1f0, %rax            # imm = 0x1F0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x54, %rdi
movq -0x20(%rbp), %rsi
movl $0xc, %edx
callq 0x3090
movq -0x10(%rbp), %rax
movb $0x0, 0x60(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1fe, %edx            # imm = 0x1FE
callq 0x16740
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x62(%rax)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x1fe, -0x24(%rbp)     # imm = 0x1FE
jge 0x13e46
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x1, %esi
callq 0x16740
movzwl %ax, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x24(%rbp)
jmp 0x13e18
movl -0x28(%rbp), %eax
andl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0x28(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)