// File: /workspace/github_c_makefile_star2_O3/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 0x407180
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 0x4062fa
movq %r15, %rdi
movq %rbx, %rsi
movl $0xa0000, %edx          # imm = 0xA0000
callq 0x4045d8
movl %eax, %r14d
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x405764
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x406440
testl %r14d, %r14d
jle 0x405813
movabsq $0x5249414c434e4953, %rax # imm = 0x5249414C434E4953
cmpq %rax, (%rbx)
je 0x405828
cmpl $0xa0000, %r14d         # imm = 0xA0000
jne 0x40587e
cmpb $0x10, 0x8e7(%rbx)
jne 0x40587e
leaq 0x178b33(%rip), %rdi    # 0x57e2d4
callq 0x4d5040
movb (%rbx), %al
testb %al, %al
je 0x4058c4
addq $0x8, %rbx
movb $0x1, %r15b
leaq 0x1789b6(%rip), %r14    # 0x57e174
cmpb $0x1, %al
je 0x4057f3
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 0x4cd9b0
addq $0x10, %rsp
movb 0x8(%rbx), %al
testb %al, %al
je 0x4058c4
leal 0x1(%r15), %ecx
addq $0x10, %rbx
testb %r15b, %r15b
movl %ecx, %r15d
jns 0x4057be
jmp 0x4058c4
movq $0x5ec460, %rdi         # imm = 0x5EC460
leaq 0x178809(%rip), %rsi    # 0x57e02a
movl $0xf, %edx
jmp 0x405891
leaq 0x178ae3(%rip), %rdi    # 0x57e312
callq 0x4d5040
cmpb $0x0, 0x8(%rbx)
je 0x4058c4
movq %rbx, %r14
addq $0x11, %r14
xorl %r12d, %r12d
leaq 0x178911(%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 0x4cd9b0
incb %r12b
addq $0xe, %r14
cmpb 0x8(%rbx), %r12b
jb 0x40584f
jmp 0x4058c4
movq $0x5ec460, %rdi         # imm = 0x5EC460
leaq 0x17883a(%rip), %rsi    # 0x57e0c6
movl $0x14, %edx
callq 0x46ef00
movq $0x5ec460, %rbx         # imm = 0x5EC460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x450050
movsbl %al, %esi
movq %rbx, %rdi
callq 0x46ea00
movq %rax, %rdi
callq 0x46dfd0
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq