LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_help_commandline
void getopt_help_commandline(getopt_t *_this, FILE *stream, unsigned linelen, unsigned indent)
{
	int	i;
	char linebuff[2 * GETOPT_MAX_LINELEN];
	char phrase[2 * GETOPT_MAX_LINELEN];
	linebuff[0] = 0;
	for (i = 0; i < _this->argc; i++) {
		if (i == 0)
			snprintf(phrase, sizeof(phrase), "\"%s\"", _this->argv[i]);
		else
			snprintf(phrase, sizeof(phrase), " \"%s\"", _this->argv[i]);
		output_append(stream, linebuff, sizeof(linebuff), phrase, /*linebreak*/0, linelen, indent);
	}

	fprintf(stream, "%s\n", linebuff);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movl %ecx, 0x4(%rsp)
movq %rsi, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
cmpl $0x0, 0xb70(%rdi)
jle 0x65d6
movl %edx, %r14d
movq %rdi, %r15
leaq 0xb78(%rdi), %rbx
leaq 0x210(%rsp), %r12
movq %rbx, %r13
xorl %ebp, %ebp
testq %rbp, %rbp
movq %r13, %rax
cmoveq %rbx, %rax
leaq 0xe151(%rip), %rdx      # 0x146db
leaq 0xe14b(%rip), %rcx      # 0x146dc
cmoveq %rcx, %rdx
movq (%rax), %rcx
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdi
xorl %eax, %eax
callq 0x31d0
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movl %r14d, %r8d
movl 0x4(%rsp), %r9d
callq 0x61f6
incq %rbp
movslq 0xb70(%r15), %rax
addq $0x8, %r13
cmpq %rax, %rbp
jl 0x6579
leaq 0xf801(%rip), %rsi      # 0x15dde
leaq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x3310
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_print_multilinestring
static void getopt_print_multilinestring(FILE *stream, char *linebuff, unsigned linebuffsize, char *text, unsigned linelen, unsigned indent)
{
	char *s_text;
	char *s_start, *s;

	s_start = s_text = strdup(text); // print multiline info. make writeable copy
	while (*s_start) {
		s = s_start;
		// seach end of substring
		while (*s && *s != '\n') s++;
		if (*s) { // substr seperator
			*s = '\0'; // terminate

			output_append(stream, linebuff, linebuffsize, s_start, /*linebreak*/s_start != s_text, linelen, indent);
			s_start = s + 1; // advance to start of next substr
		}
		else { // last substr
			output_append(stream, linebuff, linebuffsize, s_start, /*linebreak*/s_start != s_text, linelen, indent);
			s_start = s; // stop
		}
	}
	free(s_text);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebx
movl %ecx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, %rdi
callq 0x3570
movq %rax, %r12
movb (%rax), %al
testb %al, %al
je 0x669b
movq %r12, %rdx
leaq 0x1(%rdx), %r13
testb %al, %al
je 0x6674
movzbl %al, %eax
cmpl $0xa, %eax
je 0x6654
movb (%r13), %al
incq %r13
jmp 0x663f
movb $0x0, -0x1(%r13)
xorl %ecx, %ecx
cmpq %r12, %rdx
setne %cl
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %r8d
movl %ebx, %r9d
callq 0x61f6
jmp 0x6690
xorl %ecx, %ecx
cmpq %r12, %rdx
setne %cl
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %r8d
movl %ebx, %r9d
callq 0x61f6
decq %r13
movb (%r13), %al
movq %r13, %rdx
testb %al, %al
jne 0x663b
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3050
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: tu58image_create
image_t *tu58image_create(int32_t unit, int forced_data_size) {
	if (!IMAGE_UNIT_VALID(unit)) {
		fatal("bad unit %d", unit); //terminates
	}
	if (tu58_image[unit] != NULL)
		fatal("tu58image_create(): duplicate allocation"); //terminates

	tu58_image[unit] = image_create(devTU58, unit, forced_data_size);
	return tu58_image[unit];
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movslq %edi, %rbx
leaq 0x1779c(%rip), %r14     # 0x1de80
cmpq $0x0, (%r14,%rbx,8)
je 0x66f9
leaq 0xe0c2(%rip), %rdi      # 0x147b4
xorl %eax, %eax
callq 0xa2d7
movl $0x1, %edi
movl %ebx, %esi
movl %ebp, %edx
callq 0x79d8
movq %rax, (%r14,%rbx,8)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: tu58images_closeall
void tu58images_closeall(void) {
	image_t *img;
	int32_t unit;
	for (unit = 0; unit < TU58_DEVICECOUNT; unit++) {
		img = tu58_image[unit];
		if (img) {
			if (img->open)
				image_sync(img);
			image_destroy(img);
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %r14d, %r14d
leaq 0x17752(%rip), %r15     # 0x1de80
movq (%r14,%r15), %rbx
testq %rbx, %rbx
je 0x6750
cmpb $0x0, 0xf4(%rbx)
je 0x6748
movq %rbx, %rdi
callq 0x8331
movq %rbx, %rdi
callq 0x8391
addq $0x8, %r14
cmpq $0x40, %r14
jne 0x672e
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: tu58images_sync_all
void tu58images_sync_all() {
	image_t *img;
	int32_t unit;

	if (!opt_synctimeout_sec)
		return; // not wanted

	for (unit = 0; unit < TU58_DEVICECOUNT; unit++) {
		img = tu58_image[unit];

		if (img && img->open) {
			if (opt_debug)
				info("unit %d sync ", unit);
			image_sync(img); // does locking
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0x16310(%rip), %rax     # 0x1ca80
cmpl $0x0, (%rax)
je 0x67c9
leaq 0x17704(%rip), %r12     # 0x1de80
leaq 0x162f1(%rip), %r13     # 0x1ca74
leaq 0xe053(%rip), %rbx      # 0x147dd
xorl %r14d, %r14d
movq (%r12), %r15
testq %r15, %r15
je 0x67bc
cmpb $0x0, 0xf4(%r15)
je 0x67bc
cmpl $0x0, (%r13)
je 0x67b4
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0xa10f
movq %r15, %rdi
callq 0x8331
incq %r14
addq $0x8, %r12
cmpq $0x8, %r14
jne 0x678d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: reinit
static void reinit(void) {
	// clear all buffers, wait a bit
	serial_devrxinit(&tu58_serial);
	serial_devtxinit(&tu58_serial);
	delay_ms(5);

	// init sequence, send immediately
	serial_devtxstart(&tu58_serial);
	serial_devtxput(&tu58_serial, TUF_INIT);
	serial_devtxput(&tu58_serial, TUF_INIT);
	serial_devtxflush(&tu58_serial);

	return;
}

// Assembly:
pushq %rbx
leaq 0x16893(%rip), %rbx     # 0x1dec8
movq %rbx, %rdi
callq 0x8451
movq %rbx, %rdi
callq 0x842a
movl $0x5, %edi
callq 0xa3f4
movq %rbx, %rdi
callq 0x8415
movq %rbx, %rdi
movl $0x4, %esi
callq 0x859b
movq %rbx, %rdi
movl $0x4, %esi
callq 0x859b
movq %rbx, %rdi
popq %rbx
jmp 0x8513
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: tu58_monitor
void* tu58_monitor(void* none) {
	int32_t sts;
	uint64_t now;
	uint64_t next_sync_time;
	UNUSED(none) ;

	next_sync_time = now_ms() + opt_synctimeout_sec * 1000;
	for (;;) {

		// check for any error
		switch (sts = serial_devrxerror(&tu58_serial)) {
		case DEV_ERROR: // error
		case DEV_BREAK: // break
			// kill and restart the emulator
			if (opt_verbose)
				info("BREAK detected");
#ifdef THIS_DOES_NOT_YET_WORK_RELIABLY
			if (pthread_cancel(tu58_server))
			error("unable to cancel emulation thread");
			if (pthread_join(tu58_server, NULL))
			error("unable to join on emulation thread");
			if (pthread_create(&tu58_server, NULL, run, NULL))
			error("unable to restart emulation thread");
#endif // THIS_DOES_NOT_YET_WORK_RELIABLY
			break;
		case DEV_OK: // OK
			break;
		case DEV_NYI: // not yet implemented
			// return (void*)1;
			break;
		default: // something else...
			error("monitor(): unknown flag %d", sts);
			break;
		}
		now = now_ms();
		// image_*() routines have, mutex locking, so no change while saving possible
		if (next_sync_time < now
				&& tu58_serial.rx_lasttime_ms + opt_synctimeout_sec * 1000 < now
				&& tu58_serial.tx_lasttime_ms + opt_synctimeout_sec * 1000 < now) {
			// next sync time passed, and RS232 inactive
			tu58images_sync_all();
			next_sync_time = now + opt_synctimeout_sec * 1000;
		}

		// bit of a delay, loop again
		delay_ms(5);

	}

	return (void*) 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %eax, %eax
callq 0xa3ff
leaq 0x153ed(%rip), %r13     # 0x1ca80
movslq (%r13), %rcx
imulq $0x3e8, %rcx, %r15      # imm = 0x3E8
addq %rax, %r15
leaq 0x16820(%rip), %rbx     # 0x1dec8
leaq 0x153b5(%rip), %rbp     # 0x1ca64
leaq 0xd24f(%rip), %r14      # 0x14905
movq %rbx, %rdi
callq 0x8478
leal 0x1(%rax), %ecx
cmpl $0x2, %ecx
jb 0x76f0
leal -0x1(%rax), %ecx
cmpl $0x1, %ecx
ja 0x76e0
cmpl $0x0, (%rbp)
je 0x76f0
movq %r14, %rdi
xorl %eax, %eax
callq 0xa10f
jmp 0x76f0
leaq 0xd22d(%rip), %rdi      # 0x14914
movl %eax, %esi
xorl %eax, %eax
callq 0xa03c
xorl %eax, %eax
callq 0xa3ff
cmpq %rax, %r15
jae 0x773b
movq %rax, %r12
movslq (%r13), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq 0x167c7(%rip), %rcx     # 0x1ded8
addq %rax, %rcx
cmpq %r12, %rcx
jae 0x773b
addq 0x167c0(%rip), %rax     # 0x1dee0
cmpq %r12, %rax
jae 0x773b
callq 0x6760
movslq (%r13), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
addq %rax, %r12
movq %r12, %r15
movl $0x5, %edi
callq 0xa3f4
jmp 0x76b6
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: getpacket
static int32_t getpacket(tu_packet *pkt) {
	int32_t count = pkt->cmd.length + 2; // +2 for checksum bytes
	uint8_t *ptr = (uint8_t *) pkt + 2; // skip over flag/length bytes
	uint16_t rcvchk, expchk;

	// get remaining packet bytes, incl two checksum bytes
	while (--count >= 0)
		*ptr++ = serial_devrxget(&tu58_serial);

	// get checksum bytes
	rcvchk = (ptr[-1] << 8) | (ptr[-2] << 0);

	// compute expected checksum
	expchk = checksum(pkt);

	// for debug...
	if (opt_debug)
		dumppacket(pkt, "getpacket");

	// message on error
	if (expchk != rcvchk)
		error("getpacket checksum error: exp=0x%04X rcv=0x%04X", expchk, rcvchk);

	// return checksum match indication
	return (expchk != rcvchk);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzbl 0x1(%rdi), %ebp
leaq 0x2(%rdi), %r15
addl $0x3, %ebp
leaq 0x16762(%rip), %r14     # 0x1dec8
movq %r14, %rdi
callq 0x8564
movb %al, (%r15)
incq %r15
decl %ebp
cmpl $0x1, %ebp
ja 0x7766
movzbl %al, %eax
shll $0x8, %eax
movzbl -0x2(%r15), %ebp
orl %eax, %ebp
movq %rbx, %rdi
callq 0x7892
movl %eax, %r14d
leaq 0x152da(%rip), %rax     # 0x1ca74
cmpl $0x0, (%rax)
je 0x77ae
leaq 0xd295(%rip), %rsi      # 0x14a3b
movq %rbx, %rdi
callq 0x78cd
movzwl %r14w, %ebx
cmpl %ebx, %ebp
je 0x77c8
leaq 0xd288(%rip), %rdi      # 0x14a45
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xa03c
xorl %eax, %eax
cmpl %ebx, %ebp
setne %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: putpacket
static void putpacket(tu_packet *pkt) {
	int32_t count = pkt->cmd.length + 2; // +2 for flag/length bytes
	uint8_t *ptr = (uint8_t *) pkt; // start at flag byte
	uint16_t chksum;

	// send all packet bytes
	while (--count >= 0) {
		serial_devtxput(&tu58_serial, *ptr++);
		wait4cont(mrsp);
	}

	// compute/send checksum bytes, append to packet
	chksum = checksum(pkt);
	serial_devtxput(&tu58_serial, *ptr++ = chksum >> 0);
	wait4cont(mrsp);
	serial_devtxput(&tu58_serial, *ptr++ = chksum >> 8);
	wait4cont(mrsp);

	// for debug...
	if (opt_debug)
		dumppacket(pkt, "putpacket");

	// now actually send the packet (or whatever is left to send)
	serial_devtxflush(&tu58_serial);

	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzbl 0x1(%rdi), %ebp
addl $0x3, %ebp
leaq 0x166d6(%rip), %r14     # 0x1dec8
movq %rdi, %r15
movzbl (%r15), %esi
incq %r15
movq %r14, %rdi
callq 0x859b
movzbl 0x16665(%rip), %edi     # 0x1de70
callq 0x7974
decl %ebp
cmpl $0x1, %ebp
ja 0x77f5
movq %rbx, %rdi
callq 0x7892
movzwl %ax, %ebp
movb %bpl, (%r15)
movzbl %bpl, %esi
leaq 0x16698(%rip), %r14     # 0x1dec8
movq %r14, %rdi
callq 0x859b
movzbl 0x16631(%rip), %edi     # 0x1de70
callq 0x7974
shrl $0x8, %ebp
movb %bpl, 0x1(%r15)
movq %r14, %rdi
movl %ebp, %esi
callq 0x859b
movzbl 0x16614(%rip), %edi     # 0x1de70
callq 0x7974
leaq 0x1520c(%rip), %rax     # 0x1ca74
cmpl $0x0, (%rax)
je 0x787c
leaq 0xd433(%rip), %rsi      # 0x14ca7
movq %rbx, %rdi
callq 0x78cd
leaq 0x16645(%rip), %rdi     # 0x1dec8
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8513
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: checksum
static uint16_t checksum(tu_packet *pkt) {
	int32_t count = pkt->cmd.length + 2; // +2 for flag/length bytes
	uint8_t *ptr = (uint8_t *) pkt; // start at flag byte
	uint32_t chksum = 0; // initial checksum value

	while (--count >= 0) {
		chksum += *ptr++; // at least one byte
		if (--count >= 0)
			chksum += (*ptr++ << 8); // at least two bytes
		chksum = (chksum + (chksum >> 16)) & 0xFFFF; // 16b end around carry
	}

	return chksum;
}

// Assembly:
movzbl 0x1(%rdi), %ecx
addl $0x4, %ecx
xorl %edx, %edx
movzbl (%rdi), %esi
addl %edx, %esi
cmpl $0x3, %ecx
je 0x78c5
movzbl 0x1(%rdi), %edx
shll $0x8, %edx
addl %esi, %edx
movl %edx, %eax
shrl $0x10, %eax
addl %edx, %eax
movzwl %ax, %edx
addl $-0x2, %ecx
addq $0x2, %rdi
cmpl $0x2, %ecx
ja 0x789b
retq
movl %esi, %eax
shrl $0x10, %eax
addl %esi, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: dumppacket
static void dumppacket(tu_packet *pkt, char *name) {
	int32_t count = 0;
	uint8_t *ptr = (uint8_t *) pkt;

	// formatted packet dump, but skip it in background mode
	if (!opt_background) {
		fprintf(ferr, "info: %s()\n", name);
		while (count++ < pkt->cmd.length + 2) {
			if (count == 3 || ((count - 4) % 32 == 31))
				fprintf(ferr, "\n");
			fprintf(ferr, " %02X", *ptr++);
		}
		fprintf(ferr, "\n %02X %02X\n", ptr[0], ptr[1]);
	}

	return;
}

// Assembly:
leaq 0x151a8(%rip), %rax     # 0x1ca7c
cmpl $0x0, (%rax)
je 0x78da
retq
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rdx
movq %rdi, %rbx
leaq 0x16941(%rip), %r15     # 0x1e230
movq (%r15), %rdi
leaq 0xd17c(%rip), %rsi      # 0x14a75
xorl %eax, %eax
callq 0x3310
leaq 0xd17a(%rip), %r14      # 0x14a81
xorl %r12d, %r12d
cmpl $0x2, %r12d
je 0x791f
leal -0x3(%r12), %eax
andl $0x8000001f, %eax       # imm = 0x8000001F
cmpl $0x1f, %eax
jne 0x792c
movq (%r15), %rsi
movl $0xa, %edi
callq 0x3290
movq (%r15), %rdi
movzbl (%rbx,%r12), %edx
movq %r14, %rsi
xorl %eax, %eax
callq 0x3310
movzbl 0x1(%rbx), %eax
addl $0x2, %eax
incq %r12
cmpl %eax, %r12d
jb 0x790a
movq (%r15), %rdi
movzbl (%rbx,%r12), %edx
movzbl 0x1(%rbx,%r12), %ecx
leaq 0xd125(%rip), %rsi      # 0x14a87
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3310
// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/tu58drive.c
// Function: wait4cont
static void wait4cont(uint8_t code) {
	uint8_t c;
	int32_t maxchar = TU_CTRL_LEN + TU_DATA_LEN + 8;

	// send any existing data out ... makes USB serial emulation be real slow if enabled!
	if (0)
		serial_devtxflush(&tu58_serial);

	// don't do any waiting if flag not set
	if (!code)
		return;

	// wait for a CONT to arrive, but only so long
	do {
		c = serial_devrxget(&tu58_serial);
		if (opt_debug)
			info("wait4cont(): char=0x%02X", c);
	} while (c != TUF_CONT && --maxchar >= 0);

	// all done
	return;
}

// Assembly:
testl %edi, %edi
je 0x79d4
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0xffffff6e, %r15d      # imm = 0xFFFFFF6E
leaq 0x1653b(%rip), %rbx     # 0x1dec8
leaq 0x150e0(%rip), %r12     # 0x1ca74
leaq 0xd316(%rip), %r14      # 0x14cb1
movq %rbx, %rdi
callq 0x8564
movl %eax, %ebp
cmpl $0x0, (%r12)
je 0x79ba
movzbl %bpl, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0xa10f
cmpb $0x10, %bpl
je 0x79cc
leal 0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
jne 0x799b
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
movl %edx, %r14d
movl %esi, %ebp
movl %edi, %r15d
movl $0x128, %edi            # imm = 0x128
callq 0x33b0
movq %rax, %rbx
leaq 0x8(%rax), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x35a0
movw $0x0, 0xf4(%rbx)
movq %r12, 0xf8(%rbx)
movq %r12, 0x30(%rbx)
movl $0x0, 0x10c(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xd8(%rbx)
movl %r15d, 0x108(%rbx)
movl %ebp, (%rbx)
leaq 0x14a75(%rip), %rdi     # 0x1c4b0
movl $0x20, %esi
movl %r15d, %edx
callq 0xb0ca
movq %rax, 0xe8(%rbx)
testq %rax, %rax
je 0x7ac6
movl $0x200, 0xf0(%rbx)      # imm = 0x200
leal 0x1ff(%r14), %edi
addl $0x3fe, %r14d           # imm = 0x3FE
testl %edi, %edi
cmovsl %r14d, %edi
sarl $0x9, %edi
movl %edi, 0x40(%rbx)
movl 0x18(%rax), %ecx
cmpl $0x3ff, %r14d           # imm = 0x3FF
jb 0x7a92
cmpl %ecx, %edi
jl 0x7a8f
movl 0x1c(%rax), %ecx
cmpl %ecx, %edi
jle 0x7a94
movl %ecx, 0x40(%rbx)
movl %ecx, %edi
shll $0x9, %edi
movl %edi, 0x110(%rbx)
callq 0x33b0
movq %rax, 0x118(%rbx)
movl $0xf4240, %edi          # imm = 0xF4240
callq 0xb100
movq %rax, 0xf8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd2c6(%rip), %rdi      # 0x14d93
leaq 0xd2d2(%rip), %rsi      # 0x14da6
leaq 0xd2d3(%rip), %rcx      # 0x14dae
movl $0x74, %edx
callq 0x3200
// File: /workspace/github_c_makefile_star2_O3/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 0x7edf
leaq 0x120(%rdi), %rax
testl %edx, %edx
je 0x7eda
movq %rax, %rcx
cmpl $0x1, %edx
je 0x7ed8
cmpl $0x2, %edx
jne 0x7ef4
addq $0x110, %rdi            # imm = 0x110
movq %rdi, %rcx
addl (%rcx), %esi
movl %esi, (%rax)
movl %esi, %eax
retq
movl (%rdi), %edx
leaq 0xcfa5(%rip), %rsi      # 0x14e8d
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
jmp 0x9f73
leaq 0xcfb0(%rip), %rsi      # 0x14eab
movl $0xfffffff9, %edi       # imm = 0xFFFFFFF9
xorl %eax, %eax
jmp 0x9f73
// File: /workspace/github_c_makefile_star2_O3/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 0x7f50
movl %ecx, %r15d
movl %edx, %ebp
movl %esi, %r12d
leaq 0x8(%r14), %rbx
movq %rbx, %rdi
callq 0x35c0
imull %r12d, %ebp
addl %r15d, %ebp
cmpb $0x0, 0xf4(%r14)
je 0x7f6e
movl 0x110(%r14), %eax
movl %eax, 0x120(%r14)
jmp 0x7f84
movl (%r14), %edx
leaq 0xcf6f(%rip), %rsi      # 0x14ec9
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f73
movl (%r14), %edx
leaq 0xcf15(%rip), %rsi      # 0x14e8d
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
callq 0x9f73
movl $0xfffffff7, %r15d      # imm = 0xFFFFFFF7
cmpl %eax, %ebp
jg 0x7fc2
cmpb $0x0, 0xf4(%r14)
je 0x7fa1
movl %ebp, 0x120(%r14)
jmp 0x7fb9
movl (%r14), %edx
leaq 0xcee2(%rip), %rsi      # 0x14e8d
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
callq 0x9f73
movl %eax, %ebp
sarl $0x1f, %ebp
andl $-0x9, %ebp
movl %ebp, %r15d
movq %rbx, %rdi
callq 0x33a0
leaq 0xcf1a(%rip), %rsi      # 0x14eeb
movl %r15d, %edi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f73
// File: /workspace/github_c_makefile_star2_O3/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 0x804b
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 0xceb4(%rip), %rsi      # 0x14f08
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f73
// File: /workspace/github_c_makefile_star2_O3/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 0x808d
cmpl $0x0, 0x3c(%rbx)
je 0x80aa
movl (%rbx), %edx
leaq 0xcee3(%rip), %rsi      # 0x14f6e
jmp 0x8096
movl (%rbx), %edx
leaq 0xce8f(%rip), %rsi      # 0x14f25
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f73
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 0xa3ff
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 0x8140
movq 0xf8(%rbx), %rdi
movl %r15d, %esi
callq 0xb161
incl %r15d
movl 0x120(%rbx), %ecx
addl %ebp, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl 0xf0(%rbx)
jmp 0x8115
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_O3/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 0x817d
cmpl $0x0, 0x3c(%rbx)
je 0x819c
movl (%rbx), %edx
leaq 0xcde5(%rip), %rsi      # 0x14f60
jmp 0x8186
movl (%rbx), %edx
leaq 0xcdbd(%rip), %rsi      # 0x14f43
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9f73
leaq 0x148c1(%rip), %rax     # 0x1ca64
cmpl $0x0, (%rax)
je 0x81eb
cmpb $0x0, 0xf5(%rbx)
leaq 0xcdee(%rip), %rax      # 0x14fa4
leaq 0xcde9(%rip), %rdx      # 0x14fa6
cmoveq %rax, %rdx
movl (%rbx), %esi
cmpl $0x0, 0x38(%rbx)
leaq 0xd635(%rip), %rax      # 0x15803
leaq 0xcdd9(%rip), %rcx      # 0x14fae
cmoveq %rax, %rcx
movq 0x30(%rbx), %r8
leaq 0xcd9c(%rip), %rdi      # 0x14f80
xorl %eax, %eax
callq 0xa10f
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x35c0
cmpl $0x0, 0x38(%rbx)
je 0x822d
movq 0xd8(%rbx), %rdi
callq 0x9479
testl %eax, %eax
je 0x82fb
leaq 0x16020(%rip), %rax     # 0x1e238
movl (%rax), %edi
leaq 0xcd95(%rip), %rsi      # 0x14fb6
xorl %eax, %eax
callq 0x9f73
jmp 0x82fb
movq 0x30(%rbx), %rdi
movl $0x2, %esi
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x34a0
testl %eax, %eax
js 0x82ae
movl %eax, %ebp
movl 0x10c(%rbx), %edi
testl %edi, %edi
je 0x82e0
movl 0x3c(%rbx), %edx
movl 0x108(%rbx), %esi
movq 0x118(%rbx), %rcx
movl 0x110(%rbx), %r8d
xorl %r9d, %r9d
callq 0xb66f
movq %rax, %r15
movq %rax, %rdi
callq 0xb7b1
movq %r15, %rdi
callq 0xbba2
movq 0x118(%rbx), %rsi
movl 0x110(%rbx), %edx
movl %ebp, %edi
callq 0x3140
movq %r15, %rdi
callq 0xbb77
movq %r15, %rdi
callq 0xb724
jmp 0x82f4
movl (%rbx), %edx
movq 0x30(%rbx), %rcx
leaq 0xce71(%rip), %rsi      # 0x1512c
movl $0xfffffffa, %edi       # imm = 0xFFFFFFFA
xorl %eax, %eax
callq 0x9f73
testl %eax, %eax
je 0x82fb
leaq 0x15f66(%rip), %rax     # 0x1e238
movl (%rax), %edi
leaq 0xccef(%rip), %rsi      # 0x14fca
jmp 0x8221
movq 0x118(%rbx), %rsi
movl 0x110(%rbx), %edx
movl %ebp, %edi
callq 0x3140
movl %ebp, %edi
callq 0x3260
leaq 0x15f36(%rip), %r15     # 0x1e238
cmpl $0x0, (%r15)
jne 0x831b
movb $0x0, 0xf5(%rbx)
movq 0xf8(%rbx), %rdi
callq 0xb136
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_O3/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 0x837e
cmpl $0x0, 0x38(%rbx)
je 0x836b
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x35c0
movq 0xd8(%rbx), %rdi
callq 0x9511
movq %r14, %rdi
callq 0x33a0
jmp 0x837e
cmpb $0x0, 0xf5(%rbx)
je 0x837e
movq %rbx, %rdi
callq 0x8159
movl %eax, %ebp
movq 0xf8(%rbx), %rdi
callq 0xb136
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
testq %rdi, %rdi
je 0x83aa
callq 0x3050
movq $0x0, 0x30(%rbx)
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0x83c3
callq 0x3050
movq $0x0, 0x118(%rbx)
movl $0x0, 0x110(%rbx)
cmpl $0x0, 0x38(%rbx)
je 0x8400
movq 0xd8(%rbx), %rdi
testq %rdi, %rdi
je 0x83ef
callq 0x939e
movq 0xe0(%rbx), %rdi
testq %rdi, %rdi
je 0x8400
callq 0xb724
movq %rbx, %rdi
popq %rbx
jmp 0x3050
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x1, %esi
callq 0x31b0
movl $0x0, 0x128(%rbx)
leaq 0x20(%rbx), %rax
movq %rax, 0x120(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x0, 0x238(%rbx)
leaq 0x12c(%rbx), %rax
movq %rax, 0x230(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x8489
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 0x84c3
movl $0x0, 0x238(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x8508
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorl %eax, %eax
callq 0xa3ff
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 0xa3ff
movq %rax, 0x18(%rbx)
jmp 0x850b
xorl %r14d, %r14d
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x8547
leaq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0x84cb
movl 0x128(%rbx), %esi
cmpl %esi, %eax
je 0x8547
leaq 0xcc13(%rip), %rdi      # 0x15151
movl %eax, %edx
xorl %eax, %eax
callq 0xa03c
movl $0x0, 0x128(%rbx)
leaq 0x20(%rbx), %rax
movq %rax, 0x120(%rbx)
movl (%rbx), %edi
popq %rbx
jmp 0x3110
// File: /workspace/github_c_makefile_star2_O3/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 0x847e
testl %eax, %eax
jle 0x8568
xorl %eax, %eax
callq 0xa3ff
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_O3/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 0x85be
movq %rbx, %rdi
callq 0x8513
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 0xa3ff
movq %rax, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x1, %ebx
testq %rdi, %rdi
je 0x8671
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
callq 0x3190
cmpq $0x3, %rax
jne 0x8671
movb (%r12), %al
leal -0x35(%rax), %ecx
cmpb $0x3, %cl
ja 0x8671
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 0x8671
movl $0x601, %edx            # imm = 0x601
btl %ecx, %edx
jae 0x8671
movb %al, (%r15)
movzbl 0x2(%r12), %eax
movl $0x1, %ebx
cmpl $0x31, %eax
je 0x866c
cmpl $0x32, %eax
jne 0x8671
movl $0x2, %ebx
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_O3/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
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x140e5(%rip), %rax     # 0x1ca7c
cmpl $0x0, (%rax)
jne 0x8a66
movl %edi, %ebx
movq 0x1362f(%rip), %r14     # 0x1bfd8
movq (%r14), %rdi
callq 0x3370
leaq 0x15788(%rip), %rsi     # 0x1e140
movl %eax, %edi
callq 0x3480
testl %eax, %eax
je 0x89d1
leaq 0xc815(%rip), %rdi      # 0x151df
xorl %eax, %eax
callq 0xa2d7
movups 0x15794(%rip), %xmm0    # 0x1e16c
movups %xmm0, 0x2c(%rsp)
movups 0x1577c(%rip), %xmm0    # 0x1e160
movaps %xmm0, 0x20(%rsp)
movups 0x15760(%rip), %xmm0    # 0x1e150
movaps %xmm0, 0x10(%rsp)
movups 0x15744(%rip), %xmm0    # 0x1e140
movaps %xmm0, (%rsp)
testl %ebx, %ebx
je 0x8a0e
movq %rsp, %rdi
callq 0x3430
jmp 0x8a13
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
movl %eax, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x3120
cmpl $-0x1, %eax
jne 0x8a66
leaq 0xc79a(%rip), %rdi      # 0x151f9
xorl %eax, %eax
callq 0xa03c
addq $0x48, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x13fd9(%rip), %rcx     # 0x1ca7c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x0, (%rcx)
je 0x8aae
retq
pushq %rbx
subq $0x10, %rsp
movq 0x1351e(%rip), %rax     # 0x1bfd8
movq (%rax), %rdi
callq 0x3370
leaq 0xf(%rsp), %rbx
movl $0x1, %edx
movl %eax, %edi
movq %rbx, %rsi
callq 0x32b0
cmpl $0x1, %eax
movsbl (%rbx), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %ecx, %eax
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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 %rbx
movq %rsi, %rbx
movl 0x8(%rdi), %r15d
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
incq %r15
addq $-0x140, %rdi           # imm = 0xFEC0
decq %r15
je 0x8b2f
leaq 0x150(%rdi), %r14
addq $0x150, %rdi            # imm = 0x150
movq %rbx, %rsi
callq 0x3060
movq %r14, %rdi
testl %eax, %eax
jne 0x8b0b
jmp 0x8b32
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, 0x4(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movslq 0x8(%rdi), %r12
leaq 0x10(%rdi), %rbx
xorl %r13d, %r13d
testl %r12d, %r12d
cmovgl %r12d, %r13d
incq %r13
movq %rbx, %rdi
decq %r13
je 0x8ba8
leaq 0x150(%rdi), %rbp
movq %r14, %rsi
callq 0x3060
movq %rbp, %rdi
testl %eax, %eax
jne 0x8b68
xorl %eax, %eax
movl 0x4(%rsp), %ecx
testl %ecx, %ecx
sete %al
leaq -0x150(%rbp), %rbx
cmpl $0x3, -0x28(%rbp,%rax,4)
jne 0x8c01
movl %ecx, %eax
movl $0x3, -0x28(%rbp,%rax,4)
jmp 0x8c01
cmpl $0x3e8, %r12d           # imm = 0x3E8
jge 0x8c13
leal 0x1(%r12), %eax
movl %eax, 0x8(%r15)
imulq $0x150, %r12, %rax      # imm = 0x150
addq %rax, %rbx
movl $0x150, %edx            # imm = 0x150
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3220
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30c0
movl 0x4(%rsp), %ecx
movl %ecx, %eax
movl $0x3, 0x128(%rbx,%rax,4)
xorl %eax, %eax
testl %ecx, %ecx
sete %al
movl $0x1, 0x128(%rbx,%rax,4)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc756(%rip), %rdi      # 0x15370
leaq 0xc775(%rip), %rsi      # 0x15396
leaq 0xc778(%rip), %rcx      # 0x153a0
movl $0x78, %edx
callq 0x3200
// File: /workspace/github_c_makefile_star2_O3/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
leaq (%rax,%rax,4), %rcx
shlq $0x4, %rcx
leaq 0x1554c(%rip), %rbx     # 0x1e190
addq %rcx, %rbx
movl %esi, %ecx
leaq 0x13170(%rip), %rdx     # 0x1bdc0
movq (%rdx,%rcx,8), %rdx
leaq 0xc6c5(%rip), %rsi      # 0x15320
movslq (%rsi,%rax,4), %rcx
addq %rsi, %rcx
leaq 0xc79d(%rip), %rsi      # 0x15406
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3530
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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, 0x8(%rsp)
movq 0x1008(%rdi), %rdi
movq 0x18(%rdi), %rax
cmpl $-0x8, (%rax)
jl 0x90b0
movq 0x8(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x10(%rsp)
movl $0xfffffff7, %ebp       # imm = 0xFFFFFFF7
movl %ebp, %esi
callq 0xb8d3
testq %rax, %rax
je 0x9096
movq %rax, %rbx
addq $0x50, %rax
movq %rax, 0x18(%rsp)
leaq 0x1b0(%rbx), %r14
movq %rbx, %r13
addq $0x88, %r13
movl $0x3, %r12d
cmpl $0x0, -0x10(%r13)
je 0x9089
movq 0x8(%rsp), %rax
movq 0x1008(%rax), %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rcx
callq 0xbc0b
leaq 0x30(%rsp), %r15
movq %r15, %rdi
leaq 0xc47a(%rip), %rsi      # 0x154b7
movq 0x10(%rsp), %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x3530
movq -0x8(%r13), %rsi
movl -0xc(%r13), %edx
movq %r15, %rdi
callq 0xa592
testl %ebp, %ebp
js 0x9089
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
decq %r12
jne 0x900b
incl %ebp
movq 0x8(%rsp), %rax
movq 0x1008(%rax), %rdi
movq 0x18(%rdi), %rax
cmpl (%rax), %ebp
jl 0x8fd8
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_O3/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 0x8c78
testl %eax, %eax
je 0x93d4
movl (%rbx), %esi
leaq 0xc191(%rip), %rdi      # 0x15557
xorl %eax, %eax
callq 0xa03c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x9404
leaq 0x13689(%rip), %rax     # 0x1ca64
cmpl $0x0, (%rax)
je 0x93fa
cmpl $0x0, (%r14)
je 0x93fa
movl (%rbx), %esi
leaq 0x4(%rbx), %rdx
leaq 0xc186(%rip), %rdi      # 0x15579
xorl %eax, %eax
callq 0xa10f
movq %rbx, %rdi
callq 0x940c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xb773
movq %rbx, %rdi
callq 0x90c4
movq 0x1008(%rbx), %rdi
callq 0xbb46
leaq 0x13639(%rip), %r14     # 0x1ca74
cmpl $0x0, (%r14)
je 0x946c
movq 0x1008(%rbx), %rdi
leaq 0x14de1(%rip), %r15     # 0x1e230
movq (%r15), %rsi
callq 0xbbcd
cmpl $0x0, (%r14)
je 0x946c
movq 0x1008(%rbx), %rdi
movq (%r15), %rsi
callq 0xbbec
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x9f1e