LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_create
image_t *image_create(device_type_t dec_device, int unit, int forced_data_size) {
	int block_count;
	image_t *_this;
	_this = malloc(sizeof(image_t));
	pthread_mutex_init(&_this->mutex, NULL);
	_this->open = 0;
	_this->changed = 0;
	_this->changedblocks = NULL;
	_this->host_fpath = NULL;
	_this->pdp_filesystem = NULL;
	_this->hostdir = NULL;
	_this->dec_filesystem = fsNONE;
	_this->dec_device = dec_device;
	_this->unit = unit;
	_this->device_info = (device_info_t*) search_tagged_array(device_info_table,
			sizeof(device_info_t), dec_device);
	assert(_this->device_info);

	// create data buffer, not yet extended
	_this->blocksize = 512; // all devices

	_this->forced_blockcount = NEEDED_BLOCKS(_this->blocksize, forced_data_size);

	if (_this->forced_blockcount) { // correct range
		if (_this->forced_blockcount < _this->device_info->block_count)
			_this->forced_blockcount = _this->device_info->block_count;
		else if (_this->forced_blockcount > _this->device_info->max_block_count)
			_this->forced_blockcount = _this->device_info->max_block_count;
		block_count = _this->forced_blockcount;
	} else
		block_count = _this->device_info->block_count;
	_this->data_size = block_count * _this->blocksize;
	_this->data = malloc(_this->data_size);
	_this->changedblocks = boolarray_create(IMAGE_MAX_BLOCKS);

	return _this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %ebp
movl %edi, %r15d
movl $0x128, %edi            # imm = 0x128
callq 0x33b0
movq %rax, %rbx
leaq 0x8(%rax), %rdi
xorl %esi, %esi
callq 0x35a0
andw $0x0, 0xf4(%rbx)
andq $0x0, 0xf8(%rbx)
andq $0x0, 0x30(%rbx)
andl $0x0, 0x10c(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xd8(%rbx)
movl %r15d, 0x108(%rbx)
movl %ebp, (%rbx)
leaq 0x14d97(%rip), %rdi     # 0x1c4b0
pushq $0x20
popq %rsi
movl %r15d, %edx
callq 0xa77f
movq %rax, 0xe8(%rbx)
testq %rax, %rax
je 0x77a5
movq %rax, %rcx
movl $0x200, %esi            # imm = 0x200
movl %esi, 0xf0(%rbx)
leal 0x1ff(%r14), %eax
cltd
idivl %esi
movl %eax, 0x40(%rbx)
addl $0x3fe, %r14d           # imm = 0x3FE
movl 0x18(%rcx), %edx
cmpl $0x3ff, %r14d           # imm = 0x3FF
jb 0x776c
cmpl %edx, %eax
jl 0x7769
movl 0x1c(%rcx), %edx
cmpl %edx, %eax
jle 0x776e
movl %edx, 0x40(%rbx)
movl %edx, %eax
shll $0x9, %eax
movl %eax, 0x110(%rbx)
movq %rax, %rdi
callq 0x33b0
movq %rax, 0x118(%rbx)
movl $0xf4240, %edi          # imm = 0xF4240
callq 0xa79c
movq %rax, 0xf8(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc5f7(%rip), %rdi      # 0x13da3
leaq 0xc603(%rip), %rsi      # 0x13db6
leaq 0xc604(%rip), %rcx      # 0x13dbe
pushq $0x74
popq %rdx
callq 0x3200
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_lseek
int image_lseek(image_t *_this, int offset, int whence) {
	int newpos = _this->seekpos;
	if (!_this->open)
		return error_set(ERROR_IMAGE_MODE, "image_lseek(): closed unit %d", _this->unit);
	switch (whence) {
	case SEEK_SET:
		newpos = offset;
		break;
	case SEEK_CUR:
		newpos = _this->seekpos + offset;
		break;
	case SEEK_END:
		newpos = _this->data_size + offset;
		break;
	default:
		return error_set(ERROR_ILLPARAMVAL, "image_lseek(): invalid option");
	}
	_this->seekpos = newpos;
	return newpos;
}

// Assembly:
cmpb $0x0, 0xf4(%rdi)
je 0x7bb6
leaq 0x120(%rdi), %rax
testl %edx, %edx
je 0x7bb1
movq %rax, %rcx
cmpl $0x1, %edx
je 0x7baf
cmpl $0x2, %edx
jne 0x7bc9
addq $0x110, %rdi            # imm = 0x110
movq %rdi, %rcx
addl (%rcx), %esi
movl %esi, (%rax)
movl %esi, %eax
retq
movl (%rdi), %edx
leaq 0xc2de(%rip), %rsi      # 0x13e9d
pushq $-0x8
popq %rdi
xorl %eax, %eax
jmp 0x982c
leaq 0xc2eb(%rip), %rsi      # 0x13ebb
pushq $-0x7
popq %rdi
xorl %eax, %eax
jmp 0x982c
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_blockseek
int image_blockseek(image_t *_this, int32_t blocksize, int32_t blocknr, int32_t offset) {
	int result = 0;
	if (!_this->open)
		return error_set(ERROR_IMAGE_MODE, "image_blockseek(): closed unit %d", _this->unit);

	image_lock(_this);
	// change pos to end to testsize ?
	if (blocknr * blocksize + offset > image_lseek(_this, 0, SEEK_END))
		result = ERROR_IMAGE_EOF;
	else if (image_lseek(_this, blocknr * blocksize + offset, SEEK_SET) < 0)
		result = ERROR_IMAGE_EOF;
	else
		result = ERROR_OK;
	image_unlock(_this);

	return error_set(result, "Seek error within tape block");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
cmpb $0x0, 0xf4(%rdi)
je 0x7c1f
movl %ecx, %r15d
movl %edx, %ebp
movl %esi, %r12d
leaq 0x8(%r14), %rbx
movq %rbx, %rdi
callq 0x35c0
imull %r12d, %ebp
addl %r15d, %ebp
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x7b84
cmpl %eax, %ebp
jle 0x7c3b
pushq $-0x9
popq %rbp
jmp 0x7c4f
movl (%r14), %edx
leaq 0xc2b0(%rip), %rsi      # 0x13ed9
pushq $-0x8
popq %rdi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x982c
movq %r14, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x7b84
movl %eax, %ebp
sarl $0x1f, %ebp
andl $-0x9, %ebp
movq %rbx, %rdi
callq 0x33a0
leaq 0xc29d(%rip), %rsi      # 0x13efb
movl %ebp, %edi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x982c
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_read
int image_read(image_t *_this, void *buf, int32_t count) {
	int bytesleft;
	uint8_t *src;
	if (!_this->open)
		return error_set(ERROR_IMAGE_MODE, "image_read(): closed unit %d", _this->unit);
	image_lock(_this);

	// read until count or end, set seekpos
	bytesleft = _this->data_size - _this->seekpos;
	if (count > bytesleft) {
		count = bytesleft;
	}
	src = _this->data + _this->seekpos;
	memcpy(buf, src, count);
	_this->seekpos += count;

	image_unlock(_this);
	return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
cmpb $0x0, 0xf4(%rdi)
je 0x7cd7
movl %edx, %ebp
movq %rsi, %r14
leaq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x35c0
movl 0x110(%rbx), %eax
movl 0x120(%rbx), %esi
subl %esi, %eax
cmpl %ebp, %eax
cmovgel %ebp, %eax
addq 0x118(%rbx), %rsi
movslq %eax, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0x3340
addl %r12d, 0x120(%rbx)
movq %r15, %rdi
callq 0x33a0
movl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %edx
leaq 0xc238(%rip), %rsi      # 0x13f18
pushq $-0x8
popq %rdi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x982c
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_write
int image_write(image_t *_this, void *buf, int32_t count) {
	int bytesleft;
	uint8_t *dest;
	uint32_t blknr;
	if (!_this->open)
		return error_set(ERROR_IMAGE_MODE, "image_write(): closed unit %d", _this->unit);

	if (_this->readonly)
		return error_set(ERROR_IMAGE_MODE, "unit %d read only", _this->unit);

	image_lock(_this);

	bytesleft = _this->data_size - _this->seekpos;
	if (count > bytesleft)
		count = bytesleft;

	dest = _this->data + _this->seekpos;
	memcpy(dest, buf, count);

	// set dirty
	_this->changed = 1;
	_this->changetime_ms = now_ms();
	// mark all block in range
	for (blknr = _this->seekpos / _this->blocksize;
			blknr < (_this->seekpos + count) / _this->blocksize; blknr++)
		boolarray_bit_set(_this->changedblocks, blknr);
	// boolarray_print_diag(_this->changedblocks, stderr, _this->block_count, "IMAGE");
	_this->seekpos += count;

	image_unlock(_this);
	return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
cmpb $0x0, 0xf4(%rdi)
je 0x7d17
cmpl $0x0, 0x3c(%rbx)
je 0x7d32
movl (%rbx), %edx
leaq 0xc269(%rip), %rsi      # 0x13f7e
jmp 0x7d20
movl (%rbx), %edx
leaq 0xc215(%rip), %rsi      # 0x13f35
pushq $-0x8
popq %rdi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x982c
movl %edx, %r12d
movq %rsi, %r15
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x35c0
movl 0x110(%rbx), %ebp
movl 0x120(%rbx), %edi
subl %edi, %ebp
cmpl %r12d, %ebp
cmovgel %r12d, %ebp
addq 0x118(%rbx), %rdi
movslq %ebp, %rdx
movq %r15, %rsi
callq 0x3340
movb $0x1, 0xf5(%rbx)
xorl %eax, %eax
callq 0x9c9e
movq %rax, 0x100(%rbx)
movl 0xf0(%rbx), %esi
movl 0x120(%rbx), %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %esi
movl %eax, %r15d
addl %ebp, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %esi
cmpl %eax, %r15d
jae 0x7dc2
movq 0xf8(%rbx), %rdi
movl %r15d, %esi
callq 0xa7f9
incl %r15d
movl 0xf0(%rbx), %esi
movl 0x120(%rbx), %ecx
jmp 0x7d95
movl %ecx, 0x120(%rbx)
movq %r14, %rdi
callq 0x33a0
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_save
int image_save(image_t *_this) {
	if (!_this->open)
		return error_set(ERROR_IMAGE_MODE, "image_save(): closed unit %d", _this->unit);

	if (_this->readonly)
		return error_set(ERROR_IMAGE_MODE, "image_save(): unit %d read only", _this->unit);
	if (opt_verbose)
		info("unit %d: saving %s image to %s\"%s\"'", _this->unit,
				_this->changed ? "changed" : "unchanged", _this->shared ? "shared " : "",
				_this->host_fpath);

	image_lock(_this);
	if (_this->shared) {
		if (hostdir_save(_this->hostdir))
			error_set(error_code, "hostdir_save failed");
	} else {
		if (image_hostfile_save(_this))
			error_set(error_code, "image_hostfile_save failed");
	}
	if (!error_code) {
		_this->changed = 0;
		boolarray_clear(_this->changedblocks);
	}
	image_unlock(_this);
	return error_code;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x0, 0xf4(%rdi)
je 0x7dff
cmpl $0x0, 0x3c(%rbx)
je 0x7e1c
movl (%rbx), %edx
leaq 0xc173(%rip), %rsi      # 0x13f70
jmp 0x7e08
movl (%rbx), %edx
leaq 0xc14b(%rip), %rsi      # 0x13f53
pushq $-0x8
popq %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x982c
leaq 0x14c41(%rip), %rax     # 0x1ca64
cmpl $0x0, (%rax)
je 0x7e6b
cmpb $0x0, 0xf5(%rbx)
leaq 0xc17e(%rip), %rax      # 0x13fb4
leaq 0xc179(%rip), %rdx      # 0x13fb6
cmoveq %rax, %rdx
movl (%rbx), %esi
cmpl $0x0, 0x38(%rbx)
leaq 0xc98d(%rip), %rax      # 0x147db
leaq 0xc169(%rip), %rcx      # 0x13fbe
cmoveq %rax, %rcx
movq 0x30(%rbx), %r8
leaq 0xc12c(%rip), %rdi      # 0x13f90
xorl %eax, %eax
callq 0x99c3
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x35c0
cmpl $0x0, 0x38(%rbx)
je 0x7ead
movq 0xd8(%rbx), %rdi
callq 0x8fec
testl %eax, %eax
je 0x7f77
leaq 0x163a0(%rip), %rax     # 0x1e238
movl (%rax), %edi
leaq 0xc125(%rip), %rsi      # 0x13fc6
xorl %eax, %eax
callq 0x982c
jmp 0x7f77
movq 0x30(%rbx), %rdi
pushq $0x2
popq %rsi
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x34a0
testl %eax, %eax
js 0x7f2c
movl %eax, %ebp
movl 0x10c(%rbx), %edi
testl %edi, %edi
je 0x7f5c
movl 0x3c(%rbx), %edx
movl 0x108(%rbx), %esi
movq 0x118(%rbx), %rcx
movl 0x110(%rbx), %r8d
xorl %r9d, %r9d
callq 0xac8b
movq %rax, %r15
movq %rax, %rdi
callq 0xadbf
movq %r15, %rdi
callq 0xb1a3
movq 0x118(%rbx), %rsi
movl 0x110(%rbx), %edx
movl %ebp, %edi
callq 0x3140
movq %r15, %rdi
callq 0xb17a
movq %r15, %rdi
callq 0xad3a
jmp 0x7f70
movl (%rbx), %edx
movq 0x30(%rbx), %rcx
leaq 0xc203(%rip), %rsi      # 0x1413c
pushq $-0x6
popq %rdi
xorl %eax, %eax
callq 0x982c
testl %eax, %eax
je 0x7f77
leaq 0x162ea(%rip), %rax     # 0x1e238
movl (%rax), %edi
leaq 0xc083(%rip), %rsi      # 0x13fda
jmp 0x7ea1
movq 0x118(%rbx), %rsi
movl 0x110(%rbx), %edx
movl %ebp, %edi
callq 0x3140
movl %ebp, %edi
callq 0x3260
leaq 0x162ba(%rip), %r15     # 0x1e238
cmpl $0x0, (%r15)
jne 0x7f97
movb $0x0, 0xf5(%rbx)
movq 0xf8(%rbx), %rdi
callq 0xa7ce
movq %r14, %rdi
callq 0x33a0
movl (%r15), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_sync
int image_sync(image_t *_this) {
	int result = ERROR_OK;
	if (_this->open) {
		if (_this->shared) {
			// merge files in the image and the shared directory
			image_lock(_this);
			hostdir_sync(_this->hostdir);
			image_unlock(_this);
		} else {
			// just save the image file
			if (_this->changed)
				result = image_save(_this);
		}
	}
	boolarray_clear(_this->changedblocks);
	return result;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %ebp, %ebp
cmpb $0x0, 0xf4(%rdi)
je 0x7ffa
cmpl $0x0, 0x38(%rbx)
je 0x7fe7
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x35c0
movq 0xd8(%rbx), %rdi
callq 0x9082
movq %r14, %rdi
callq 0x33a0
jmp 0x7ffa
cmpb $0x0, 0xf5(%rbx)
je 0x7ffa
movq %rbx, %rdi
callq 0x7ddb
movl %eax, %ebp
movq 0xf8(%rbx), %rdi
callq 0xa7ce
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/image.c
// Function: image_destroy
void image_destroy(image_t *_this) {
	_this->open = 0;
	if (_this->host_fpath)
		free(_this->host_fpath);
	_this->host_fpath = NULL;
	if (_this->data)
		free(_this->data);
	_this->data = NULL;
	_this->data_size = 0;
	if (_this->shared) {
		if (_this->hostdir)
			hostdir_destroy(_this->hostdir);
		if (_this->pdp_filesystem)
			filesystem_destroy(_this->pdp_filesystem);
	}
	free(_this);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movb $0x0, 0xf4(%rdi)
movq 0x30(%rdi), %rdi
callq 0x3050
andq $0x0, 0x30(%rbx)
movq 0x118(%rbx), %rdi
callq 0x3050
andq $0x0, 0x118(%rbx)
andl $0x0, 0x110(%rbx)
cmpl $0x0, 0x38(%rbx)
je 0x8069
movq 0xd8(%rbx), %rdi
testq %rdi, %rdi
je 0x8058
callq 0x8f13
movq 0xe0(%rbx), %rdi
testq %rdi, %rdi
je 0x8069
callq 0xad3a
movq %rbx, %rdi
popq %rbx
jmp 0x3050
nop
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devtxinit
void serial_devtxinit(serial_device_t *serial) {
	// flush all output
	tcflush(serial->fd, TCOFLUSH);

	// reset send buffer
	serial->wcnt = 0;
	serial->wptr = serial->wbuf;

	return;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
pushq $0x1
popq %rsi
callq 0x31b0
andl $0x0, 0x128(%rbx)
leaq 0x20(%rbx), %rax
movq %rax, 0x120(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devrxinit
void serial_devrxinit(serial_device_t *serial) {
	// flush all input
	tcflush(serial->fd, TCIFLUSH);

	// reset receive buffer
	serial->rcnt = 0;
	serial->rptr = serial->rbuf;

	return;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
xorl %esi, %esi
callq 0x31b0
andl $0x0, 0x238(%rbx)
leaq 0x12c(%rbx), %rax
movq %rax, 0x230(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devrxavail
int32_t serial_devrxavail(serial_device_t *serial) {
	// get more characters if none available
	if (serial->rcnt <= 0) {
		serial->rcnt = read(serial->fd, serial->rbuf, sizeof(serial->rbuf));
		serial->rptr = serial->rbuf;
	}
	if (serial->rcnt < 0)
		serial->rcnt = 0;

	// return characters available
	return serial->rcnt;
}

// Assembly:
movl 0x238(%rdi), %eax
testl %eax, %eax
jle 0x80e5
retq
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rdi), %edi
leaq 0x12c(%rbx), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rsi
callq 0x32b0
movl %eax, 0x238(%rbx)
movq %r14, 0x230(%rbx)
testl %eax, %eax
jns 0x811c
andl $0x0, 0x238(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devtxwrite
int32_t serial_devtxwrite(serial_device_t *serial, uint8_t *buf, int32_t cnt) {
	// write characters if asked, return number written
	int32_t result = 0;
	if (cnt > 0) {
		// write is monolitic and may take long
		// make sure serial_tx_lasttime_ms doe not time out
		serial->tx_lasttime_ms = now_ms() + 60000; // signal busy: 1 minute in the future
		result = write(serial->fd, buf, cnt);
		serial->tx_lasttime_ms = now_ms(); // now up to date
	}
	return result;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testl %edx, %edx
jle 0x8161
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorl %eax, %eax
callq 0x9c9e
addq $0xea60, %rax           # imm = 0xEA60
movq %rax, 0x18(%rbx)
movl (%rbx), %edi
movl %ebp, %edx
movq %r14, %rsi
callq 0x3140
movq %rax, %r14
xorl %eax, %eax
callq 0x9c9e
movq %rax, 0x18(%rbx)
jmp 0x8164
xorl %r14d, %r14d
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devtxflush
void serial_devtxflush(serial_device_t *serial) {
	int32_t acnt;

	// write any characters we have
	if (serial->wcnt > 0) {
		if ((acnt = serial_devtxwrite(serial, serial->wbuf, serial->wcnt)) != serial->wcnt)
			error("devtxflush(): write error, expected=%d, actual=%d", serial->wcnt, acnt);
	}

	// buffer is now empty
	serial->wcnt = 0;
	serial->wptr = serial->wbuf;

	// wait until all characters are transmitted
	tcdrain(serial->fd);

	return;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x128(%rdi), %edx
testl %edx, %edx
jle 0x81a0
leaq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0x8124
movl 0x128(%rbx), %esi
cmpl %esi, %eax
je 0x81a0
leaq 0xbfca(%rip), %rdi      # 0x14161
movl %eax, %edx
xorl %eax, %eax
callq 0x98f2
andl $0x0, 0x128(%rbx)
leaq 0x20(%rbx), %rax
movq %rax, 0x120(%rbx)
movl (%rbx), %edi
popq %rbx
jmp 0x3110
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devrxget
uint8_t serial_devrxget(serial_device_t *serial) {
	// get more characters if none available
	while (serial_devrxavail(serial) <= 0)
		/*spin*/;

	serial->rx_lasttime_ms = now_ms(); // signal activity

	// count, return next character
	serial->rcnt--;
	return *(serial->rptr)++;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rbx, %rdi
callq 0x80da
testl %eax, %eax
jle 0x81be
xorl %eax, %eax
callq 0x9c9e
movq %rax, 0x10(%rbx)
decl 0x238(%rbx)
movq 0x230(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x230(%rbx)
movb (%rax), %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devtxput
void serial_devtxput(serial_device_t *serial, uint8_t c) {

	// must flush if hit the end of the buffer
	if (serial->wcnt >= (int)sizeof(serial->wbuf))
		serial_devtxflush(serial);

	// count, add one character to buffer
	serial->wcnt++;
	*(serial->wptr)++ = c;

	serial->tx_lasttime_ms = now_ms(); // signal activity

	return;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movl 0x128(%rdi), %eax
cmpl $0x100, %eax            # imm = 0x100
jl 0x8214
movq %rbx, %rdi
callq 0x816c
movl 0x128(%rbx), %eax
incl %eax
movl %eax, 0x128(%rbx)
movq 0x120(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x120(%rbx)
movb %bpl, (%rax)
xorl %eax, %eax
callq 0x9c9e
movq %rax, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_decode_format
int serial_decode_format(char *formatstr, int *result_bitcount, char *result_parity,
		int *result_stopbits) {
	if (!formatstr || strlen(formatstr) != 3)
		return 1;
	switch (formatstr[0]) {
	case '5':
		*result_bitcount = 5 ;
		break ;
	case '6':
		*result_bitcount = 6 ;
		break ;
	case '7':
		*result_bitcount = 7 ;
		break ;
	case '8':
		*result_bitcount = 8 ;
		break ;
	default: return 1;
	}

	switch (toupper(formatstr[1])) {
	case 'O':
	case 'E':
	case 'N':
		*result_parity = toupper(formatstr[1]) ;
		break ;
	default: return 1;
	}

	switch (formatstr[2]) {
	case '1':
		*result_stopbits = 1 ;
		break ;
	case '2':
		*result_stopbits = 2 ;
		break ;
	default: return 1;
	}
	return 0 ; // all OK
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq $0x1
popq %rbx
testq %rdi, %rdi
je 0x82c1
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
callq 0x3190
cmpq $0x3, %rax
jne 0x82c1
movb (%r12), %al
leal -0x35(%rax), %ecx
cmpb $0x3, %cl
ja 0x82c1
addb $-0x30, %al
movzbl %al, %eax
movl %eax, (%r13)
callq 0x3030
movq (%rax), %rax
movsbq 0x1(%r12), %rcx
movl (%rax,%rcx,4), %eax
leal -0x45(%rax), %ecx
cmpl $0xa, %ecx
ja 0x82c1
movl $0x601, %edx            # imm = 0x601
btl %ecx, %edx
jae 0x82c1
movb %al, (%r15)
movzbl 0x2(%r12), %eax
pushq $0x1
popq %rbx
cmpl $0x31, %eax
je 0x82bc
cmpl $0x32, %eax
jne 0x82c1
pushq $0x2
popq %rbx
movl %ebx, (%r14)
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: serial_devrestore
void serial_devrestore(serial_device_t *serial) {
	tcsetattr(serial->fd, TCSANOW, &serial->lineSave);
	close(serial->fd);
	serial->fd = -1;
	return;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
leaq 0x23c(%rbx), %rdx
xorl %esi, %esi
callq 0x3490
movl (%rbx), %edi
callq 0x3260
orl $-0x1, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: coninit
void coninit(int rawmode) {
	struct termios cons;

	// background mode, don't do anything
	if (opt_background)
		return;

	// get current console parameters
	if (tcgetattr(fileno(stdin), &consSave))
		fatal("stdin not a serial device");

	// copy modes
	cons = consSave;

	// set new modes
	if (rawmode) {
		cfmakeraw(&cons);
	} else {
		cons.c_lflag &= ~( ICANON | ECHO);
	}

	// now set param
	tcflush(fileno(stdin), TCIFLUSH);
	tcsetattr(fileno(stdin), TCSANOW, &cons);

	// set non-blocking reads
	if (fcntl(fileno(stdin), F_SETFL, FNDELAY) == -1)
		error("stdin failed to set non-blocking read");

	return;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
leaq 0x14500(%rip), %rax     # 0x1ca7c
cmpl $0x0, (%rax)
jne 0x8649
movl %edi, %ebx
movq 0x13a4a(%rip), %r14     # 0x1bfd8
movq (%r14), %rdi
callq 0x3370
leaq 0x15ba3(%rip), %rsi     # 0x1e140
movl %eax, %edi
callq 0x3480
testl %eax, %eax
je 0x85b6
leaq 0xbc40(%rip), %rdi      # 0x141ef
xorl %eax, %eax
callq 0x9b87
movups 0x15baf(%rip), %xmm0    # 0x1e16c
movups %xmm0, 0x2c(%rsp)
movups 0x15b97(%rip), %xmm0    # 0x1e160
movaps %xmm0, 0x20(%rsp)
movups 0x15b7b(%rip), %xmm0    # 0x1e150
movaps %xmm0, 0x10(%rsp)
movups 0x15b5f(%rip), %xmm0    # 0x1e140
movaps %xmm0, (%rsp)
testl %ebx, %ebx
je 0x85f3
movq %rsp, %rdi
callq 0x3430
jmp 0x85f8
andb $-0xb, 0xc(%rsp)
movq (%r14), %rdi
callq 0x3370
movl %eax, %edi
xorl %esi, %esi
callq 0x31b0
movq (%r14), %rdi
callq 0x3370
movq %rsp, %rdx
movl %eax, %edi
xorl %esi, %esi
callq 0x3490
movq (%r14), %rdi
callq 0x3370
pushq $0x4
popq %rsi
movl %eax, %edi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x3120
cmpl $-0x1, %eax
jne 0x8649
leaq 0xbbc7(%rip), %rdi      # 0x14209
xorl %eax, %eax
callq 0x98f2
addq $0x48, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/serial.c
// Function: conget
int32_t conget(void) {
	char buf[1];
	int32_t s;

	// background mode, don't return anything
	if (opt_background)
		return -1;

	// try to read at most one char (may be none)
	s = read(fileno(stdin), buf, sizeof(buf));

	// if got a char return it, else return -1
	return s == 1 ? *buf : -1;
}

// Assembly:
leaq 0x143f6(%rip), %rax     # 0x1ca7c
cmpl $0x0, (%rax)
je 0x868f
pushq $-0x1
popq %rax
retq
pushq %rbx
subq $0x10, %rsp
movq 0x1393d(%rip), %rax     # 0x1bfd8
movq (%rax), %rdi
callq 0x3370
leaq 0xf(%rsp), %rbx
pushq $0x1
popq %rdx
movl %eax, %edi
movq %rbx, %rsi
callq 0x32b0
cmpl $0x1, %eax
movsbl (%rbx), %ecx
pushq $-0x1
popq %rax
cmovel %ecx, %eax
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: snapshot_file_find
hostdir_file_t *snapshot_file_find(hostdir_snapshot_t *_this, char *pdp_filename_ext) {
	int i;
	hostdir_file_t *result = NULL;
	for (i = 0; !result && i < _this->file_count; i++) {
		if (!strcasecmp(_this->file[i].pdp_filnam_ext_stream, pdp_filename_ext))
			result = &_this->file[i]; // found
	}
	return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rdi), %r15
xorl %r12d, %r12d
xorl %eax, %eax
testq %rax, %rax
jne 0x870f
movslq 0x8(%r14), %rcx
cmpq %rcx, %r12
jge 0x870f
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3060
incq %r12
testl %eax, %eax
movl $0x0, %eax
cmoveq %r15, %rax
addq $0x150, %r15            # imm = 0x150
jmp 0x86df
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: snapshot_file_register
hostdir_file_t *snapshot_file_register(hostdir_snapshot_t *_this, char *pdp_filename_ext,
		hostdir_side_t side) {
	hostdir_file_t *result;
	result = snapshot_file_find(_this, pdp_filename_ext);
	if (result && result->state[OTHER_SIDE(side)] == fs_created) {
		// Special logic: if a file is create on both sides simultanuously
		// it is found by the 2nd side, because 1st side allocated it.
		// so do not create a 2nd time but mark as "created"
		// It ois NOT possible that the 1st side "created" and the 2nd side had the file before:
		// the snapshot shows only a synchronized state with same files on both sides.
		result->state[side] = fs_created;
	}
	if (!result) {
		assert(_this->file_count < HOSTDIR_MAX_FILES);
		result = &_this->file[_this->file_count++];
		memset(result, 0, sizeof(hostdir_file_t));
		strcpy(result->pdp_filnam_ext_stream, pdp_filename_ext);
		result->state[side] = fs_created;
		result->state[OTHER_SIDE(side)] = fs_missing;
	}
	return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
callq 0x86c8
testq %rax, %rax
je 0x875b
movq %rax, %r14
xorl %eax, %eax
testl %ebx, %ebx
sete %al
cmpl $0x3, 0x128(%r14,%rax,4)
jne 0x87bd
movl %ebx, %eax
movl $0x3, 0x128(%r14,%rax,4)
jmp 0x87bd
movslq 0x8(%r12), %rax
cmpq $0x3e8, %rax            # imm = 0x3E8
jge 0x87ca
imulq $0x150, %rax, %rcx      # imm = 0x150
leaq (%r12,%rcx), %r13
incl %eax
movl %eax, 0x8(%r12)
leaq (%r12,%rcx), %r14
addq $0x10, %r14
movl $0x150, %edx            # imm = 0x150
movq %r14, %rdi
xorl %esi, %esi
callq 0x3220
movq %r14, %rdi
movq %r15, %rsi
callq 0x30c0
movl %ebx, %eax
movl $0x3, 0x138(%r13,%rax,4)
xorl %eax, %eax
testl %ebx, %ebx
sete %al
movl $0x1, 0x138(%r13,%rax,4)
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xbb77(%rip), %rdi      # 0x14348
leaq 0xbb96(%rip), %rsi      # 0x1436e
leaq 0xbb99(%rip), %rcx      # 0x14378
pushq $0x78
popq %rdx
callq 0x3200
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: state_text
char *state_text(hostdir_side_t side, hostdir_file_state_t state) {
	static char buff[2][80];
	char *statetxt[] = { "unchanged", "missing", "changed", "created" };
	char *sidetxt[] = { "PDP", "host" };
	char *result = buff[side]; // static buffer for each side
	sprintf(result, "%s on %s", statetxt[state], sidetxt[side]);
	return result;
}

// Assembly:
pushq %rbx
movl %edi, %eax
imulq $0x50, %rax, %rcx
leaq 0x1599b(%rip), %rbx     # 0x1e190
addq %rcx, %rbx
movl %esi, %ecx
leaq 0xbb2f(%rip), %rsi      # 0x14330
movslq (%rsi,%rcx,4), %rdx
addq %rsi, %rdx
leaq 0xbb31(%rip), %rsi      # 0x14340
movslq (%rsi,%rax,4), %rcx
addq %rsi, %rcx
leaq 0xbbc1(%rip), %rsi      # 0x143de
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3530
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: hostdir_from_pdp_fs
int hostdir_from_pdp_fs(hostdir_t *_this) {
	char pathbuff[4096];
	int fileidx;
	struct utimbuf ut;
	// known filesystems have max 3 special files (RT11)
	for (fileidx = -FILESYSTEM_MAX_SPECIALFILE_COUNT; fileidx < *_this->pdp_fs->file_count;
			fileidx++) {
		int i;
		file_t *f = filesystem_file_get(_this->pdp_fs, fileidx);
		if (f)
			for (i = 0; i < FILESYSTEM_MAX_DATASTREAM_COUNT; i++)
				if (f->stream[i].valid) {
					file_stream_t *stream = &f->stream[i];
					sprintf(pathbuff, "%s/%s", _this->path,
							filesystem_filename_to_host(_this->pdp_fs, f->filnam, f->ext,
									stream->name));
					file_write(pathbuff, stream->data, stream->data_size);
					if (fileidx >= 0) {
						// regular file, not bootblock or monitor: set original file date
						ut.modtime = mktime(&f->date);
						ut.actime = mktime(&f->date);
						utime(pathbuff, &ut);
					}
				}
	}
	return ERROR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1038, %rsp           # imm = 0x1038
movq %rdi, 0x10(%rsp)
leaq 0x4(%rdi), %rax
movq %rax, 0x18(%rsp)
pushq $-0x9
popq %rsi
movq 0x10(%rsp), %rax
movq 0x1008(%rax), %rdi
movq 0x18(%rdi), %rax
cmpl (%rax), %esi
jge 0x8c59
movl %esi, 0xc(%rsp)
callq 0xaedb
testq %rax, %rax
je 0x8c4e
movq %rax, %rbx
leaq 0x50(%rax), %r15
leaq 0x1b0(%rax), %r14
movq %rax, %r13
addq $0x88, %r13
pushq $0x3
popq %rbp
subq $0x1, %rbp
jb 0x8c4e
cmpl $0x0, -0x10(%r13)
je 0x8c45
movq 0x10(%rsp), %rax
movq 0x1008(%rax), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0xb20a
leaq 0x30(%rsp), %r12
movq %r12, %rdi
leaq 0xb899(%rip), %rsi      # 0x1448f
movq 0x18(%rsp), %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x3530
movq -0x8(%r13), %rsi
movl -0xc(%r13), %edx
movq %r12, %rdi
callq 0x9df9
cmpl $0x0, 0xc(%rsp)
js 0x8c45
movq %r14, %rdi
callq 0x33f0
movq %rax, 0x28(%rsp)
movq %r14, %rdi
callq 0x33f0
movq %rax, 0x20(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x3040
addq $0x68, %r13
jmp 0x8bbc
movl 0xc(%rsp), %esi
incl %esi
jmp 0x8b77
xorl %eax, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: hostdir_create
hostdir_t *hostdir_create(int unit, char *path, filesystem_t *pdp_fs) {
	hostdir_t *_this;
	_this = malloc(sizeof(hostdir_t));
	_this->unit = unit ;
	strcpy(_this->path, path);
	_this->pdp_fs = pdp_fs;

	_this->snapshot.hostdir = _this ;
	_this->snapshot.file_count = 0;
	return _this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
movl $0x530a8, %edi          # imm = 0x530A8
callq 0x33b0
movq %rax, %r15
movl %ebp, (%rax)
leaq 0x4(%rax), %rdi
movq %r14, %rsi
callq 0x30c0
movq %rbx, 0x1008(%r15)
movq %r15, 0x1010(%r15)
andl $0x0, 0x1018(%r15)
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: hostdir_load
int hostdir_load(hostdir_t *_this, int allowcreate, int *created) {

	if (hostdir_prepare(_this, /*wipe*/0, allowcreate, created)) {
		error("Unit %d: hostdir_prepare() failed", _this->unit);
		return -1;
	}
	if (opt_verbose && *created)
		info("Unit %d: Host directory \"%s\" created", _this->unit, _this->path);

	return hostdir_image_reload(_this);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %edx
movq %rdi, %rbx
xorl %esi, %esi
movq %r14, %rcx
callq 0x882c
testl %eax, %eax
je 0x8f47
movl (%rbx), %esi
leaq 0xb5f4(%rip), %rdi      # 0x1452f
xorl %eax, %eax
callq 0x98f2
pushq $-0x1
popq %rax
jmp 0x8f77
leaq 0x13b16(%rip), %rax     # 0x1ca64
cmpl $0x0, (%rax)
je 0x8f6d
cmpl $0x0, (%r14)
je 0x8f6d
movl (%rbx), %esi
leaq 0x4(%rbx), %rdx
leaq 0xb5eb(%rip), %rdi      # 0x14551
xorl %eax, %eax
callq 0x99c3
movq %rbx, %rdi
callq 0x8f7f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: hostdir_image_reload
static int hostdir_image_reload(hostdir_t *_this) {
	filesystem_init(_this->pdp_fs);
	hostdir_to_pdp_fs(_this); //  dir => filesystem
	filesystem_render(_this->pdp_fs); // filesystem => image
	if (opt_debug)
		filesystem_print_dir(_this->pdp_fs, ferr);
	if (opt_debug)
		filesystem_print_diag(_this->pdp_fs, ferr);

	snapshot_init(_this);
	return ERROR_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x1008(%rdi), %rdi
callq 0xad85
movq %rbx, %rdi
callq 0x8c6d
movq 0x1008(%rbx), %rdi
callq 0xb14b
leaq 0x13ac6(%rip), %r14     # 0x1ca74
cmpl $0x0, (%r14)
je 0x8fdf
movq 0x1008(%rbx), %rdi
leaq 0x1526e(%rip), %r15     # 0x1e230
movq (%r15), %rsi
callq 0xb1cc
cmpl $0x0, (%r14)
je 0x8fdf
movq 0x1008(%rbx), %rdi
movq (%r15), %rsi
callq 0xb1eb
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x97df
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: hostdir_save
int hostdir_save(hostdir_t *_this) {
	if (hostdir_prepare(_this, /*wipe*/1, 0, NULL))
		return error_set(error_code, "Unit %d: Saving host dir", _this->unit);
	filesystem_init(_this->pdp_fs);
	filesystem_parse(_this->pdp_fs); // image => filesystem
	hostdir_from_pdp_fs(_this); // filesystem => dir
	if (opt_debug)
		filesystem_print_dir(_this->pdp_fs, ferr);
	if (opt_debug)
		filesystem_print_diag(_this->pdp_fs, ferr);
	return ERROR_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x882c
testl %eax, %eax
je 0x9022
leaq 0x1522d(%rip), %rax     # 0x1e238
movl (%rax), %edi
movl (%rbx), %edx
leaq 0xb560(%rip), %rsi      # 0x14576
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x982c
movq 0x1008(%rbx), %rdi
callq 0xad85
movq 0x1008(%rbx), %rdi
callq 0xadbf
movq %rbx, %rdi
callq 0x8b55
leaq 0x13a2b(%rip), %r14     # 0x1ca74
cmpl $0x0, (%r14)
je 0x907a
movq 0x1008(%rbx), %rdi
leaq 0x151d3(%rip), %r15     # 0x1e230
movq (%r15), %rsi
callq 0xb1cc
cmpl $0x0, (%r14)
je 0x907a
movq 0x1008(%rbx), %rdi
movq (%r15), %rsi
callq 0xb1eb
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: snapshot_scan_pdpimage
static int snapshot_scan_pdpimage(hostdir_t *_this) {
	int i, j;
	hostdir_file_t *f;

	// see above
	for (i = 0; i < _this->snapshot.file_count; i++)
		_this->snapshot.file[i].state[side_pdp] = fs_missing;

	// not expandle, we're only creating
	// filesystem_create(_this->fs, _this->dec_device, &_this->image_data, &_this->image_data_size,/*expandable*/0) ;

	filesystem_init(_this->pdp_fs);

	// analyse an image
	if (filesystem_parse(_this->pdp_fs))
		return error_set(error_code, "Uint %d: Scanning PDP image", _this->unit);
	// if PDP file system was created with block change map, now changed files are marked
	for (i = -FILESYSTEM_MAX_SPECIALFILE_COUNT; i < *_this->pdp_fs->file_count; i++) {
		file_t *fpdp = filesystem_file_get(_this->pdp_fs, i); // include bootblock & monitor
		// for all streams
		for (j = 0; j < FILESYSTEM_MAX_DATASTREAM_COUNT; j++)
			if (fpdp && fpdp->stream[j].valid) {
				char *fname = filesystem_filename_to_host(_this->pdp_fs, fpdp->filnam,
						fpdp->ext, fpdp->stream[j].name);
				f = snapshot_file_register(&_this->snapshot, fname, side_pdp);
				f->pdp_fileidx = i;
				f->pdp_fixed = fpdp->fixed;
				f->pdp_streamidx = j;
				if (f->state[side_pdp] != fs_created) {
					if (fpdp->stream[j].changed)
						f->state[side_pdp] = fs_changed;
					else
						f->state[side_pdp] = fs_unchanged;
				}
			}
	}
	return ERROR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movl 0x1018(%rdi), %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0x150, %rcx, %rcx      # imm = 0x150
cmpq %rax, %rcx
je 0x9565
movl $0x1, 0x1148(%r14,%rax)
addq $0x150, %rax            # imm = 0x150
jmp 0x954c
movq 0x1008(%r14), %rdi
callq 0xad85
movq 0x1008(%r14), %rdi
callq 0xadbf
testl %eax, %eax
je 0x95a9
leaq 0x14cb0(%rip), %rax     # 0x1e238
movl (%rax), %edi
movl (%r14), %edx
leaq 0xb150(%rip), %rsi      # 0x146e4
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x982c
leaq 0x1010(%r14), %rax
movq %rax, (%rsp)
pushq $-0x9
popq %rbp
movq 0x1008(%r14), %rdi
movq 0x18(%rdi), %rax
cmpl (%rax), %ebp
jge 0x9658
movl %ebp, %esi
callq 0xaedb
movq %rax, %r15
leaq 0x78(%rax), %r13
leaq 0x50(%rax), %r12
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0x9651
testq %r15, %r15
je 0x9648
cmpl $0x0, (%r13)
je 0x9648
movq 0x1008(%r14), %rdi
leaq 0x10(%r13), %rcx
movq %r15, %rsi
movq %r12, %rdx
callq 0xb20a
movq (%rsp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x871b
movl %ebp, 0x140(%rax)
movl 0x1e8(%r15), %ecx
movl %ecx, 0x148(%rax)
movl %ebx, 0x144(%rax)
cmpl $0x3, 0x128(%rax)
je 0x9648
xorl %ecx, %ecx
cmpb $0x0, 0x60(%r13)
setne %cl
addl %ecx, %ecx
movl %ecx, 0x128(%rax)
incq %rbx
addq $0x68, %r13
jmp 0x95de
incl %ebp
jmp 0x95b7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: snapshot_print
static void snapshot_print(hostdir_snapshot_t *_this, FILE *stream, int all) {
	int i;
	UNUSED(stream) ;
	for (i = 0; i < _this->file_count; i++) {
		hostdir_file_t *f;
		f = &_this->file[i];
		if (all || f->state[side_pdp] != fs_unchanged || f->state[side_host] != fs_unchanged) {
			info("Unit %d, file %3d: %10s %s, %s.", _this->hostdir->unit,
				i, f->pdp_filnam_ext_stream,
					state_text(side_pdp, f->state[side_pdp]),
					state_text(side_host, f->state[side_host]));
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, 0x4(%rsp)
movq %rdi, %r14
leaq 0x13c(%rdi), %rbx
xorl %r12d, %r12d
movslq 0x8(%r14), %rax
cmpq %rax, %r12
jge 0x96e6
movl -0x4(%rbx), %esi
movl %esi, %eax
orl 0x4(%rsp), %eax
jne 0x969e
xorl %esi, %esi
cmpl $0x0, (%rbx)
je 0x96da
leaq -0x12c(%rbx), %r13
movq (%r14), %rax
movl (%rax), %ebp
xorl %edi, %edi
callq 0x87e7
movq %rax, %r15
movl (%rbx), %esi
pushq $0x1
popq %rdi
callq 0x87e7
leaq 0xb03b(%rip), %rdi      # 0x14700
movl %ebp, %esi
movl %r12d, %edx
movq %r13, %rcx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x99c3
incq %r12
addq $0x150, %rbx            # imm = 0x150
jmp 0x9683
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: hostdir_file_copy_from_pdp
static void hostdir_file_copy_from_pdp(hostdir_t *_this, hostdir_file_t *f) {
	char pathbuff[4096];
	file_t *fpdp;
	file_stream_t *stream;
	sprintf(pathbuff, "%s/%s", _this->path, f->pdp_filnam_ext_stream);

	fpdp = filesystem_file_get(_this->pdp_fs, f->pdp_fileidx); // also boot and monitor
	stream = &fpdp->stream[f->pdp_streamidx];
	if (!dbg_simulate)
		file_write(pathbuff, stream->data, stream->data_size);
	if (opt_verbose)
		info("Unit %d: Copied file \"%s\" from PDP to shared dir.", _this->unit, pathbuff);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x4(%rdi), %rdx
leaq 0xad7f(%rip), %rsi      # 0x1448f
movq %rsp, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x3530
movq 0x1008(%rbx), %rdi
movl 0x140(%r14), %esi
callq 0xaedb
cmpl $0x0, 0x14a49(%rip)     # 0x1e180
jne 0x9758
movslq 0x144(%r14), %rcx
imulq $0x68, %rcx, %rcx
movq 0x80(%rax,%rcx), %rsi
movl 0x7c(%rax,%rcx), %edx
movq %rsp, %rdi
callq 0x9df9
leaq 0x13305(%rip), %rax     # 0x1ca64
cmpl $0x0, (%rax)
je 0x9777
movl (%rbx), %esi
leaq 0xafb3(%rip), %rdi      # 0x14720
movq %rsp, %rdx
xorl %eax, %eax
callq 0x99c3
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: hostdir_file_delete
static void hostdir_file_delete(hostdir_t *_this, hostdir_file_t *f) {
	char pathbuff[4096];
	sprintf(pathbuff, "%s/%s", _this->path, f->hostfilename);
	if (!dbg_simulate)
		remove(pathbuff);
	if (opt_verbose)
		info("Unit %d: Deleted file \"%s\" on shared dir.", _this->unit, pathbuff);
}

// Assembly:
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movq %rdi, %rbx
leaq 0x4(%rdi), %rdx
leaq 0x28(%rsi), %rcx
leaq 0xacf3(%rip), %rsi      # 0x1448f
movq %rsp, %rdi
xorl %eax, %eax
callq 0x3530
cmpl $0x0, 0x149d3(%rip)     # 0x1e180
jne 0x97b7
movq %rsp, %rdi
callq 0x30b0
leaq 0x132a6(%rip), %rax     # 0x1ca64
cmpl $0x0, (%rax)
je 0x97d6
movl (%rbx), %esi
leaq 0xaf86(%rip), %rdi      # 0x14752
movq %rsp, %rdx
xorl %eax, %eax
callq 0x99c3
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/hostdir.c
// Function: snapshot_init
static void snapshot_init(hostdir_t *_this) {
	_this->snapshot.file_count = 0;
	snapshot_scan_hostdir(_this);
	snapshot_scan_pdpimage(_this);
	snapshot_clear_states(_this);
	// now both sides "unchanged"
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
andl $0x0, 0x1018(%rdi)
callq 0x9310
movq %rbx, %rdi
callq 0x952a
movl 0x1018(%rbx), %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0x150, %rcx, %rcx      # imm = 0x150
cmpq %rax, %rcx
je 0x9821
andq $0x0, 0x1148(%rbx,%rax)
addq $0x150, %rax            # imm = 0x150
jmp 0x980b
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/error.c
// Function: error_set
int error_set(int code, char *fmt, ...) {
	char buffer[1024];
	va_list args;
//	assert(error_trace_level < ERROR_MAX_TRACE_LEVEL) ;
	error_code = code;
	if (code == ERROR_OK)
		error_clear();
	else if (fmt && strlen(fmt)) {
		va_start(args, fmt);
		vsprintf(buffer, fmt, args);
		va_end(args);
		// strcpy(error_message[error_trace_level++], buffer);
		error(buffer);
	}
	return error_code;
}

// Assembly:
pushq %rbx
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x9883
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movl %edi, 0x149af(%rip)     # 0x1e238
testl %edi, %edi
je 0x98e0
movl %edi, %eax
testq %rsi, %rsi
je 0x98e9
cmpb $0x0, (%rsi)
je 0x98e9
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0x4e0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
callq 0x3470
movq %rbx, %rdi
xorl %eax, %eax
callq 0x98f2
movl 0x1495a(%rip), %eax     # 0x1e238
jmp 0x98e9
andl $0x0, 0x14951(%rip)     # 0x1e238
xorl %eax, %eax
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/error.c
// Function: error
void error(char *fmt, ...) {
	va_list args;
	va_start(args, fmt);
	fprintf(ferr, "[%s ERROR]  ", cur_time_text());
	vfprintf(ferr, fmt, args);
	fprintf(ferr, "\n");
	va_end(args);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x9955
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r14
movq %rdi, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%r14)
movq 0x148b4(%rip), %r15     # 0x1e230
callq 0x9d1e
leaq 0xae0f(%rip), %rsi      # 0x14797
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3310
movq 0x14894(%rip), %rdi     # 0x1e230
movq %rbx, %rsi
movq %r14, %rdx
callq 0x34f0
movq 0x14882(%rip), %rsi     # 0x1e230
pushq $0xa
popq %rdi
callq 0x3290
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/error.c
// Function: info
void info(char *fmt, ...) {
	va_list args;
	if (!opt_background) {
		va_start(args, fmt);
		fprintf(ferr, "[%s info]  ", cur_time_text());
		vfprintf(ferr, fmt, args);
		fprintf(ferr, "\n");
		va_end(args);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x9a23
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
leaq 0x13052(%rip), %rax     # 0x1ca7c
cmpl $0x0, (%rax)
jne 0x9a98
movq %rdi, %rbx
leaq 0x20(%rsp), %rax
movq %rsp, %r14
movq %rax, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%r14)
movq 0x147d2(%rip), %r15     # 0x1e230
callq 0x9d1e
leaq 0xad12(%rip), %rsi      # 0x1477c
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3310
movq 0x147b2(%rip), %rdi     # 0x1e230
movq %rbx, %rsi
movq %r14, %rdx
callq 0x34f0
movq 0x147a0(%rip), %rsi     # 0x1e230
pushq $0xa
popq %rdi
callq 0x3290
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/error.c
// Function: warning
void warning(char *fmt, ...) {
	va_list args;
	if (!opt_background) {
		va_start(args, fmt);
		fprintf(ferr, "[%s Warning]  ", cur_time_text());
		vfprintf(ferr, fmt, args);
		fprintf(ferr, "\n");
		va_end(args);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x9b05
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
leaq 0x12f70(%rip), %rax     # 0x1ca7c
cmpl $0x0, (%rax)
jne 0x9b7a
movq %rdi, %rbx
leaq 0x20(%rsp), %rax
movq %rsp, %r14
movq %rax, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%r14)
movq 0x146f0(%rip), %r15     # 0x1e230
callq 0x9d1e
leaq 0xac3c(%rip), %rsi      # 0x14788
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3310
movq 0x146d0(%rip), %rdi     # 0x1e230
movq %rbx, %rsi
movq %r14, %rdx
callq 0x34f0
movq 0x146be(%rip), %rsi     # 0x1e230
pushq $0xa
popq %rdi
callq 0x3290
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/error.c
// Function: fatal
void fatal(char *fmt, ...) {
	va_list args;
	va_start(args, fmt);
	fprintf(ferr, "[%s FATAL]  ", cur_time_text());
	vfprintf(ferr, fmt, args);
	fprintf(ferr, "\n");
	va_end(args);
	exit(EXIT_FAILURE);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x9bea
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r14
movq %rdi, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%r14)
movq 0x1461f(%rip), %r15     # 0x1e230
callq 0x9d1e
leaq 0xab87(%rip), %rsi      # 0x147a4
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3310
movq 0x145ff(%rip), %rdi     # 0x1e230
movq %rbx, %rsi
movq %r14, %rdx
callq 0x34f0
movq 0x145ed(%rip), %rsi     # 0x1e230
pushq $0xa
popq %rdi
callq 0x3290
pushq $0x1
popq %rdi
callq 0x3540
nop
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/utils.c
// Function: delay_us
void delay_us(int32_t us) {
	struct timespec rqtp;
	int32_t sts;

	// check if any delay required
	if (us <= 0)
		return;

	// nanosleep() preferred over usleep(),
	// compute integer seconds and fraction (in nanoseconds)
	rqtp.tv_sec = us / 1000000L;
	rqtp.tv_nsec = (us % 1000000L) * 1000L;

	// if nanosleep() fails then just plain sleep()
	if ((sts = nanosleep(&rqtp, NULL)) == -1)
		sleep(rqtp.tv_sec);
}

// Assembly:
testl %edi, %edi
jle 0x9c92
subq $0x18, %rsp
movl $0xf4240, %ecx          # imm = 0xF4240
movl %edi, %eax
xorl %edx, %edx
divl %ecx
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
imull $0x3e8, %edx, %eax      # imm = 0x3E8
movq %rax, 0x8(%rdi)
xorl %esi, %esi
callq 0x31e0
cmpl $-0x1, %eax
jne 0x9c8e
movl 0x8(%rsp), %edi
callq 0x3590
addq $0x18, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/utils.c
// Function: cur_time_text
char *cur_time_text() {
	static char result[40] ;
	time_t timer;
	struct tm* tm_info;
	time(&timer);
	tm_info = localtime(&timer);
	strftime(result, 26, "%H:%M:%S", tm_info);
	return result;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
callq 0x3070
leaq 0x14511(%rip), %rbx     # 0x1e250
leaq 0xaa6b(%rip), %rdx      # 0x147b1
pushq $0x1a
popq %rsi
movq %rbx, %rdi
movq %rax, %rcx
callq 0x3450
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
retq