LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: tapAddBlock
void tapAddBlock(FILE* file, int len, char* buf, int type) {
	int crc = type & 0xff;
	for (int i = 0; i < len; i++) {
		crc ^= buf[i];
	}
	fputc((len + 2) & 0xff, file);
	fputc(((len + 2) >> 8) & 0xff, file);
	fputc(type, file);
	fwrite(buf, len, 1, file);
	fputc(crc, file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %rbx
movl %ecx, -0x2c(%rbp)
movzbl %cl, %r14d
xorl %eax, %eax
testl %esi, %esi
movl $0x0, %ecx
cmovgl %esi, %ecx
cmpq %rax, %rcx
je 0x401fc3
movsbl (%r15,%rax), %edx
xorl %edx, %r14d
incq %rax
jmp 0x401fb1
leal 0x2(%r12), %r13d
movl $0xff, %eax
movl %r13d, %edi
andl %eax, %edi
movq %rbx, %rsi
callq 0x418870
shrl $0x8, %r13d
movl $0xff, %eax
andl %eax, %r13d
movl %r13d, %edi
movq %rbx, %rsi
callq 0x418870
movl -0x2c(%rbp), %edi
movq %rbx, %rsi
callq 0x418870
movslq %r12d, %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x414ab0
movl %r14d, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x418870
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: tapList
void tapList(char* path) {
	FILE* file = fopen(path, "rb");
	if (!file) {
		printf("Can't open image '%s'\n",path);
		return;
	}
	int len;
	tHead hd;
	int blk = 0;
	printf("Name\t\tType\tStart\tSize\n");
	printf("------------------------------------\n");
	while (1) {
		len = fgetc(file);
		len |= (fgetc(file) << 8);
		if (feof(file)) break;
		int type = fgetc(file);
		if (type == 0x00) {
			fread((char*)&hd, sizeof(tHead), 1, file);
			printf("%.10s\t%s\t%i\t%i\n",hd.name, hd.type ? "Bytes" : "Prog", hd.asl | (hd.ash << 8), hd.dll | (hd.dlh << 8));
			fgetc(file);		// skip crc
		} else {
			fseek(file, len - 1, SEEK_CUR);
			printf("blk-%.3i\t\t\t\t%i\n",blk,len - 2);
		}
		blk++;
	}
	fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x9d002(%rip), %rsi     # 0x49f051
callq 0x414760
testq %rax, %rax
je 0x40214d
movq %rax, %rbx
leaq 0x9d404(%rip), %rdi     # 0x49f46b
callq 0x414d80
leaq 0x9d40e(%rip), %rdi     # 0x49f481
callq 0x414d80
leaq 0x9d082(%rip), %r12     # 0x49f101
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x418a90
movl %eax, %r15d
movq %rbx, %rdi
callq 0x418a90
movl %eax, %r14d
movq %rbx, %rdi
callq 0x4187a0
testl %eax, %eax
jne 0x402136
movq %rbx, %rdi
callq 0x418a90
testl %eax, %eax
je 0x4020e3
shll $0x8, %r14d
orl %r15d, %r14d
leal -0x1(%r14), %eax
movslq %eax, %rsi
movq %rbx, %rdi
pushq $0x1
popq %rdx
callq 0x4189b0
addl $-0x2, %r14d
movq %r12, %rdi
movl %r13d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x40dd00
jmp 0x40212e
leaq -0x39(%rbp), %rdi
pushq $0x11
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x414860
cmpb $0x0, -0x39(%rbp)
leaq 0x9cff6(%rip), %rdx     # 0x49f0f6
leaq 0x9cff5(%rip), %rax     # 0x49f0fc
cmoveq %rax, %rdx
movzwl -0x2c(%rbp), %ecx
movzwl -0x2e(%rbp), %r8d
leaq 0x9cfcb(%rip), %rdi     # 0x49f0e6
leaq -0x38(%rbp), %rsi
xorl %eax, %eax
callq 0x40dd00
movq %rbx, %rdi
callq 0x418a90
incl %r13d
jmp 0x402082
movq %rbx, %rdi
callq 0x414320
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9cf7b(%rip), %rdi     # 0x49f0cf
movq %r14, %rsi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40dd00
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: tapPush
void tapPush(char* iname, char* fname) {
	char buf[0x10000];
	int flen = readfile(fname, buf, 0xfffd);
	if (flen < 0) return;	
	FILE* file = fopen(iname, "ab");
	if (!file) {
		printf("Can't open '%s' for append\n", iname);
		return;
	}
	if (!opt.headLess) {
		tHead hd;
		memset(hd.name, 0x20, 10);
		xName nm = cutName(fname);
		memcpy(hd.name, nm.name, 10);
		hd.dll = flen & 0xff;
		hd.dlh = (flen >> 8) & 0xff;
		if (opt.isBasic) {
			hd.type = 0x00;
			hd.asl = opt.aStart & 0xff;
			hd.ash = (opt.aStart >> 8) & 0xff;
			hd.pll = hd.dll;
			hd.plh = hd.dlh;
		} else {
			hd.type = 0x03;
			hd.asl = 0;
			hd.ash = 0;
			hd.pll = 0;
			hd.plh = 0x80;
		}
		tapAddBlock(file, sizeof(tHead), (char*)&hd, 0x00);
	}
	tapAddBlock(file, flen, buf, 0xff);		// data
	fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10020, %rsp          # imm = 0x10020
movq %rsi, %r15
movq %rdi, %r12
leaq -0x10040(%rbp), %rsi
movq %r15, %rdi
movl $0xfffd, %edx           # imm = 0xFFFD
callq 0x401848
testl %eax, %eax
js 0x4021f4
movl %eax, %ebx
leaq 0x9cf6c(%rip), %rsi     # 0x49f111
movq %r12, %rdi
callq 0x414760
testq %rax, %rax
je 0x402204
movq %rax, %r14
testb $0x2, 0xd0214(%rip)     # 0x4d23d0
jne 0x402256
movq %r15, %rdi
callq 0x401af1
movq %rax, -0x30(%rbp)
movw %dx, -0x28(%rbp)
movb %bl, -0x26(%rbp)
movl %ebx, %eax
shrl $0x8, %eax
movb %al, -0x25(%rbp)
testb $0x1, 0xd01ec(%rip)     # 0x4d23d0
jne 0x402224
movb $-0x80, %al
movb $0x3, %sil
xorl %ecx, %ecx
xorl %edi, %edi
xorl %r8d, %r8d
jmp 0x402234
addq $0x10020, %rsp          # imm = 0x10020
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9cf09(%rip), %rdi     # 0x49f114
movq %r12, %rsi
xorl %eax, %eax
addq $0x10020, %rsp          # imm = 0x10020
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x40dd00
movl 0xd01aa(%rip), %ecx     # 0x4d23d4
movl %ecx, %edi
shrl $0x8, %edi
xorl %esi, %esi
movl %ebx, %r8d
leaq -0x31(%rbp), %rdx
movb %sil, (%rdx)
movb %cl, 0xd(%rdx)
movb %dil, 0xe(%rdx)
movb %r8b, 0xf(%rdx)
movb %al, 0x10(%rdx)
pushq $0x11
popq %rsi
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x401f87
leaq -0x10040(%rbp), %rdx
movq %r14, %rdi
movl %ebx, %esi
movl $0xff, %ecx
callq 0x401f87
movq %r14, %rdi
addq $0x10020, %rsp          # imm = 0x10020
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x414320
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: sclList
void sclList(char* path) {
	FILE* file = fopen(path, "rb");
	if (!file) {
		printf("Can't open image '%s'\n",path);
		return;
	}
	trdFile hd;
	printf("Name\t\tExt\tStart\tSize\tSLen\n---------------------------\n");
	fseek(file, 8, SEEK_SET);
	int cnt = fgetc(file);
	unsigned short start, len;
	while (cnt > 0) {
		fread((char*)&hd, 14, 1, file);
		start = hd.stl | (hd.sth << 8);
		len = hd.lnl | (hd.lnh << 8);
		printf("%.8s\t%c\t%i\t%i\t%i\n",hd.name, hd.ext, start, len, hd.slen);
		cnt--;
	}
	fclose (file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x9cd5c(%rip), %rsi     # 0x49f051
callq 0x414760
testq %rax, %rax
je 0x40238a
movq %rax, %rbx
leaq 0x9d1ab(%rip), %rdi     # 0x49f4b8
callq 0x414d80
pushq $0x8
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4189b0
movq %rbx, %rdi
callq 0x418a90
movl %eax, %r14d
leaq -0x38(%rbp), %r15
pushq $0x1
popq %r13
leaq 0x9cdf7(%rip), %r12     # 0x49f130
testl %r14d, %r14d
jle 0x402373
movq %r15, %rdi
pushq $0xe
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x414860
movzwl -0x2f(%rbp), %ecx
movzwl -0x2d(%rbp), %r8d
movsbl -0x30(%rbp), %edx
movzbl -0x2b(%rbp), %r9d
movq %r12, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x40dd00
decl %r14d
jmp 0x402339
movq %rbx, %rdi
callq 0x414320
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9cd3e(%rip), %rdi     # 0x49f0cf
movq %r14, %rsi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40dd00
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: sclSeekFile
int sclSeekFile(FILE* file, char* name, trdFile* hd) {
	fseek(file, 8, SEEK_SET);
	int cnt = fgetc(file);
	int find = 0;
	int pos = 9;
	while ((cnt > 0) && !find) {
		fread((char*)hd, 14, 1, file);
		if (memcmp((char*)hd, name, 9) == 0) {
			find = 1;
		} else {
			pos += 14;
			cnt--;
		}
	}
	return find ? pos : -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
pushq $0x8
popq %rsi
xorl %edx, %edx
callq 0x4189b0
movq %r15, %rdi
callq 0x418a90
movl %eax, %r12d
pushq $0x9
popq %r13
movb $0x1, %cl
testl %r12d, %r12d
jle 0x4028a6
testb $0x1, %cl
je 0x4028a6
movq %rbx, %rdi
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x414860
movq %rbx, %rdi
movq %r14, %rsi
pushq $0x9
popq %rdx
callq 0x401028
leal 0xe(%r13), %edx
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
cmovel %r13d, %edx
subl %ecx, %r12d
movl %edx, %r13d
jmp 0x402866
testb $0x1, %cl
pushq $-0x1
popq %rax
cmovnel %eax, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: sclRename
void sclRename(char* ipath, char* oname, char* nname) {
	FILE* file = fopen(ipath, "r+");
	if (!file) {
		printf("Can't open file '%s'\n",ipath);
		return;
	}
	char nbuf[9];
	makeName(oname, nbuf);
	trdFile hd;
	int pos = sclSeekFile(file, nbuf, &hd);
	if (pos < 0) {
		printf("File '%s' not found in image\n",oname);
	} else {
		int oldSum = getSum(nbuf, 9);
		makeName(nname, nbuf);
		int dif = getSum(nbuf, 9) - oldSum;	// diff to new CRC
		fseek(file, pos, SEEK_SET);		// read old CRC
		fwrite(nbuf, 9, 1, file);
		fseek(file, -4, SEEK_END);
		int crc = fgeti(file);
		crc += dif;				// change it
		fseek(file, -4, SEEK_END);		// write back
		fputi(file, crc);
	}
	fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
leaq 0x9c8ad(%rip), %rsi     # 0x49f190
callq 0x414760
testq %rax, %rax
je 0x4029a5
movq %rax, %rbx
leaq -0x31(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x401c84
leaq -0x41(%rbp), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x402834
testl %eax, %eax
js 0x4029c4
movl %eax, %r12d
leaq -0x31(%rbp), %r15
pushq $0x9
popq %rsi
movq %r15, %rdi
callq 0x401d11
movl %eax, %r13d
movq %r14, %rdi
movq %r15, %rsi
callq 0x401c84
movq %r15, %rdi
pushq $0x9
popq %rsi
callq 0x401d11
movl %eax, %r14d
subl %r13d, %r14d
movl %r12d, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4189b0
pushq $0x9
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x414ab0
pushq $-0x4
popq %r15
pushq $0x2
popq %r12
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x4189b0
movq %rbx, %rdi
callq 0x401bd3
addl %eax, %r14d
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x4189b0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x401c26
jmp 0x4029d5
leaq 0x9c6a8(%rip), %rdi     # 0x49f054
movq %r12, %rsi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40dd00
leaq 0x9c7a7(%rip), %rdi     # 0x49f172
movq %r15, %rsi
xorl %eax, %eax
callq 0x40dd00
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x414320
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trdCreate
void trdCreate(char* path) {
	char buf[0xa0000];
	memset(buf, 0x00, 0xa0000);
	buf[0x8e2] = 0x01;
	buf[0x8e3] = 0x16;
	buf[0x8e5] = 0xf0;
	buf[0x8e6] = 0x09;
	buf[0x8e7] = 0x10;
	FILE *file = fopen(path, "wb");
	if (!file) {
		printf("Can't write to file '%s'\n",path);
	} else {
		fwrite(buf, 0xa0000, 1, file);
		fclose(file);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xa0000, %rsp          # imm = 0xA0000
movq %rdi, %rbx
leaq -0xa0010(%rbp), %r14
movl $0xa0000, %edx          # imm = 0xA0000
movq %r14, %rdi
xorl %esi, %esi
callq 0x4010a8
movw $0x1601, 0x8e2(%r14)    # imm = 0x1601
movw $0x9f0, 0x8e5(%r14)     # imm = 0x9F0
movb $0x10, 0x8e7(%r14)
leaq 0x9c660(%rip), %rsi     # 0x49f095
movq %rbx, %rdi
callq 0x414760
testq %rax, %rax
je 0x402a6f
movq %rax, %r14
leaq -0xa0010(%rbp), %rdi
pushq $0x1
popq %rdx
movl $0xa0000, %esi          # imm = 0xA0000
movq %rax, %rcx
callq 0x414ab0
movq %r14, %rdi
addq $0xa0000, %rsp          # imm = 0xA0000
popq %rbx
popq %r14
popq %rbp
jmp 0x414320
leaq 0x9c71d(%rip), %rdi     # 0x49f193
movq %rbx, %rsi
xorl %eax, %eax
addq $0xa0000, %rsp          # imm = 0xA0000
popq %rbx
popq %r14
popq %rbp
jmp 0x40dd00
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trdList
void trdList(char* path) {
	FILE* file = fopen(path, "rb");
	if (!file) {
		printf("Can't open image '%s'\n", path);
		return;
	}
	printf("Name\t\tExt\tStart\tSize\tSLen\tSec\tTrk\n---------------------------\n");
	trdFile hd;
	int cnt = 0;
	int start,len;
	while (cnt < 128) {
		fread((char*)&hd, 16, 1, file);
		if (hd.name[0] == 0x00) break;
		if (hd.name[0] != 0x01) {
			start = hd.stl | (hd.sth << 8);
			len = hd.lnl | (hd.lnh << 8);
			printf("%.8s\t%c\t%i\t%i\t%i\t%i\t%i\n", hd.name, hd.ext, start, len, hd.slen, hd.sec, hd.trk);
		}
	}
	fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x9c5ab(%rip), %rsi     # 0x49f051
callq 0x414760
testq %rax, %rax
je 0x402b3c
movq %rax, %rbx
leaq 0x9ca48(%rip), %rdi     # 0x49f506
callq 0x414d80
leaq -0x38(%rbp), %r14
pushq $0x10
popq %r15
pushq $0x1
popq %r12
leaq 0x9c6d7(%rip), %r13     # 0x49f1ad
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x414860
movzbl -0x38(%rbp), %eax
cmpl $0x1, %eax
je 0x402ad6
testl %eax, %eax
je 0x402b25
movzwl -0x2f(%rbp), %ecx
movzwl -0x2d(%rbp), %r8d
movsbl -0x30(%rbp), %edx
movzbl -0x2b(%rbp), %r9d
movzbl -0x2a(%rbp), %r10d
movzbl -0x29(%rbp), %r11d
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x40dd00
popq %rcx
popq %rdx
jmp 0x402ad6
movq %rbx, %rdi
callq 0x414320
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9c58c(%rip), %rdi     # 0x49f0cf
movq %r14, %rsi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40dd00
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trd_put_data
void trd_put_data(char* img, char* buf, int trk, int sec, int len, int dt) {
	if ((dt == 0x18) || (dt == 0x19)) {
		sec = (trk << 5) | (sec & 0x0f);
		char* ptr = buf;
		while (len > 0) {
			memcpy(img + (sec << 8), ptr, 0x100);
			sec++;
			if ((sec & 0x0f) == 0)
				sec += 0x10;
			ptr += 0x100;
			len--;
		}
	} else {
		sec = (trk << 4) | (sec & 0x0f);
		memcpy(img + (sec << 8), buf, len << 8);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %r8d, %ebx
movl %ecx, %r12d
movq %rsi, %r14
movq %rdi, %r15
andl $-0x2, %r9d
cmpl $0x18, %r9d
jne 0x402bc6
shll $0x5, %edx
andl $0xf, %r12d
orl %edx, %r12d
testl %ebx, %ebx
jle 0x402bbd
movl %r12d, %eax
shll $0x8, %eax
movslq %eax, %rdi
addq %r15, %rdi
movl $0x100, %edx            # imm = 0x100
movq %r14, %rsi
callq 0x401048
leal 0x1(%r12), %eax
addl $0x11, %r12d
testb $0xf, %al
cmovnel %eax, %r12d
addq $0x100, %r14            # imm = 0x100
decl %ebx
jmp 0x402b86
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
shll $0xc, %edx
andl $0xf, %r12d
shll $0x8, %r12d
orl %edx, %r12d
movslq %r12d, %rax
addq %rax, %r15
shll $0x8, %ebx
movslq %ebx, %rdx
movq %r15, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x401048
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trdPush
void trdPush(char* ipath, char* fpath) {
	char buf[0x10000];
	trdFile hd = prepareFile(fpath, buf);
	if (hd.name[0] == 0) return;
	char img[0xa0000];
	memset(img, 0, 0xa0000);
	if (readfile(ipath, img, 0xa0000) < 0) {
		printf("Can't read image '%s'\n", ipath);
		return;
	}
	int files = img[0x8e4];			// test files count
	if (files > 127) {
		printf("Too many files in image\n");
		return;
	}
	int freesec = (img[0x8e5] & 0xff) | ((img[0x8e6] & 0xff) << 8);
	
	if (freesec < hd.slen) {		// test free sectors
		printf("No room for file\n");
		return;
	}
	int lastsec = img[0x8e1] & 0xff;
	int lasttrk = img[0x8e2] & 0xff;
	hd.sec = lastsec;
	hd.trk = lasttrk;
	files++;
	img[0x8e4] = files;
	freesec -= hd.slen;
	img[0x8e5] = freesec & 0xff;
	img[0x8e6] = ((freesec & 0xff00) >> 8);
	int diskType = img[0x8e3] & 0xff;
	char* ptr = img;
	while (*ptr)				// find 1st free descriptor
		ptr += 16;
	memcpy(ptr, (char*)&hd, 16);		// make new descriptor
	int secnum = ((hd.trk << 4) + hd.sec);	// free sector num
	// int fpos = (secnum << 8); 		// position in image
	secnum += hd.slen;
	img[0x8e1] = secnum & 0x0f;
	img[0x8e2] = ((secnum & 0xfff0) >> 4);
	trd_put_data(img, buf, hd.trk, hd.sec, hd.slen, diskType);
	// memcpy(img + fpos, buf, hd.slen << 8);	// copy file data
	savefile(ipath, img, 0xa0000);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb0000, %rsp          # imm = 0xB0000
movq %rsi, %rax
movq %rdi, %rbx
leaq -0x10020(%rbp), %rsi
movq %rax, %rdi
callq 0x401dc2
movq %rax, %r14
testb %r14b, %r14b
je 0x402d33
movq %rdx, %r15
leaq -0xb0020(%rbp), %r12
movl $0xa0000, %edx          # imm = 0xA0000
movq %r12, %rdi
xorl %esi, %esi
callq 0x4010a8
movq %rbx, %rdi
movq %r12, %rsi
movl $0xa0000, %edx          # imm = 0xA0000
callq 0x401848
testl %eax, %eax
js 0x402c7b
movzwl -0xaf73b(%rbp), %eax
movq %r15, %rcx
shrq $0x28, %rcx
movzbl %cl, %r8d
subl %r8d, %eax
jae 0x402c91
leaq 0x9c8d3(%rip), %rdi     # 0x49f544
callq 0x414d80
jmp 0x402d33
leaq 0x9c543(%rip), %rdi     # 0x49f1c5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x40dd00
jmp 0x402d33
movzbl -0xaf73f(%rbp), %ecx
movzbl -0xaf73e(%rbp), %edx
movq %rcx, %rsi
shlq $0x30, %rsi
movabsq $0xffffffffffff, %rdi   # imm = 0xFFFFFFFFFFFF
andq %rdi, %r15
incb -0xaf73c(%rbp)
orq %rsi, %r15
movb %al, -0xaf73b(%rbp)
movb %ah, -0xaf73a(%rbp)
movzbl -0xaf73d(%rbp), %r9d
cmpb $0x0, (%r12)
leaq 0x10(%r12), %r12
jne 0x402cd0
movq %rdx, %rax
shlq $0x38, %rax
orq %rax, %r15
movq %r14, -0x10(%r12)
movq %r15, -0x8(%r12)
leal (%r8,%rcx), %eax
movl %eax, %esi
andb $0xf, %sil
leaq -0xb0020(%rbp), %r14
movb %sil, 0x8e1(%r14)
shrl $0x4, %eax
addb %dl, %al
movb %al, 0x8e2(%r14)
leaq -0x10020(%rbp), %rsi
movq %r14, %rdi
callq 0x402b5b
movq %rbx, %rdi
movq %r14, %rsi
movl $0xa0000, %edx          # imm = 0xA0000
callq 0x4018f4
addq $0xb0000, %rsp          # imm = 0xB0000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trdSeekFile
int trdSeekFile(FILE* file, char* name, trdFile* hd) {
	int find = 0;
	int cnt = 0;
	rewind(file);
	while ((cnt < 128) && !find) {
		fread((char*)hd, 16, 1, file);
		if (hd->name[0] == 0x00) break;
		if (memcmp((char*)hd, name, 9) == 0) {
			find = 1;
		}
		cnt++;
	}
	return find ? (cnt - 1) << 4 : -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
callq 0x418bb0
xorl %ecx, %ecx
pushq $-0x10
popq %rbx
xorl %r13d, %r13d
cmpl $0x7f, %r13d
ja 0x402da5
testl %ecx, %ecx
jne 0x402da5
movq %r14, %rdi
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x414860
cmpb $0x0, (%r14)
je 0x402da9
movq %r14, %rdi
movq %r15, %rsi
pushq $0x9
popq %rdx
callq 0x401028
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
incl %r13d
addl $0x10, %ebx
jmp 0x402d67
testl %ecx, %ecx
jne 0x402dac
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trd_get_data
void trd_get_data(FILE* file, char* buf, int trk, int sec, int len, int dt) {
	if ((dt == 0x18) || (dt == 0x19)) {
		fseek(file, ((trk << 5) | (sec & 0x0f)) << 8, SEEK_SET);
		char* ptr = buf;
		while (len > 0) {
			fread(ptr, 0x100, 1, file);		// read 1 sec
			if ((ftell(file) & 0xfff) == 0) {	// if eot
				fseek(file, 0x1000, SEEK_CUR);	// skip 4Kb
			}
			ptr += 0x100;
			len--;
		}
	} else {
		fseek(file, ((trk << 4) | (sec & 0x0f)) << 8, SEEK_SET);
		fread(buf, len << 8, 1, file);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r14d
movq %rsi, %r15
movq %rdi, %rbx
andl $-0x2, %r9d
andl $0xf, %ecx
shll $0x8, %ecx
cmpl $0x18, %r9d
jne 0x402e4f
shll $0xd, %edx
orl %edx, %ecx
movslq %ecx, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4189b0
pushq $0x1
popq %r12
pushq $0x1
popq %r13
testl %r14d, %r14d
jle 0x402e40
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x414860
movq %rbx, %rdi
callq 0x414960
shlq $0x34, %rax
jne 0x402e34
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
movl %r13d, %edx
callq 0x4189b0
addq $0x100, %r15            # imm = 0x100
decl %r14d
jmp 0x402dfe
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shll $0xc, %edx
orl %edx, %ecx
movslq %ecx, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4189b0
shll $0x8, %r14d
movslq %r14d, %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x414860
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trdPop
void trdPop(char* ipath, char* fname, char* oname) {
	FILE* file = fopen(ipath, "rb");
	if (!file) {
		printf("Can't open image '%s'\n",ipath);
		return;
	}
	char nbuf[9];
	char xbuf[256];
	char buf[0x10000];
	int num = 0;
	makeName(fname, nbuf);
	trdFile hd;
	fseek(file, 0x8e3, SEEK_SET);
	int diskType = fgetc(file) & 0xff;	// 0x16:80ds, 17:40ds, 18:80ss, 19:40ss
	if (fname == NULL) {
		do {
			fseek(file, num << 4, SEEK_SET);
			fread(&hd, 16, 1, file);
			if (hd.name[0] > 31) {
				trd_get_data(file, buf, hd.trk, hd.sec, hd.slen, diskType);
				sprintf(xbuf,"%.3i_%.8s.%c",num,hd.name,hd.ext);
				// printf("%s\n",xbuf);
				saveoutput(xbuf, buf, hd);
			}
			num++;
		} while ((num < 128) && (hd.name[0] != 0x00));
	} else if (trdSeekFile(file, nbuf, &hd) < 0) {
		printf("Can't find file '%s' in image\n",fname);
	} else {
		trd_get_data(file, buf, hd.trk, hd.sec, hd.slen, diskType);
		saveoutput(oname, buf, hd);
	}
	fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10128, %rsp          # imm = 0x10128
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
leaq 0x9c1a9(%rip), %rsi     # 0x49f051
callq 0x414760
testq %rax, %rax
je 0x402f3a
movq %rax, %rbx
leaq -0x45(%rbp), %rsi
movq %r15, %rdi
callq 0x401c84
movl $0x8e3, %esi            # imm = 0x8E3
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4189b0
movq %rbx, %rdi
callq 0x418a90
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
testq %r15, %r15
je 0x402f5c
leaq -0x45(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movq %rbx, %rdi
callq 0x402d43
testl %eax, %eax
js 0x402ffc
movzbl -0x29(%rbp), %edx
movzbl -0x2a(%rbp), %ecx
movzbl -0x2b(%rbp), %r8d
leaq -0x10150(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl -0x3c(%rbp), %r9d
callq 0x402dbd
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq %r14, %rdi
movq %r15, %rsi
callq 0x401e9f
jmp 0x40300d
leaq 0x9c18e(%rip), %rdi     # 0x49f0cf
movq %r12, %rsi
xorl %eax, %eax
addq $0x10128, %rsp          # imm = 0x10128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40dd00
xorl %r13d, %r13d
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x4189b0
leaq -0x38(%rbp), %rdi
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x414860
movb -0x38(%rbp), %al
cmpb $0x20, %al
jl 0x402fe5
movzbl -0x29(%rbp), %edx
movzbl -0x2a(%rbp), %ecx
movzbl -0x2b(%rbp), %r8d
movq %rbx, %rdi
leaq -0x10150(%rbp), %r12
movq %r12, %rsi
movl -0x3c(%rbp), %r9d
callq 0x402dbd
movsbl -0x30(%rbp), %r8d
leaq -0x150(%rbp), %r15
movq %r15, %rdi
leaq 0x9c1a4(%rip), %rsi     # 0x49f165
movl %r14d, %edx
leaq -0x38(%rbp), %rcx
xorl %eax, %eax
callq 0x40ddd0
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq %r15, %rdi
movq %r12, %rsi
callq 0x401e9f
movb -0x38(%rbp), %al
cmpq $0x7e, %r14
ja 0x40300d
incq %r14
addq $0x10, %r13
testb %al, %al
jne 0x402f62
jmp 0x40300d
leaq 0x9c1d9(%rip), %rdi     # 0x49f1dc
movq %r15, %rsi
xorl %eax, %eax
callq 0x40dd00
movq %rbx, %rdi
callq 0x414320
addq $0x10128, %rsp          # imm = 0x10128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: trdRename
void trdRename(char* ipath, char* oname, char* nname) {
	FILE* file = fopen(ipath, "r+");
	if (!file) {
		printf("Can't open image '%s'\n",ipath);
		return;
	}
	char nbuf[9];
	makeName(oname, nbuf);
	trdFile hd;
	int pos = trdSeekFile(file, nbuf, &hd);
	if (pos < 0) {
		printf("Can't find file '%s' in image\n",oname);
	} else {
		makeName(nname, nbuf);
		fseek(file, pos, SEEK_SET);
		fwrite(nbuf, 9, 1, file);
	}
	fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
leaq 0x9c14a(%rip), %rsi     # 0x49f190
callq 0x414760
testq %rax, %rax
je 0x4030a7
movq %rax, %rbx
leaq -0x29(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x401c84
leaq -0x39(%rbp), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x402d43
testl %eax, %eax
js 0x4030c4
movl %eax, %r12d
leaq -0x29(%rbp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x401c84
movl %r12d, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4189b0
pushq $0x9
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x414ab0
jmp 0x4030d5
leaq 0x9c021(%rip), %rdi     # 0x49f0cf
movq %r12, %rsi
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x40dd00
leaq 0x9c111(%rip), %rdi     # 0x49f1dc
movq %r14, %rsi
xorl %eax, %eax
callq 0x40dd00
movq %rbx, %rdi
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x414320
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: create
void create(char* path) {
	if (testExt(path, "tap")) {
		tapCreate(path);
	} else if (testExt(path, "scl")) {
		sclCreate(path);
	} else if (testExt(path, "trd")) {
		trdCreate(path);
	} else {
		printf("Unknown type, use TAP SCL TRD please\n");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x9bfc1(%rip), %rsi     # 0x49f0ba
callq 0x401968
testl %eax, %eax
je 0x403110
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x402026
leaq 0x9bfa7(%rip), %rsi     # 0x49f0be
movq %rbx, %rdi
callq 0x401968
testl %eax, %eax
je 0x403131
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4022a5
leaq 0x9bf93(%rip), %rsi     # 0x49f0cb
movq %rbx, %rdi
callq 0x401968
testl %eax, %eax
je 0x403152
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4029eb
leaq 0x9c3fc(%rip), %rdi     # 0x49f555
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x414d80
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: list
void list(char* path) {
	int mode = getFileType(path);
	switch (mode) {
		case TYPE_TAP:
			tapList(path);
			break;
		case TYPE_SCL:
			sclList(path);
			break;
		case TYPE_TRD:
			trdList(path);
			break;
		default:
			printf("Unknown image type\n");
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x4019e4
movl %eax, %eax
leaq 0x9be89(%rip), %rcx     # 0x49f004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x9c3ef(%rip), %rdi     # 0x49f57a
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x414d80
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x402a8b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x402034
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4022da
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: push
void push(char* ipath, char* fpath) {
	int type = getFileType(ipath);
	switch(type) {
		case TYPE_TAP:
			tapPush(ipath, fpath);
			break;
		case TYPE_SCL:
			sclPush(ipath, fpath);
			break;
		case TYPE_TRD:
			trdPush(ipath, fpath);
			break;
		default:
			printf("Unknown image type\n");
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x4019e4
movl %eax, %eax
leaq 0x9be39(%rip), %rcx     # 0x49f014
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x9c38f(%rip), %rdi     # 0x49f57a
popq %rbx
popq %r14
popq %rbp
jmp 0x414d80
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x402bf3
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x40216c
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x4023a9
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: pop
void pop(char* ipath, char* fname, char* oname) {
	if (!oname) {
		if (opt.asHobeta) {
			char fpath[1024];
			memset(fpath, 0, 1024);
			char* pDot = strrchr(fname,'.');
			if (pDot) {
				memcpy(fpath, fname, pDot - fname + 1);
				strcat(fpath,"$");
				strcat(fpath,pDot + 1);
				oname = fpath;
			} else {
				oname = fname;
			}
		} else {
			oname = fname;
		}
	}
	int type = getFileType(ipath);
	switch(type) {
		case TYPE_TAP:
			tapPop(ipath, fname, oname);
			break;
		case TYPE_SCL:
			sclPop(ipath, fname, oname);
			break;
		case TYPE_TRD:
			trdPop(ipath, fname, oname);
			break;
		default:
			printf("Unknown image type\n");
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
testq %rdx, %rdx
jne 0x4032b2
testb $0x4, 0xcf186(%rip)     # 0x4d23d0
movq %rbx, %r12
je 0x4032b2
leaq -0x430(%rbp), %r15
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x4010a8
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0x401058
movq %rbx, %r12
testq %rax, %rax
je 0x4032b2
movq %rax, %r13
movq %rax, %rdx
subq %rbx, %rdx
incq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x401048
movq %r15, %rdi
callq 0x4010e0
movw $0x24, -0x430(%rbp,%rax)
incq %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x401060
movq %r15, %r12
movq %r14, %rdi
callq 0x4019e4
movl %eax, %eax
leaq 0x9bd61(%rip), %rcx     # 0x49f024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x9c2a7(%rip), %rdi     # 0x49f57a
jmp 0x4032ec
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x402e84
jmp 0x403301
leaq 0x9c1ba(%rip), %rdi     # 0x49f4a6
callq 0x414d80
jmp 0x403301
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4025f9
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: renam
void renam(char* ipath, char* oname, char* nname) {
	int type = getFileType(ipath);
	switch(type) {
		case TYPE_TAP:
			tapRename(ipath, oname, nname);
			break;
		case TYPE_SCL:
			sclRename(ipath, oname, nname);
			break;
		case TYPE_TRD:
			trdRename(ipath, oname, nname);
			break;
		default:
			printf("Unknown image type\n");
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x4019e4
movl %eax, %eax
leaq 0x9bd00(%rip), %rcx     # 0x49f034
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x9c236(%rip), %rdi     # 0x49f57a
jmp 0x403365
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x403027
leaq 0x9c141(%rip), %rdi     # 0x49f4a6
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x414d80
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4028c2
// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/mktrd/mctrd.c
// Function: help
void help() {
	printf("::: Usage :::\n");
	printf("mctrd [-h][-z][-b][-n][-a num] command name1 [name2] [name3]\n");
	printf("::: Keys :::\n");
	printf("%*s %s\n",-32,"-a | --autostart NUM","set autostart line number for basic file");
	printf("%*s %s\n",-32,"-b | --basic","add file to archive as basic");
	printf("%*s %s\n",-32,"-h | --help","show this page");
	printf("%*s %s\n",-32,"-n | --no-head","push file to TAP without header");
	printf("%*s %s\n",-32,"-z | --hobeta","pop/push file as hobeta (SCL, TRD only)");
	printf("::: Commands :::\n");
	printf("%*s %s\n",-32,"list <image>","show image catalog");
	printf("%*s %s\n",-32,"new <image>","create new image (TAP, TRD, SCL: depends on extension)");
	printf("%*s %s\n",-32,"add <file> <image>","put file into image");
	printf("%*s %s\n",-32,"pop <file> <image> [<outname>]","extract file from image (scl,trd)");
	printf("%*s %s\n",-32,"pop <image>","extract all files from image (scl,trd)");
	printf("%*s %s\n",-32,"rename <image> <oname> <nname>","rename file inside image. oname = old name, nname = new name");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0x9c1f3(%rip), %rdi     # 0x49f58d
callq 0x414d80
leaq 0x9c1f5(%rip), %rdi     # 0x49f59b
callq 0x414d80
leaq 0x9c226(%rip), %rdi     # 0x49f5d8
callq 0x414d80
leaq 0x9be3d(%rip), %rbx     # 0x49f1fb
leaq 0x9be3e(%rip), %rdx     # 0x49f203
leaq 0x9be4c(%rip), %rcx     # 0x49f218
pushq $-0x20
popq %r14
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9be5d(%rip), %rdx     # 0x49f241
leaq 0x9be63(%rip), %rcx     # 0x49f24e
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9be6c(%rip), %rdx     # 0x49f26b
leaq 0x9be71(%rip), %rcx     # 0x49f277
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9be6c(%rip), %rdx     # 0x49f286
leaq 0x9be74(%rip), %rcx     # 0x49f295
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9be80(%rip), %rdx     # 0x49f2b5
leaq 0x9be87(%rip), %rcx     # 0x49f2c3
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9c195(%rip), %rdi     # 0x49f5e5
callq 0x414d80
leaq 0x9be8f(%rip), %rdx     # 0x49f2eb
leaq 0x9be95(%rip), %rcx     # 0x49f2f8
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9be94(%rip), %rdx     # 0x49f30b
leaq 0x9be99(%rip), %rcx     # 0x49f317
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9bebc(%rip), %rdx     # 0x49f34e
leaq 0x9bec8(%rip), %rcx     # 0x49f361
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9bec8(%rip), %rdx     # 0x49f375
leaq 0x9bee0(%rip), %rcx     # 0x49f394
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9beee(%rip), %rdx     # 0x49f3b6
leaq 0x9bef3(%rip), %rcx     # 0x49f3c2
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x40dd00
leaq 0x9bf06(%rip), %rdx     # 0x49f3e9
leaq 0x9bf1e(%rip), %rcx     # 0x49f408
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x40dd00
// File: /workspace/github_c_makefile_star2_O2/canboat[P]canboat/group-function/command.c
// Function: usage
void usage(char **argv, char **av)
{
  if (av)
  {
    fprintf(stderr, "Unknown or invalid argument %s\n", av[0]);
  }
  fprintf(stderr, "Usage: %s <dest> <prio> <pgn> <field>=<value> ... | -version\n\n", argv[0]);
  fprintf(stderr, "       <field> is a decimal value\n");
  fprintf(stderr, "       <value> is a hexadecimal value; the length of the value defines how many bytes are encoded\n");
  fprintf(stderr, "       Maximum # of fields: %d\n\n", MAX_FIELDS);
  fprintf(stderr, "This program uses PGN 126208 to command a device to set fields to a particular value.\n");
  fprintf(stderr, "The use of this is thus completely dependent on what the device allows.\n\n" COPYRIGHT);
  exit(1);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testq %rsi, %rsi
je 0x13d3
movq 0x4c39(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
movq (%rsi), %rdx
leaq 0x1c38(%rip), %rsi      # 0x3004
xorl %eax, %eax
callq 0x1150
movq 0x4c1e(%rip), %r14      # 0x5ff8
movq (%r14), %rdi
movq (%rbx), %rdx
leaq 0x1c3d(%rip), %rsi      # 0x3024
xorl %eax, %eax
callq 0x1150
movq (%r14), %rcx
leaq 0x1c6b(%rip), %rdi      # 0x3063
pushq $0x22
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x1230
movq (%r14), %rcx
leaq 0x1c76(%rip), %rdi      # 0x3086
pushq $0x62
popq %rsi
movq %rbx, %rdx
callq 0x1230
movq (%r14), %rdi
leaq 0x1cc4(%rip), %rsi      # 0x30e9
pushq $0x14
popq %rdx
xorl %eax, %eax
callq 0x1150
movq (%r14), %rcx
leaq 0x1cd1(%rip), %rdi      # 0x310a
pushq $0x56
popq %rsi
movq %rbx, %rdx
callq 0x1230
movq (%r14), %rcx
leaq 0x1d13(%rip), %rdi      # 0x3161
movl $0x304, %esi            # imm = 0x304
movq %rbx, %rdx
callq 0x1230
pushq $0x1
popq %rdi
callq 0x1210
// File: /workspace/github_c_makefile_star2_O2/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_5/exercise_5_11/entab.c
// Function: main
int main(int argc, char *argv[])
{
  if (!is_tab_stop_arg_list_valid(argc, argv))
  {
    puts("Error: invalid tab stop list.\n");
    return EXIT_FAILURE;
  }

  int c;
  size_t arg_pos = 1;
  size_t line_pos = 0;
  size_t tab_stop = DEFAULT_TAB_LENGTH;
  size_t nr_of_spaces = 0;
  size_t nr_of_custom_tab_stops = argc - 1;

  while ((c = getchar()) != EOF)
  {
    ++line_pos;

    if (c == ' ')
    {
      ++nr_of_spaces;

      if (nr_of_custom_tab_stops)
      {
        tab_stop = atoi(argv[arg_pos]);
      }
      else if (argc > 1)
      {
        tab_stop = 1;
      }

      if (line_pos % tab_stop == 0 && nr_of_spaces > 1)
      {
        putchar('\t');

        if (nr_of_custom_tab_stops)
        {
          ++arg_pos;
          --nr_of_custom_tab_stops;
        }

        nr_of_spaces = 0;
      }
    }
    else
    {
      while (nr_of_spaces)
      {
        putchar(' ');
        --nr_of_spaces;
      }

      if (c == '\n')
      {
        arg_pos = 1;
        line_pos = 0;
        nr_of_custom_tab_stops = argc - 1;
      }

      putchar(c);
    }
  }

  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, %ebx
movq %rsi, 0x20(%rsp)
callq 0x12c0
testl %eax, %eax
je 0x12a2
movq %rbx, 0x18(%rsp)
leal -0x1(%rbx), %eax
movslq %eax, %r15
pushq $0x8
popq %r14
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
xorl %r12d, %r12d
movq %r15, 0x10(%rsp)
xorl %ebx, %ebx
xorl %ebp, %ebp
callq 0x1060
cmpl $-0x1, %eax
je 0x129e
movl %eax, %r13d
incq %r12
cmpl $0x20, %eax
jne 0x1259
testq %r15, %r15
je 0x1207
movq 0x20(%rsp), %rax
movq 0x8(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1070
movslq %eax, %r14
jmp 0x1213
cmpl $0x2, 0x18(%rsp)
pushq $0x1
popq %rax
cmovgeq %rax, %r14
incq %rbp
movq %r12, %rax
xorl %edx, %edx
divq %r14
testq %rdx, %rdx
sete %al
cmpq $0x2, %rbp
setae %cl
andb %al, %cl
decq %rbx
cmpb $0x1, %cl
jne 0x11d1
cmpq $0x1, %r15
sbbq $-0x1, 0x8(%rsp)
subq $0x1, %r15
movl $0x0, %eax
cmovbq %rax, %r15
pushq $0x9
popq %rdi
callq 0x1030
jmp 0x11cd
pushq $0x20
popq %rbp
testq %rbx, %rbx
je 0x126d
movl %ebp, %edi
callq 0x1030
incq %rbx
jmp 0x125c
cmpl $0xa, %r13d
pushq $0x1
popq %rax
movq 0x8(%rsp), %rcx
cmoveq %rax, %rcx
movq %rcx, 0x8(%rsp)
movl $0x0, %eax
cmoveq %rax, %r12
cmoveq 0x10(%rsp), %r15
movl %r13d, %edi
callq 0x1030
jmp 0x11cd
xorl %eax, %eax
jmp 0x12b1
leaq 0xd5b(%rip), %rdi       # 0x2004
callq 0x1040
pushq $0x1
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Aethlas[P]fflz4/fflz4.c
// Function: main
int main(int argc, char **argv)
{
    if (argc < 2) FAILED(1, "");

    char *profile = NULL, *bookmark = NULL;
    unsigned int flag = 0x0;
    int c = 0;

    while ((c = getopt(argc, argv, "p:utcbsd")) != -1) {
        switch (c) {
            case 'p': /* profile path */
                flag |= FLAG_P;
                profile = strdup(optarg);
                break;
            case 'u': /* url */
                flag |= FLAG_U;
                break;
            case 't': /* title */
                flag |= FLAG_T;
                break;
            case 'c': /* current session */
                flag |= FLAG_C;
                break;
            case 'b': /* bookmark */
                flag |= FLAG_B;
                break;
            case 's': /* session json */
                flag |= FLAG_S;
                break;
            case 'd': /* bookmark json */
                flag |= FLAG_D;
                break;
            case '?':
                if (optopt == 'p')
                    FAILED(1, "");
                break;
            default:
                break;
        }
    }

    if (!profile)
        profile = get_firefox_profile();

    if (flag & (FLAG_U | FLAG_T | FLAG_C | FLAG_S))
        get_tabs(profile, flag);

    if (flag & (FLAG_B | FLAG_D)) {
        bookmark = get_bookmark_file(profile);
        get_bookmarks(bookmark, flag);
        free(bookmark);
    }

    free(profile);
    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x2, %edi
jl 0x143f
movq %rsi, %r14
movl %edi, %r15d
xorl %ebx, %ebx
leaq 0xdcbd(%rip), %r12      # 0xf01c
leaq 0xdc9e(%rip), %r13      # 0xf004
xorl %ebp, %ebp
movl %r15d, %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x11c0
leal -0x70(%rax), %ecx
cmpl $0x5, %ecx
jbe 0x1399
cmpl $0x3f, %eax
je 0x13c9
cmpl $0x62, %eax
je 0x13dc
cmpl $0x63, %eax
je 0x13d7
cmpl $0x64, %eax
je 0x13e1
cmpl $-0x1, %eax
jne 0x1368
jmp 0x13e6
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
orl $0x1, %ebp
movq 0x11c13(%rip), %rax     # 0x12fc0
movq (%rax), %rdi
callq 0x1200
movq %rax, %rbx
jmp 0x1368
orl $0x4, %ebp
jmp 0x1368
orl $0x2, %ebp
jmp 0x1368
orl $0x20, %ebp
jmp 0x1368
movq 0x11c00(%rip), %rax     # 0x12fd0
cmpl $0x70, (%rax)
jne 0x1368
jmp 0x143f
orl $0x8, %ebp
jmp 0x1368
orl $0x10, %ebp
jmp 0x1368
orl $0x40, %ebp
jmp 0x1368
testq %rbx, %rbx
jne 0x13f3
callq 0x14ae
movq %rax, %rbx
testb $0x2e, %bpl
je 0x1403
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1628
testb $0x50, %bpl
je 0x1426
movq %rbx, %rdi
callq 0x173c
movq %rax, %r14
movq %rax, %rdi
movl %ebp, %esi
callq 0x18be
movq %r14, %rdi
callq 0x1230
movq %rbx, %rdi
callq 0x1230
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x144c
pushq $0x1
popq %rdi
callq 0x11e0
// File: /workspace/github_c_makefile_star2_O2/Aethlas[P]fflz4/fflz4.c
// Function: usage
static void usage(void)
{
    printf("Usage fflz4:\n");
    printf("-u\tSession urls\n");
    printf("-t\tSession titles\n");
    printf("-c\tActive title & url. Can be limited with -u or -t\n");
    printf("-b\tBookmarks title & url saved in toolbar. Can be limited with -u or -t\n");
    printf("-s\tRaw session json\n");
    printf("-d\tRaw bookmarks json\n");
    printf("-p\t(Optional) Provide path to firefox profile. Default: /home/<user>/.mozilla/firefox/<xxxxxx.default>/\n");
}

// Assembly:
pushq %rax
leaq 0xddd5(%rip), %rdi      # 0xf229
callq 0x1050
leaq 0xddd6(%rip), %rdi      # 0xf236
callq 0x1050
leaq 0xddda(%rip), %rdi      # 0xf246
callq 0x1050
leaq 0xdde0(%rip), %rdi      # 0xf258
callq 0x1050
leaq 0xde08(%rip), %rdi      # 0xf28c
callq 0x1050
leaq 0xde44(%rip), %rdi      # 0xf2d4
callq 0x1050
leaq 0xde4c(%rip), %rdi      # 0xf2e8
callq 0x1050
leaq 0xde56(%rip), %rdi      # 0xf2fe
popq %rax
jmp 0x1050
// File: /workspace/github_c_makefile_star2_O2/Aethlas[P]fflz4/fflz4.c
// Function: get_firefox_profile
char *get_firefox_profile(void)
{
    char *home = NULL, *source = NULL, *result_path = NULL;
    char path[4096] = {0}, profile[256] = {0};
    size_t SIZE = 0;
    int len = 0;

    home = getenv("HOME");
    if (!home) FAILED(0, "Get $HOME failed\n");

    sprintf(path, "%s/.mozilla/firefox/profiles.ini", home);
    source = get_file_content(path, "r", 0, &SIZE);

    /* get firefox profile */
    for (const char *tok = strtok(source, "\n"); tok && *tok; tok = strtok(NULL, "\n")) {
        if (strstr(tok, "Path")) {
            char *r = strstr(tok, "=");
            size_t pos = r-tok+1, len = strlen(tok);
            size_t j = 0;
            for (size_t i = pos; i < len; ++i) {
                profile[j++] = tok[i];
            }
            profile[j] = '\0';
            break;
        }
    }

    if (strlen(profile))
        len = asprintf(&result_path, "%s/.mozilla/firefox/%s/", home, profile);

    if (!len) FAILED(0, "Get profile path failed\n");

    free(source);
    return result_path;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1118, %rsp           # imm = 0x1118
andq $0x0, (%rsp)
leaq 0x110(%rsp), %rdi
movl $0x1000, %edx           # imm = 0x1000
xorl %esi, %esi
callq 0x10c0
leaq 0x10(%rsp), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x10c0
leaq 0xdb80(%rip), %rdi      # 0xf073
callq 0x1030
testq %rax, %rax
je 0x1613
movq %rax, %rbx
leaq 0xdb7f(%rip), %rsi      # 0xf08a
leaq 0x110(%rsp), %r15
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x11d0
leaq 0xdca5(%rip), %rsi      # 0xf1cc
leaq 0x8(%rsp), %rcx
movq %r15, %rdi
xorl %edx, %edx
callq 0x1ae4
movq %rax, %r15
leaq 0xdc69(%rip), %r13      # 0xf1a9
leaq 0xdb64(%rip), %rbp      # 0xf0ab
movq %rax, %rdi
movq %r13, %rsi
callq 0x11b0
testq %rax, %rax
je 0x15ef
movq %rax, %r12
cmpb $0x0, (%rax)
je 0x15ef
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1210
movl $0x0, %edi
testq %rax, %rax
je 0x154a
pushq $0x3d
popq %rsi
movq %r12, %rdi
callq 0x10b0
movq %rax, %r13
movq %r12, %rdi
callq 0x10a0
subq %r12, %r13
incq %r13
cmpq %rax, %r13
jae 0x15a9
movb (%r12,%r13), %cl
movb %cl, (%r14)
incq %r14
jmp 0x1595
movb $0x0, (%r14)
cmpb $0x0, 0x10(%rsp)
je 0x15ef
leaq 0xdaf5(%rip), %rsi      # 0xf0b0
movq %rsp, %rdi
leaq 0x10(%rsp), %rcx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1180
testl %eax, %eax
je 0x15ef
movq %r15, %rdi
callq 0x1230
movq (%rsp), %rax
addq $0x1118, %rsp           # imm = 0x1118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11a02(%rip), %rax     # 0x12ff8
movq (%rax), %rcx
leaq 0xdac8(%rip), %rdi      # 0xf0c8
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x11f0
pushq $0x1
popq %rdi
callq 0x11e0
movq 0x119de(%rip), %rax     # 0x12ff8
movq (%rax), %rcx
leaq 0xda54(%rip), %rdi      # 0xf078
pushq $0x11
jmp 0x1602