// File: pelrun[P]aft/CDSKFile.cpp
// Function: CDSKTrack::SameHeader(CDSKTrack const&) const
bool CDSKTrack::SameHeader(const CDSKTrack &track) const
{
	bool equal = true;
	equal = equal && (NbSector == track.NbSector);
	equal = equal && (SectorSize == track.SectorSize);
	equal = equal && (DataRate == track.DataRate);
	equal = equal && (RecordingMode == track.RecordingMode);
	equal = equal && (GAP3Size == track.GAP3Size);
	equal = equal && (FillByte == track.FillByte);

	if (!equal || NbSector == 0)
		return equal;

	unsigned char size = Sectors[0].SectorSize;
	set<unsigned char> sectorID;
	set<unsigned char> trackSectorID;
	for (int s=0 ; s<NbSector ; s++)
	{
		if (Sectors[s].SectorSize != size ||
			track.Sectors[s].SectorSize != size)
			return false;

		sectorID.insert(Sectors[s].SectorID);
		trackSectorID.insert(track.Sectors[s].SectorID);
	}
	if (sectorID.size() != trackSectorID.size())
		return false;

	set<unsigned char>::iterator sit = sectorID.begin();
	set<unsigned char>::iterator dit = trackSectorID.begin();
	for ( ; sit != sectorID.end() ; sit++, dit++)
	{
		if ((*sit) != (*dit))
			return false;
	}
	return true;
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x118(%rsp)
movq %rsi, 0x110(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0x38(%rsp)
movb $0x1, 0x10f(%rsp)
xorl %eax, %eax
testb $0x1, 0x10f(%rsp)
movb %al, 0x47(%rsp)
je 0x982a
movq 0x38(%rsp), %rax
movzbl 0x16(%rax), %eax
movq 0x110(%rsp), %rcx
movzbl 0x16(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
andb $0x1, %al
movb %al, 0x10f(%rsp)
xorl %eax, %eax
testb $0x1, 0x10f(%rsp)
movb %al, 0x37(%rsp)
je 0x9865
movq 0x38(%rsp), %rax
movzbl 0x15(%rax), %eax
movq 0x110(%rsp), %rcx
movzbl 0x15(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
movb %al, 0x10f(%rsp)
xorl %eax, %eax
testb $0x1, 0x10f(%rsp)
movb %al, 0x36(%rsp)
je 0x98a0
movq 0x38(%rsp), %rax
movzbl 0x13(%rax), %eax
movq 0x110(%rsp), %rcx
movzbl 0x13(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x36(%rsp)
movb 0x36(%rsp), %al
andb $0x1, %al
movb %al, 0x10f(%rsp)
xorl %eax, %eax
testb $0x1, 0x10f(%rsp)
movb %al, 0x35(%rsp)
je 0x98db
movq 0x38(%rsp), %rax
movzbl 0x14(%rax), %eax
movq 0x110(%rsp), %rcx
movzbl 0x14(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x35(%rsp)
movb 0x35(%rsp), %al
andb $0x1, %al
movb %al, 0x10f(%rsp)
xorl %eax, %eax
testb $0x1, 0x10f(%rsp)
movb %al, 0x34(%rsp)
je 0x9916
movq 0x38(%rsp), %rax
movzbl 0x17(%rax), %eax
movq 0x110(%rsp), %rcx
movzbl 0x17(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x34(%rsp)
movb 0x34(%rsp), %al
andb $0x1, %al
movb %al, 0x10f(%rsp)
xorl %eax, %eax
testb $0x1, 0x10f(%rsp)
movb %al, 0x33(%rsp)
je 0x9951
movq 0x38(%rsp), %rax
movzbl 0x18(%rax), %eax
movq 0x110(%rsp), %rcx
movzbl 0x18(%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x33(%rsp)
movb 0x33(%rsp), %al
andb $0x1, %al
movb %al, 0x10f(%rsp)
testb $0x1, 0x10f(%rsp)
je 0x9976
movq 0x38(%rsp), %rax
movzbl 0x16(%rax), %eax
cmpl $0x0, %eax
jne 0x998b
movb 0x10f(%rsp), %al
andb $0x1, %al
movb %al, 0x127(%rsp)
jmp 0x9c43
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
movb 0x3(%rax), %al
movb %al, 0x10e(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xb0e0
leaq 0xa8(%rsp), %rdi
callq 0xb0e0
movl $0x0, 0xa4(%rsp)
movq 0x38(%rsp), %rcx
movl 0xa4(%rsp), %eax
movzbl 0x16(%rcx), %ecx
cmpl %ecx, %eax
jge 0x9b20
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0xa4(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzbl 0x3(%rax), %eax
movzbl 0x10e(%rsp), %ecx
cmpl %ecx, %eax
jne 0x9a2e
movq 0x110(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0xa4(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzbl 0x3(%rax), %eax
movzbl 0x10e(%rsp), %ecx
cmpl %ecx, %eax
je 0x9a46
movb $0x0, 0x127(%rsp)
movl $0x1, 0xa0(%rsp)
jmp 0x9c29
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0xa4(%rsp), %rcx
shlq $0x5, %rcx
leaq 0x2(%rax,%rcx), %rsi
leaq 0xd8(%rsp), %rdi
callq 0xb0f0
movb %dl, 0x27(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x9a78
movb 0x27(%rsp), %al
movq 0x28(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movb %al, 0x88(%rsp)
movq 0x110(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0xa4(%rsp), %rcx
shlq $0x5, %rcx
leaq 0x2(%rax,%rcx), %rsi
leaq 0xa8(%rsp), %rdi
callq 0xb0f0
movb %dl, 0x17(%rsp)
movq %rax, 0x18(%rsp)
jmp 0x9ac5
movb 0x17(%rsp), %al
movq 0x18(%rsp), %rcx
movq %rcx, 0x70(%rsp)
movb %al, 0x78(%rsp)
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x99c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xb240
leaq 0xd8(%rsp), %rdi
callq 0xb240
jmp 0x9c54
leaq 0xd8(%rsp), %rdi
callq 0xb150
movq %rax, 0x8(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xb150
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
je 0x9b64
movb $0x0, 0x127(%rsp)
movl $0x1, 0xa0(%rsp)
jmp 0x9c29
leaq 0xd8(%rsp), %rdi
callq 0xb160
movq %rax, 0x68(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xb160
movq %rax, 0x60(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xb1b0
movq %rax, 0x58(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xb190
testb $0x1, %al
jne 0x9baf
jmp 0x9c16
leaq 0x68(%rsp), %rdi
callq 0xb1e0
movzbl (%rax), %eax
movl %eax, 0x4(%rsp)
leaq 0x60(%rsp), %rdi
callq 0xb1e0
movq %rax, %rcx
movl 0x4(%rsp), %eax
movzbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x9bed
movb $0x0, 0x127(%rsp)
movl $0x1, 0xa0(%rsp)
jmp 0x9c29
jmp 0x9bef
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
callq 0xb200
movq %rax, 0x50(%rsp)
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0xb200
movq %rax, 0x48(%rsp)
jmp 0x9b88
movb $0x1, 0x127(%rsp)
movl $0x1, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xb240
leaq 0xd8(%rsp), %rdi
callq 0xb240
movb 0x127(%rsp), %al
andb $0x1, %al
addq $0x128, %rsp            # imm = 0x128
retq
movq 0x98(%rsp), %rdi
callq 0x11ab0
nopw %cs:(%rax,%rax)