// File: /workspace/github_c_makefile_star2_O1/salextpuru[P]speccy-toochain/src/mktrd/mktrd.cpp
// Function: list(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void list(const string fname) {
	unsigned char *buf = new unsigned char[0xa0000];
	int len=readfile(fname,buf);
	if (len<1) {cout<<"Can't read file"<<endl; return;}
	int mode=testsig(buf,len);
	unsigned char* ptr = buf;
	unsigned char i=0;
	switch (mode) {
		case 1:
			ptr+=9;
			printf("Name\t\tExt\tStart\tSize\tSLen\n---------------------------\n");
			for(;i<*(buf+8);i++) {
				printf("%.8s\t%.1s\t%i\t%i\t%i\n",ptr,ptr+8,*(ptr+9)+(*(ptr+10)<<8),*(ptr+11)+(*(ptr+12)<<8),*(ptr+13));
				ptr+=14;
			}
			break;
		case 2:
			printf("Name\t\tExt\tStart\tSize\tSLen\tTrk\tSec\n---------------------------\n");
			while (*ptr!=0 && i<128) {
				if (*ptr!=1) printf("%.8s\t%.1s\t%i\t%i\t%i\t%i\t%i\n",ptr,ptr+8,*(ptr+9)+(*(ptr+10)<<8),*(ptr+11)+(*(ptr+12)<<8),*(ptr+13),*(ptr+14),*(ptr+15));
				ptr+=16; i++;
			}
			break;
		default: cout<<"Unknown image format"<<endl; break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
movl $0xa0000, %edi          # imm = 0xA0000
callq 0x407170
movq %rax, %rbx
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x4062f4
movq %r15, %rdi
movq %rbx, %rsi
movl $0xa0000, %edx          # imm = 0xA0000
callq 0x4045d8
movl %eax, %r14d
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x40575f
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x406430
testl %r14d, %r14d
jle 0x40578d
movabsq $0x5249414c434e4953, %rax # imm = 0x5249414C434E4953
cmpq %rax, (%rbx)
je 0x4057a5
cmpl $0xa0000, %r14d         # imm = 0xA0000
sete %cl
cmpb $0x10, 0x8e7(%rbx)
sete %al
andb %cl, %al
addb %al, %al
jmp 0x4057a7
movq $0x5ec460, %rdi         # imm = 0x5EC460
leaq 0x17888f(%rip), %rsi    # 0x57e02a
movl $0xf, %edx
jmp 0x405895
movb $0x1, %al
cmpb $0x2, %al
je 0x405810
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x405882
leaq 0x178b54(%rip), %rdi    # 0x57e312
callq 0x4d5030
cmpb $0x0, 0x8(%rbx)
je 0x4058c8
movq %rbx, %r14
addq $0x11, %r14
xorl %r12d, %r12d
leaq 0x178982(%rip), %r15    # 0x57e160
leaq -0x8(%r14), %rsi
movzwl 0x1(%r14), %ecx
movzwl 0x3(%r14), %r8d
movzbl 0x5(%r14), %r9d
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x4cd9a0
incb %r12b
addq $0xe, %r14
cmpb 0x8(%rbx), %r12b
jb 0x4057de
jmp 0x4058c8
leaq 0x178abd(%rip), %rdi    # 0x57e2d4
callq 0x4d5030
movb (%rbx), %al
testb %al, %al
je 0x4058c8
addq $0x8, %rbx
movb $0x1, %r15b
leaq 0x178940(%rip), %r14    # 0x57e174
cmpb $0x1, %al
je 0x405869
leaq -0x8(%rbx), %rsi
movzwl 0x1(%rbx), %ecx
movzwl 0x3(%rbx), %r8d
movzbl 0x5(%rbx), %r9d
movzbl 0x6(%rbx), %r10d
movzbl 0x7(%rbx), %r11d
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x4cd9a0
addq $0x10, %rsp
movb 0x8(%rbx), %al
testb %al, %al
je 0x4058c8
leal 0x1(%r15), %ecx
addq $0x10, %rbx
testb %r15b, %r15b
movl %ecx, %r15d
jns 0x405834
jmp 0x4058c8
movq $0x5ec460, %rdi         # imm = 0x5EC460
leaq 0x178836(%rip), %rsi    # 0x57e0c6
movl $0x14, %edx
callq 0x46eef0
movq $0x5ec460, %rbx         # imm = 0x5EC460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x450040
movsbl %al, %esi
movq %rbx, %rdi
callq 0x46e9f0
movq %rax, %rdi
callq 0x46dfc0
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq