LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/ttoobne[P]bohttpd/src/core/threadpool.c
// Function: threadpool_destroy
int threadpool_destroy(threadpool_t* threadpool) {
    int i;

    do {
        if (threadpool == NULL) {
            log_error("arguments invalid.");
            break;
        }

        /* 取得互斥锁资源 */
        if (pthread_mutex_lock(&(threadpool->lock_mutex)) != 0) {
            log_error("lock failed.");
            break;
        }

        /* 如果线程池已经关闭，则直接返回 */
        if (threadpool->shutdown) {
            log_error("already shutting down.");
            break;
        }

        /* 将线程池设置为关闭 */
        threadpool->shutdown = 1;

        /* 广播通知线程终止并解锁 */
        if ((pthread_cond_broadcast(&(threadpool->nempty_cond)) != 0) ||
            (pthread_mutex_unlock(&(threadpool->lock_mutex)) != 0)) {
            log_error("threadpool unlock failed.");
            break;
        }

        /* 回收线程池中的所有线程 */
        for (i = 0; i < threadpool->thread_running; ++ i) {
            if (pthread_join(threadpool->threads[i], NULL) != 0) {
                log_error("thread join failed.");
            }
        }

        return threadpool_free(threadpool);

    } while (0);

    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x5eae
movq %rdi, %rbx
leaq 0x30(%rdi), %r14
movq %r14, %rdi
callq 0x2480
testl %eax, %eax
je 0x5ecf
leaq 0x1ffc(%rip), %rsi      # 0x7e8d
leaq 0x20ea(%rip), %rdx      # 0x7f82
leaq 0x211a(%rip), %r8       # 0x7fb9
movl $0x4, %edi
movl $0xdc, %ecx
jmp 0x5f38
leaq 0x1fd8(%rip), %rsi      # 0x7e8d
leaq 0x20c6(%rip), %rdx      # 0x7f82
leaq 0x1ff2(%rip), %r8       # 0x7eb5
movl $0x4, %edi
movl $0xd6, %ecx
jmp 0x5f38
cmpl $0x0, 0x28(%rbx)
je 0x5ef6
leaq 0x1fb1(%rip), %rsi      # 0x7e8d
leaq 0x209f(%rip), %rdx      # 0x7f82
leaq 0x20ab(%rip), %r8       # 0x7f95
movl $0x4, %edi
movl $0xe2, %ecx
jmp 0x5f38
movl $0x1, 0x28(%rbx)
leaq 0x88(%rbx), %rdi
callq 0x20a0
testl %eax, %eax
jne 0x5f19
movq %r14, %rdi
callq 0x22b0
testl %eax, %eax
je 0x5f53
leaq 0x1f6d(%rip), %rsi      # 0x7e8d
leaq 0x205b(%rip), %rdx      # 0x7f82
leaq 0x207e(%rip), %r8       # 0x7fac
movl $0x4, %edi
movl $0xec, %ecx
xorl %eax, %eax
callq 0x252a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x14(%rbx)
jle 0x5fa9
leaq 0x1f2d(%rip), %r14      # 0x7e8d
leaq 0x201b(%rip), %r15      # 0x7f82
leaq 0x2058(%rip), %r12      # 0x7fc6
xorl %r13d, %r13d
movq (%rbx), %rax
movq (%rax,%r13,8), %rdi
xorl %esi, %esi
callq 0x2420
testl %eax, %eax
je 0x5f9d
movl $0x4, %edi
movq %r14, %rsi
movq %r15, %rdx
movl $0xf3, %ecx
movq %r12, %r8
xorl %eax, %eax
callq 0x252a
incq %r13
movslq 0x14(%rbx), %rax
cmpq %rax, %r13
jl 0x5f71
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5ce4
nop
// File: /workspace/github_c_makefile_star2_O1/ttoobne[P]bohttpd/src/core/utility.c
// Function: set_nonblocking
int set_nonblocking(int fd)
{
    int old_option;
    int new_option;

    if ((old_option = fcntl(fd, F_GETFL)) == -1)
    {
        log_error("get fd option failed.");
        return -1;
    }

    new_option = old_option | O_NONBLOCK;

    if (fcntl(fd, F_SETFL, new_option) == -1)
    {
        log_error("set fd option failed.");
        return -1;
    }

    return old_option;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %r14d
movl $0x3, %esi
xorl %eax, %eax
callq 0x20e0
cmpl $-0x1, %eax
je 0x601a
movl %eax, %ebx
movl %eax, %edx
orl $0x800, %edx            # imm = 0x800
movl %r14d, %edi
movl $0x4, %esi
xorl %eax, %eax
callq 0x20e0
cmpl $-0x1, %eax
jne 0x6045
leaq 0x1fda(%rip), %rsi      # 0x7fda
leaq 0x1fe6(%rip), %rdx      # 0x7fed
leaq 0x2005(%rip), %r8       # 0x8013
movl $0x4, %edi
movl $0x26, %ecx
jmp 0x6039
leaq 0x1fb9(%rip), %rsi      # 0x7fda
leaq 0x1fc5(%rip), %rdx      # 0x7fed
leaq 0x1fce(%rip), %r8       # 0x7ffd
movl $0x4, %edi
movl $0x1e, %ecx
xorl %eax, %eax
callq 0x252a
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ttoobne[P]bohttpd/src/core/utility.c
// Function: ignore_sigpipe
int ignore_sigpipe()
{
    struct sigaction sa;

    memset(&sa, 0, sizeof(sa));
    sa.sa_handler = SIG_IGN;
    sa.sa_flags = 0;

    if (sigaction(SIGPIPE, &sa, NULL))
    {
        log_error("ignore SIGPIPE signal failed.");
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xa0, %rsp
leaq -0xa8(%rbp), %r14
xorl %ebx, %ebx
movl $0x98, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x21b0
movq $0x1, (%r14)
movl $0x0, 0x88(%r14)
movl $0xd, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x20b0
testl %eax, %eax
je 0x60c2
leaq 0x1f3c(%rip), %rsi      # 0x7fda
leaq 0x1f84(%rip), %rdx      # 0x8029
leaq 0x1f8c(%rip), %r8       # 0x8038
movl $0x4, %edi
movl $0x3a, %ecx
xorl %eax, %eax
callq 0x252a
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/main.c
// Function: help
void help() {
	char **s;
	fprintf(ferr, "\n");
	fprintf(ferr, "NAME\n");
	fprintf(ferr, "\n");
	fprintf(ferr, "%s\n", version);
	fprintf(ferr, "%s\n", copyright);

	fprintf(ferr, "\n");
	fprintf(ferr, "SYNOPSIS\n");
	fprintf(ferr, "\n");
	fprintf(ferr, "Command line options are processed strictly left-to-right. \n\n");
	// getopt must be initialized to print the syntax
	getopt_help(&getopt_parser, stdout, arg_menu_linewidth, 10, PROGNAME);
	fprintf(ferr, "\n");
	fprintf(ferr, "EXAMPLES\n");
	fprintf(ferr, "\n");
	for (s = examples; *s; s++)
		fputs(*s, ferr);

	fprintf(ferr, "\n");
	fprintf(ferr, "SEE ALSO\n");
	fprintf(ferr, "\n");
	fprintf(ferr, "Online docs: www.retrocmp.com/tools/tu58fs \n");
	fprintf(ferr, "Repository: https://github.com/j-hoppe/tu58fs\n");
	fprintf(ferr, "Contact: j_hoppe@t-online.de\n");
	fprintf(ferr, "\n");
	exit(1);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x1ab49(%rip), %r14     # 0x1e240
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r14), %rcx
leaq 0xe922(%rip), %rdi      # 0x12030
movl $0x5, %esi
movl $0x1, %edx
callq 0x3560
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r14), %rdi
leaq 0x12612(%rip), %rbx     # 0x15d46
leaq 0x18bf5(%rip), %rdx     # 0x1c330
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3320
movq (%r14), %rdi
leaq 0x18c41(%rip), %rdx     # 0x1c390
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3320
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r14), %rcx
leaq 0xe8c6(%rip), %rdi      # 0x12036
movl $0x9, %esi
movl $0x1, %edx
callq 0x3560
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r14), %rcx
leaq 0xe8aa(%rip), %rdi      # 0x12040
movl $0x3d, %esi
movl $0x1, %edx
callq 0x3560
movq 0x18824(%rip), %rax     # 0x1bfd0
movq (%rax), %rsi
movl 0x18b6f(%rip), %edx     # 0x1c324
leaq 0x192e4(%rip), %rdi     # 0x1caa0
leaq 0xe8bb(%rip), %r8       # 0x1207e
movl $0xa, %ecx
callq 0x5e9a
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r14), %rcx
leaq 0xe8a1(%rip), %rdi      # 0x12085
movl $0x9, %esi
movl $0x1, %edx
callq 0x3560
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
leaq 0xeb76(%rip), %rdi      # 0x1237d
leaq 0x183fa(%rip), %rbx     # 0x1bc08
movq (%r14), %rsi
callq 0x3220
movq (%rbx), %rdi
addq $0x8, %rbx
testq %rdi, %rdi
jne 0x380e
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r14), %rcx
leaq 0xe856(%rip), %rdi      # 0x1208f
movl $0x9, %esi
movl $0x1, %edx
callq 0x3560
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r14), %rcx
leaq 0xe83a(%rip), %rdi      # 0x12099
movl $0x2c, %esi
movl $0x1, %edx
callq 0x3560
movq (%r14), %rcx
leaq 0xe84e(%rip), %rdi      # 0x120c6
movl $0x2e, %esi
movl $0x1, %edx
callq 0x3560
movq (%r14), %rcx
leaq 0xe864(%rip), %rdi      # 0x120f5
movl $0x1d, %esi
movl $0x1, %edx
callq 0x3560
movq (%r14), %rsi
movl $0xa, %edi
callq 0x32a0
movl $0x1, %edi
callq 0x3550
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/main.c
// Function: commandline_option_error
static void commandline_option_error(char *errtext, ...) {
	va_list args;
	fprintf(ferr, "Error while parsing commandline option:\n");
	if (errtext) {
		va_start(args, errtext);
		vfprintf(ferr, errtext, args);
		fprintf(ferr, "\nSyntax:  ");
		va_end(args);
	} else
		fprintf(ferr, "  %s\nSyntax:  ", getopt_parser.curerrortext);
	getopt_help_option(&getopt_parser, stdout, 96, 10);
	exit(1);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x5040
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 0x191f9(%rip), %r14     # 0x1e240
movq (%r14), %rcx
leaq 0xf037(%rip), %rdi      # 0x14088
movl $0x28, %esi
movl $0x1, %edx
callq 0x3560
testq %rbx, %rbx
jne 0x507f
movq (%r14), %rdi
leaq 0xf042(%rip), %rsi      # 0x140b1
leaq 0x180ae(%rip), %rdx     # 0x1d124
xorl %eax, %eax
callq 0x3320
jmp 0x50c8
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rdx)
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x3500
movq (%r14), %rcx
leaq 0xeffc(%rip), %rdi      # 0x140b5
movl $0xa, %esi
movl $0x1, %edx
callq 0x3560
movq 0x16f01(%rip), %rax     # 0x1bfd0
movq (%rax), %rsi
leaq 0x179c7(%rip), %rdi     # 0x1caa0
movl $0x60, %edx
movl $0xa, %ecx
callq 0x667b
movl $0x1, %edi
callq 0x3550
nop
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_isoption
int getopt_isoption(getopt_t *_this, char *name)
{
	if (name == NULL && _this->cur_option == _this->nonoption_descr)
		return 1; // were parsing the non-option args
	if (!_this->cur_option)
		return 0; // not equal
	if (!name) // nonoption args already tested
		return 0;
	// names NULL for nonoption-args
	if (_this->cur_option->short_name && !getopt_strcmp(_this, name, _this->cur_option->short_name))
		return 1;
	if (_this->cur_option->long_name && !getopt_strcmp(_this, name, _this->cur_option->long_name))
		return 1;
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
testq %rsi, %rsi
jne 0x53d3
movq 0x338(%r15), %rax
cmpq 0x8(%r15), %rax
je 0x541e
testq %r14, %r14
sete %al
movq 0x338(%r15), %r12
testq %r12, %r12
sete %cl
xorl %ebx, %ebx
orb %al, %cl
jne 0x5423
movq 0x8(%r12), %rdx
testq %rdx, %rdx
je 0x5405
movq %r15, %rdi
movq %r14, %rsi
callq 0x5431
testl %eax, %eax
je 0x541e
movq 0x10(%r12), %rdx
testq %rdx, %rdx
je 0x5423
movq %r15, %rdi
movq %r14, %rsi
callq 0x5431
testl %eax, %eax
jne 0x5423
movl $0x1, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_parse_error
static int getopt_parse_error(getopt_t *_this, int error)
{
	_this->curerror = error;
	switch (error) {
	case GETOPT_STATUS_ILLEGALOPTION:
		snprintf(_this->curerrortext, sizeof(_this->curerrortext),
			"Undefined option at \"%s\"", _this->curtoken);
		break;
	case GETOPT_STATUS_MINARGCOUNT:
		if (_this->cur_option == _this->nonoption_descr)
			snprintf(_this->curerrortext, sizeof(_this->curerrortext),
				"Less than %d non-option arguments at \"%s\"",
				_this->cur_option->fix_arg_count, _this->curtoken);
		else
			snprintf(_this->curerrortext, sizeof(_this->curerrortext),
				"Less than %d arguments for option \"%s\" at \"%s\"",
				_this->cur_option->fix_arg_count, _this->cur_option->long_name, _this->curtoken);
		break;
	case GETOPT_STATUS_MAXARGCOUNT:
		if (_this->cur_option == _this->nonoption_descr)
			snprintf(_this->curerrortext, sizeof(_this->curerrortext),
				"More than %d non-option arguments at \"%s\"", _this->cur_option->max_arg_count, _this->curtoken);
		else
			snprintf(_this->curerrortext, sizeof(_this->curerrortext),
				"More than %d arguments for option \"%s\" at \"%s\"",
				_this->cur_option->max_arg_count, _this->cur_option->long_name, _this->curtoken);
		break;
	}
	return error;
}

// Assembly:
pushq %rbx
movl %esi, %ebx
movl %esi, 0x680(%rdi)
cmpl $-0x3, %esi
je 0x57e1
cmpl $-0x2, %ebx
jne 0x581e
movq 0x338(%rdi), %rdx
leaq 0x684(%rdi), %rax
movl 0x678(%rdx), %ecx
cmpq 0x8(%rdi), %rdx
je 0x5841
movq 0x10(%rdx), %r8
movq 0x678(%rdi), %r9
leaq 0xed8d(%rip), %rdx      # 0x1456c
jmp 0x580d
movq 0x338(%rdi), %rdx
leaq 0x684(%rdi), %rax
movl 0x67c(%rdx), %ecx
cmpq 0x8(%rdi), %rdx
je 0x5851
movq 0x10(%rdx), %r8
movq 0x678(%rdi), %r9
leaq 0xedb8(%rip), %rdx      # 0x145c5
movl $0x101, %esi            # imm = 0x101
movq %rax, %rdi
xorl %eax, %eax
callq 0x31e0
jmp 0x586e
movq 0x678(%rdi), %rcx
addq $0x684, %rdi            # imm = 0x684
leaq 0xecf6(%rip), %rdx      # 0x14529
movl $0x101, %esi            # imm = 0x101
xorl %eax, %eax
callq 0x31e0
jmp 0x586e
movq 0x678(%rdi), %r8
leaq 0xecf3(%rip), %rdx      # 0x14542
jmp 0x585f
movq 0x678(%rdi), %r8
leaq 0xed3c(%rip), %rdx      # 0x1459b
movl $0x101, %esi            # imm = 0x101
movq %rax, %rdi
xorl %eax, %eax
callq 0x31e0
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_arg_s
int getopt_arg_s(getopt_t *_this, char *argname, char *val, unsigned valsize)
{
	int argidx;
	getopt_option_descr_t  *odesc = _this->cur_option;
	if (!odesc)
		return getopt_parse_error(_this, GETOPT_STATUS_ILLEGALOPTION);
	argidx = getopt_optionargidx(_this, odesc, argname);
	if (argidx < 0)
		return getopt_arg_error(_this, odesc, GETOPT_STATUS_ILLEGALARG, argname, NULL);
	if (argidx >= (int)_this->cur_option_argvalcount)
		// only n args specified, but this has list place > n
		// the optional argument [argidx] is not given in the arguument list
		return GETOPT_STATUS_EOF;
	//		return getopt_arg_error(_this, odesc, GETOPT_STATUS_ARGNOTSET, argname, NULL);
	strncpy(val, _this->cur_option_argval[argidx], valsize);
	val[valsize - 1] = 0;
	return GETOPT_STATUS_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x338(%rdi), %r13
testq %r13, %r13
je 0x5b60
movq %rsi, %r12
movq %rdx, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movslq 0x678(%r13), %rbp
testq %rbp, %rbp
jle 0x5afe
xorl %r14d, %r14d
movq 0x18(%r13,%r14,8), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5431
testl %eax, %eax
je 0x5b95
incq %r14
cmpq %r14, %rbp
jne 0x5ade
movl 0x67c(%r13), %r15d
cmpl %r15d, %ebp
jge 0x5b2e
leaq 0x340(%r13), %r14
movq (%r14), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5431
testl %eax, %eax
je 0x5b98
incl %ebp
addq $0x8, %r14
cmpl %ebp, %r15d
jne 0x5b11
movl $0xfffffffb, 0x680(%rbx) # imm = 0xFFFFFFFB
leaq 0x684(%rbx), %rdi
movq 0x10(%r13), %r8
leaq 0xeacb(%rip), %rdx      # 0x14615
movl $0x101, %esi            # imm = 0x101
movq %r12, %rcx
xorl %eax, %eax
callq 0x31e0
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
jmp 0x5b98
movl $0xffffffff, 0x680(%rbx) # imm = 0xFFFFFFFF
movq 0x678(%rbx), %rcx
addq $0x684, %rbx            # imm = 0x684
leaq 0xe9aa(%rip), %rdx      # 0x14529
movl $0x101, %esi            # imm = 0x101
movq %rbx, %rdi
xorl %eax, %eax
callq 0x31e0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5c05
movl %r14d, %ebp
testl %ebp, %ebp
js 0x5bd2
xorl %eax, %eax
cmpl 0x670(%rbx), %ebp
jge 0x5c05
movl %ebp, %eax
movq 0x348(%rbx,%rax,8), %rsi
movq 0x10(%rsp), %rbx
movl %ebx, %edx
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x30a0
decl %ebx
movb $0x0, (%r14,%rbx)
movl $0x1, %eax
jmp 0x5c05
movl $0xfffffffc, 0x680(%rbx) # imm = 0xFFFFFFFC
addq $0x684, %rbx            # imm = 0x684
movq 0x10(%r13), %rcx
leaq 0xea06(%rip), %rdx      # 0x145f4
movl $0x101, %esi            # imm = 0x101
movq %rbx, %rdi
movq %r12, %r8
xorl %eax, %eax
callq 0x31e0
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_arg_i
int getopt_arg_i(getopt_t *_this, char *argname, int *val)
{
	int res;
	char *endptr;
	char buff[GETOPT_MAX_LINELEN + 1];
	res = getopt_arg_s(_this, argname, buff, sizeof(buff));
	if (res <= 0) // error or EOF
		return res;
	*val = strtol(buff, &endptr, 0);
	if (*endptr) // stop char: error
		return getopt_arg_error(_this, _this->cur_option, GETOPT_STATUS_ARGFORMATINT, argname, buff);
	return GETOPT_STATUS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %rdx
movl $0x101, %ecx            # imm = 0x101
callq 0x5aa1
testl %eax, %eax
jle 0x5ca5
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0x3340
movl %eax, (%r15)
movq (%r12), %rax
cmpb $0x0, (%rax)
je 0x5ca0
movq 0x338(%r14), %rax
movl $0xfffffffa, 0x680(%r14) # imm = 0xFFFFFFFA
addq $0x684, %r14            # imm = 0x684
movq 0x10(%rax), %r8
leaq 0xe9c2(%rip), %rdx      # 0x14644
leaq 0x10(%rsp), %r9
movl $0x101, %esi            # imm = 0x101
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
jmp 0x5ca5
movl $0x1, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_arg_u
int getopt_arg_u(getopt_t *_this, char *argname, unsigned *val)
{
	int res;
	char *endptr;
	char buff[GETOPT_MAX_LINELEN + 1];
	res = getopt_arg_s(_this, argname, buff, sizeof(buff));
	if (res <= 0) // error or EOF
		return res;
	*val = strtoul(buff, &endptr, 0);
	if (*endptr) // stop char: error
		return getopt_arg_error(_this, _this->cur_option, GETOPT_STATUS_ARGFORMATINT, argname, buff);
	return GETOPT_STATUS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %rdx
movl $0x101, %ecx            # imm = 0x101
callq 0x5aa1
testl %eax, %eax
jle 0x5d45
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0x3510
movl %eax, (%r15)
movq (%r12), %rax
cmpb $0x0, (%rax)
je 0x5d40
movq 0x338(%r14), %rax
movl $0xfffffffa, 0x680(%r14) # imm = 0xFFFFFFFA
addq $0x684, %r14            # imm = 0x684
movq 0x10(%rax), %r8
leaq 0xe922(%rip), %rdx      # 0x14644
leaq 0x10(%rsp), %r9
movl $0x101, %esi            # imm = 0x101
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
jmp 0x5d45
movl $0x1, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_arg_o
int getopt_arg_o(getopt_t *_this, char *argname, int *val)
{
	int res;
	char *endptr;
	char buff[GETOPT_MAX_LINELEN + 1];
	res = getopt_arg_s(_this, argname, buff, sizeof(buff));
	if (res <= 0) // error or EOF
		return res;
	*val = strtol(buff, &endptr, 8);
	if (*endptr) // stop char: error
		return getopt_arg_error(_this, _this->cur_option, GETOPT_STATUS_ARGFORMATHEX, argname, buff);
	return GETOPT_STATUS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %rdx
movl $0x101, %ecx            # imm = 0x101
callq 0x5aa1
testl %eax, %eax
jle 0x5de8
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
movl $0x8, %edx
callq 0x3340
movl %eax, (%r15)
movq (%r12), %rax
cmpb $0x0, (%rax)
je 0x5de3
movq 0x338(%r14), %rax
movl $0xfffffff9, 0x680(%r14) # imm = 0xFFFFFFF9
addq $0x684, %r14            # imm = 0x684
movq 0x10(%rax), %r8
leaq 0xe8c0(%rip), %rdx      # 0x14685
leaq 0x10(%rsp), %r9
movl $0x101, %esi            # imm = 0x101
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
movl $0xfffffff9, %eax       # imm = 0xFFFFFFF9
jmp 0x5de8
movl $0x1, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_arg_h
int getopt_arg_h(getopt_t *_this, char *argname, int *val)
{
	int res;
	char *endptr;
	char buff[GETOPT_MAX_LINELEN + 1];
	res = getopt_arg_s(_this, argname, buff, sizeof(buff));
	if (res <= 0) // error or EOF
		return res;
	*val = strtol(buff, &endptr, 16);
	if (*endptr) // stop char: error
		return getopt_arg_error(_this, _this->cur_option, GETOPT_STATUS_ARGFORMATHEX, argname, buff);
	return GETOPT_STATUS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %rdx
movl $0x101, %ecx            # imm = 0x101
callq 0x5aa1
testl %eax, %eax
jle 0x5e8b
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
movl $0x10, %edx
callq 0x3340
movl %eax, (%r15)
movq (%r12), %rax
cmpb $0x0, (%rax)
je 0x5e86
movq 0x338(%r14), %rax
movl $0xfffffff9, 0x680(%r14) # imm = 0xFFFFFFF9
addq $0x684, %r14            # imm = 0x684
movq 0x10(%rax), %r8
leaq 0xe81d(%rip), %rdx      # 0x14685
leaq 0x10(%rsp), %r9
movl $0x101, %esi            # imm = 0x101
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
movl $0xfffffff9, %eax       # imm = 0xFFFFFFF9
jmp 0x5e8b
movl $0x1, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/j-hoppe[P]tu58fs/getopt2.c
// Function: output_append
static void output_append(FILE *stream, char *line, int linesize, char *s, int linebreak, unsigned linelen, unsigned indent)
{
	unsigned _i_;
	if (linebreak
		|| (strlen(line) > indent && (strlen(line) + strlen(s)) > linelen)) {
		// prevent the indent from prev line to be accounted for another line break
		fprintf(stream, "%s\n", line); \
			for (_i_ = 0; _i_ < indent; _i_++) line[_i_] = ' ';
		line[_i_] = 0;
	}
	strncat(line, s, linesize);
	line[linesize - 1] = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %ebp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
testl %ecx, %ecx
je 0x62c1
leaq 0xfab3(%rip), %rsi      # 0x15d46
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3320
testl %ebp, %ebp
je 0x62ba
movl %ebp, %r12d
movq %rbx, %rdi
movl $0x20, %esi
movq %r12, %rdx
callq 0x3230
movb $0x0, (%rbx,%r12)
jmp 0x62e9
movl %r8d, %r12d
movq %rbx, %rdi
callq 0x31a0
movq %rax, %r13
movl %ebp, %eax
cmpq %rax, %r13
jbe 0x62e9
movq %r14, %rdi
callq 0x31a0
addq %r13, %rax
movl %r12d, %ecx
cmpq %rcx, %rax
ja 0x628c
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3260
movb $0x0, 0x1ff(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x6651
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 0xe0d6(%rip), %rdx      # 0x146db
leaq 0xe0d0(%rip), %rcx      # 0x146dc
cmoveq %rcx, %rdx
movq (%rax), %rcx
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdi
xorl %eax, %eax
callq 0x31e0
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movl %r14d, %r8d
movl 0x4(%rsp), %r9d
callq 0x6271
incq %rbp
movslq 0xb70(%r15), %rax
addq $0x8, %r13
cmpq %rax, %rbp
jl 0x65f4
leaq 0xf6ee(%rip), %rsi      # 0x15d46
leaq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x3320
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x3580
movq %rax, %r12
cmpb $0x0, (%rax)
je 0x6711
movq %r12, %rdx
movq %r12, %r13
movzbl (%r13), %eax
testl %eax, %eax
je 0x66ee
cmpl $0xa, %eax
je 0x66cb
incq %r13
jmp 0x66b8
movb $0x0, (%r13)
xorl %ecx, %ecx
cmpq %r12, %rdx
setne %cl
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %r8d
movl %ebx, %r9d
callq 0x6271
incq %r13
jmp 0x6707
xorl %ecx, %ecx
cmpq %r12, %rdx
setne %cl
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %r8d
movl %ebx, %r9d
callq 0x6271
cmpb $0x0, (%r13)
movq %r13, %rdx
jne 0x66b8
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3050
nop
// File: /workspace/github_c_makefile_star2_O1/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 0x17738(%rip), %r14     # 0x1de90
cmpq $0x0, (%r14,%rbx,8)
je 0x676d
leaq 0xe076(%rip), %rdi      # 0x147dc
xorl %eax, %eax
callq 0xa2ef
movl $0x1, %edi
movl %ebx, %esi
movl %ebp, %edx
callq 0x7a40
movq %rax, (%r14,%rbx,8)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x176ee(%rip), %r15     # 0x1de90
movq (%r14,%r15), %rbx
testq %rbx, %rbx
je 0x67c4
cmpb $0x0, 0xf4(%rbx)
je 0x67bc
movq %rbx, %rdi
callq 0x83d8
movq %rbx, %rdi
callq 0x8438
addq $0x8, %r14
cmpq $0x40, %r14
jne 0x67a2
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x162ac(%rip), %rax     # 0x1ca90
cmpl $0x0, (%rax)
je 0x683d
leaq 0x176a0(%rip), %r12     # 0x1de90
leaq 0x1628d(%rip), %r13     # 0x1ca84
leaq 0xe007(%rip), %rbx      # 0x14805
xorl %r14d, %r14d
movq (%r12), %r15
testq %r15, %r15
je 0x6830
cmpb $0x0, 0xf4(%r15)
je 0x6830
cmpl $0x0, (%r13)
je 0x6828
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0xa127
movq %r15, %rdi
callq 0x83d8
incq %r14
addq $0x8, %r12
cmpq $0x8, %r14
jne 0x6801
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x1686b(%rip), %rbx     # 0x1ded8
movq %rbx, %rdi
callq 0x84f5
movq %rbx, %rdi
callq 0x84ce
movl $0x5, %edi
callq 0xa411
movq %rbx, %rdi
callq 0x84b9
movq %rbx, %rdi
movl $0x4, %esi
callq 0x8646
movq %rbx, %rdi
movl $0x4, %esi
callq 0x8646
movq %rbx, %rdi
popq %rbx
jmp 0x85be
// File: /workspace/github_c_makefile_star2_O1/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 0xa41c
leaq 0x153c5(%rip), %r13     # 0x1ca90
movslq (%r13), %rcx
imulq $0x3e8, %rcx, %r15      # imm = 0x3E8
addq %rax, %r15
leaq 0x167f8(%rip), %rbx     # 0x1ded8
leaq 0x1538d(%rip), %rbp     # 0x1ca74
leaq 0xd23f(%rip), %r14      # 0x1492d
movq %rbx, %rdi
callq 0x851c
leal 0x1(%rax), %ecx
cmpl $0x2, %ecx
jb 0x7728
leal -0x1(%rax), %ecx
cmpl $0x1, %ecx
ja 0x7718
cmpl $0x0, (%rbp)
je 0x7728
movq %r14, %rdi
xorl %eax, %eax
callq 0xa127
jmp 0x7728
leaq 0xd21d(%rip), %rdi      # 0x1493c
movl %eax, %esi
xorl %eax, %eax
callq 0xa054
xorl %eax, %eax
callq 0xa41c
cmpq %rax, %r15
jae 0x7773
movq %rax, %r12
movslq (%r13), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq 0x1679f(%rip), %rcx     # 0x1dee8
addq %rax, %rcx
cmpq %r12, %rcx
jae 0x7773
addq 0x16798(%rip), %rax     # 0x1def0
cmpq %r12, %rax
jae 0x7773
callq 0x67d4
movslq (%r13), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
addq %rax, %r12
movq %r12, %r15
movl $0x5, %edi
callq 0xa411
jmp 0x76ee
// File: /workspace/github_c_makefile_star2_O1/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 0x1673a(%rip), %r14     # 0x1ded8
movq %r14, %rdi
callq 0x860f
movb %al, (%r15)
incq %r15
decl %ebp
cmpl $0x1, %ebp
jg 0x779e
movzbl -0x1(%r15), %ebp
movzbl -0x2(%r15), %eax
movzbl 0x1(%rbx), %ecx
addl $0x4, %ecx
xorl %edi, %edi
movq %rbx, %rdx
movzbl (%rdx), %esi
addl %edi, %esi
cmpl $0x3, %ecx
jne 0x77d8
incq %rdx
jmp 0x77e5
movzbl 0x1(%rdx), %edi
addq $0x2, %rdx
shll $0x8, %edi
addl %edi, %esi
movl %esi, %r14d
shrl $0x10, %r14d
addl %esi, %r14d
movzwl %r14w, %edi
addl $-0x2, %ecx
cmpl $0x2, %ecx
jg 0x77c9
shll $0x8, %ebp
orl %eax, %ebp
leaq 0x1527d(%rip), %rax     # 0x1ca84
cmpl $0x0, (%rax)
je 0x781b
leaq 0xd250(%rip), %rsi      # 0x14a63
movq %rbx, %rdi
callq 0x7937
movzwl %r14w, %ebx
cmpl %ebx, %ebp
je 0x7835
leaq 0xd243(%rip), %rdi      # 0x14a6d
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xa054
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_O1/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 %r12
pushq %rbx
movq %rdi, %rbx
movzbl 0x1(%rdi), %ebp
addl $0x3, %ebp
leaq 0x16678(%rip), %r14     # 0x1ded8
movq %rdi, %r15
movzbl (%r15), %esi
incq %r15
movq %r14, %rdi
callq 0x8646
movzbl 0x16607(%rip), %edi     # 0x1de80
callq 0x79de
decl %ebp
cmpl $0x1, %ebp
jg 0x7863
movzbl 0x1(%rbx), %eax
addl $0x4, %eax
xorl %esi, %esi
movq %rbx, %rcx
movzbl (%rcx), %edx
addl %esi, %edx
cmpl $0x3, %eax
jne 0x78a0
incq %rcx
jmp 0x78ad
movzbl 0x1(%rcx), %esi
addq $0x2, %rcx
shll $0x8, %esi
addl %esi, %edx
movl %edx, %ebp
shrl $0x10, %ebp
addl %edx, %ebp
movzwl %bp, %esi
addl $-0x2, %eax
cmpl $0x2, %eax
jg 0x7891
movb %bpl, (%r15)
movl $0xff, %r12d
movl %ebp, %esi
andl %r12d, %esi
leaq 0x16604(%rip), %r14     # 0x1ded8
movq %r14, %rdi
callq 0x8646
movzbl 0x1659d(%rip), %edi     # 0x1de80
callq 0x79de
shrl $0x8, %ebp
movb %bpl, 0x1(%r15)
andl %r12d, %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x8646
movzbl 0x1657d(%rip), %edi     # 0x1de80
callq 0x79de
leaq 0x15175(%rip), %rax     # 0x1ca84
cmpl $0x0, (%rax)
je 0x7923
leaq 0xd3b4(%rip), %rsi      # 0x14ccf
movq %rbx, %rdi
callq 0x7937
leaq 0x165ae(%rip), %rdi     # 0x1ded8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x85be
// File: /workspace/github_c_makefile_star2_O1/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 0x1514e(%rip), %rax     # 0x1ca8c
cmpl $0x0, (%rax)
je 0x7944
retq
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rdx
movq %rdi, %rbx
leaq 0x168e7(%rip), %r15     # 0x1e240
movq (%r15), %rdi
leaq 0xd13a(%rip), %rsi      # 0x14a9d
xorl %eax, %eax
callq 0x3320
leaq 0xd138(%rip), %r14      # 0x14aa9
xorl %r12d, %r12d
cmpl $0x2, %r12d
je 0x7989
leal -0x3(%r12), %eax
andl $0x8000001f, %eax       # imm = 0x8000001F
cmpl $0x1f, %eax
jne 0x7996
movq (%r15), %rsi
movl $0xa, %edi
callq 0x32a0
movq (%r15), %rdi
movzbl (%rbx,%r12), %edx
movq %r14, %rsi
xorl %eax, %eax
callq 0x3320
movzbl 0x1(%rbx), %eax
addl $0x2, %eax
incq %r12
cmpl %eax, %r12d
jb 0x7974
movq (%r15), %rdi
movzbl (%rbx,%r12), %edx
movzbl 0x1(%rbx,%r12), %ecx
leaq 0xd0e3(%rip), %rsi      # 0x14aaf
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3320
// File: /workspace/github_c_makefile_star2_O1/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 0x7a3e
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0xffffff6e, %r15d      # imm = 0xFFFFFF6E
leaq 0x164e1(%rip), %rbx     # 0x1ded8
leaq 0x15086(%rip), %r12     # 0x1ca84
leaq 0xd2d4(%rip), %r14      # 0x14cd9
movq %rbx, %rdi
callq 0x860f
movl %eax, %ebp
cmpl $0x0, (%r12)
je 0x7a24
movzbl %bpl, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0xa127
cmpb $0x10, %bpl
je 0x7a36
leal 0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
jne 0x7a05
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 0x33c0
movq %rax, %rbx
leaq 0x8(%rax), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x35b0
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 0x14a1d(%rip), %rdi     # 0x1c4c0
movl $0x20, %esi
movl %r15d, %edx
callq 0xb12a
movq %rax, 0xe8(%rbx)
testq %rax, %rax
je 0x7b40
movl $0x200, 0xf0(%rbx)      # imm = 0x200
leal 0x1ff(%r14), %edx
addl $0x3fe, %r14d           # imm = 0x3FE
testl %edx, %edx
cmovsl %r14d, %edx
sarl $0x9, %edx
movl %edx, 0x40(%rbx)
leaq 0x18(%rax), %rsi
cmpl $0x3ff, %r14d           # imm = 0x3FF
jae 0x7af6
movq %rsi, %rcx
jmp 0x7b0c
movq %rbx, %rcx
addq $0x40, %rcx
movl (%rsi), %esi
cmpl %esi, %edx
jl 0x7b0a
movl 0x1c(%rax), %esi
cmpl %esi, %edx
jle 0x7b0c
movl %esi, (%rcx)
movl (%rcx), %edi
shll $0x9, %edi
movl %edi, 0x110(%rbx)
callq 0x33c0
movq %rax, 0x118(%rbx)
movl $0xf4240, %edi          # imm = 0xF4240
callq 0xb160
movq %rax, 0xf8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd274(%rip), %rdi      # 0x14dbb
leaq 0xd280(%rip), %rsi      # 0x14dce
leaq 0xd281(%rip), %rcx      # 0x14dd6
movl $0x74, %edx
callq 0x3210
// File: /workspace/github_c_makefile_star2_O1/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 0x7f86
leaq 0x120(%rdi), %rax
testl %edx, %edx
je 0x7f81
movq %rax, %rcx
cmpl $0x1, %edx
je 0x7f7f
cmpl $0x2, %edx
jne 0x7f9b
addq $0x110, %rdi            # imm = 0x110
movq %rdi, %rcx
addl (%rcx), %esi
movl %esi, (%rax)
movl %esi, %eax
retq
movl (%rdi), %edx
leaq 0xcf26(%rip), %rsi      # 0x14eb5
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
jmp 0x9f8f
leaq 0xcf31(%rip), %rsi      # 0x14ed3
movl $0xfffffff9, %edi       # imm = 0xFFFFFFF9
xorl %eax, %eax
jmp 0x9f8f
// File: /workspace/github_c_makefile_star2_O1/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 0x7ff7
movl %ecx, %r15d
movl %edx, %ebp
movl %esi, %r12d
leaq 0x8(%r14), %rbx
movq %rbx, %rdi
callq 0x35d0
imull %r12d, %ebp
addl %r15d, %ebp
cmpb $0x0, 0xf4(%r14)
je 0x8015
movl 0x110(%r14), %eax
movl %eax, 0x120(%r14)
jmp 0x802b
movl (%r14), %edx
leaq 0xcef0(%rip), %rsi      # 0x14ef1
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f8f
movl (%r14), %edx
leaq 0xce96(%rip), %rsi      # 0x14eb5
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
callq 0x9f8f
movl $0xfffffff7, %r15d      # imm = 0xFFFFFFF7
cmpl %eax, %ebp
jg 0x8069
cmpb $0x0, 0xf4(%r14)
je 0x8048
movl %ebp, 0x120(%r14)
jmp 0x8060
movl (%r14), %edx
leaq 0xce63(%rip), %rsi      # 0x14eb5
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
callq 0x9f8f
movl %eax, %ebp
sarl $0x1f, %ebp
andl $-0x9, %ebp
movl %ebp, %r15d
movq %rbx, %rdi
callq 0x33b0
leaq 0xce9b(%rip), %rsi      # 0x14f13
movl %r15d, %edi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f8f
// File: /workspace/github_c_makefile_star2_O1/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 0x80f2
movl %edx, %ebp
movq %rsi, %r14
leaq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x35d0
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 0x3350
addl %r12d, 0x120(%rbx)
movq %r15, %rdi
callq 0x33b0
movl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %edx
leaq 0xce35(%rip), %rsi      # 0x14f30
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f8f
// File: /workspace/github_c_makefile_star2_O1/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 0x8134
cmpl $0x0, 0x3c(%rbx)
je 0x8151
movl (%rbx), %edx
leaq 0xce64(%rip), %rsi      # 0x14f96
jmp 0x813d
movl (%rbx), %edx
leaq 0xce10(%rip), %rsi      # 0x14f4d
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x9f8f
movl %edx, %r12d
movq %rsi, %r15
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x35d0
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 0x3350
movb $0x1, 0xf5(%rbx)
xorl %eax, %eax
callq 0xa41c
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 0x81e7
movq 0xf8(%rbx), %rdi
movl %r15d, %esi
callq 0xb1c9
incl %r15d
movl 0x120(%rbx), %ecx
addl %ebp, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl 0xf0(%rbx)
jmp 0x81bc
movl %ecx, 0x120(%rbx)
movq %r14, %rdi
callq 0x33b0
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq