// File: /workspace/github_cpp_makefile_star2_O1/bstrysko[P]IntelHexParser/src/IntelHexFile.cpp
// Function: IntelHexFile::IntelHexFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
IntelHexFile::IntelHexFile(string filename)
{
	ifstream file(filename.c_str());

	if(!file.is_open())
	{
		stringstream o;
		o << "Cannot load file ";
		o << filename;
		throw ios_base::failure(o.str());
	}

	char buffer[INTEL_HEX_FILE_MAX_ENTRY_SIZE];

	while(true)
	{
		file.getline(buffer, INTEL_HEX_FILE_MAX_ENTRY_SIZE);

		/*
		 * End of file
		 */
		if(!file)
		{
			break;
		}

		IntelHexFileEntry entry(buffer);

		if((entry.getRecordType() != 0x0) && (entry.getRecordType() != 0x1))
		{
			stringstream o;
			o << "Unsupported record type: 0x";
			o << hex << (uint32_t)entry.getRecordType();
			throw ios_base::failure(o.str());
		}

		addressToFileEntries.insert(pair<uint16_t, IntelHexFileEntry>(entry.getAddress(), entry));
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x618, %rsp            # imm = 0x618
movq %rsi, %rbx
leaq 0x8(%rdi), %rax
movl $0x0, 0x8(%rdi)
xorl %ecx, %ecx
movq %rcx, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movq %rdi, -0x30(%rbp)
movq %rcx, 0x28(%rdi)
movq (%rsi), %rsi
leaq -0x428(%rbp), %rdi
movl $0x8, %edx
callq 0x34a0
leaq -0x3b0(%rbp), %rdi
callq 0x3040
testb %al, %al
je 0x38f6
leaq -0x218(%rbp), %r15
leaq -0x640(%rbp), %r12
leaq -0x78(%rbp), %rbx
movq -0x428(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x428(%rbp), %r14
addq %r14, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %ecx
movl $0x20c, %edx            # imm = 0x20C
movq %r14, %rdi
movq %r12, %rsi
callq 0x34e0
movq -0x428(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x408(%rbp,%rax)
jne 0x3829
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %r12, %rdi
callq 0x3100
leaq (%rax,%rbp), %rdx
addq $-0x640, %rdx           # imm = 0xF9C0
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x30c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3150
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3757
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x3470
testb %al, %al
je 0x3773
movq %rbx, %rdi
callq 0x3470
cmpb $0x1, %al
jne 0x384c
movq %rbx, %rdi
callq 0x3270
movw %ax, -0x220(%rbp)
movb -0x76(%rbp), %al
movb %al, 0x2(%r15)
movzwl -0x78(%rbp), %eax
movw %ax, (%r15)
movq -0x68(%rbp), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
movq $0x0, 0x18(%r15)
subq -0x70(%rbp), %r14
je 0x37be
js 0x3847
movq %r14, %rdi
callq 0x32a0
movq %rax, %r13
jmp 0x37c1
xorl %r13d, %r13d
movq %r13, -0x210(%rbp)
movq %r13, -0x208(%rbp)
addq %r13, %r14
movq %r14, -0x200(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %r14
subq %rsi, %r14
je 0x37f1
movq %r13, %rdi
movq %r14, %rdx
callq 0x3400
addq %r14, %r13
movq %r13, -0x208(%rbp)
movb -0x58(%rbp), %al
movb %al, -0x1f8(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x3240
movq %r15, %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3140
jmp 0x36be
leaq -0x428(%rbp), %rdi
callq 0x3060
addq $0x618, %rsp            # imm = 0x618
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x30a0
leaq -0x220(%rbp), %rdi
callq 0x31f0
leaq -0x210(%rbp), %rbx
leaq 0x27bc(%rip), %rsi      # 0x6022
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x3310
movq -0x210(%rbp), %rax
movq -0x18(%rax), %rax
movl -0x1f8(%rbp,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, -0x1f8(%rbp,%rax)
leaq -0x78(%rbp), %rdi
callq 0x3470
movzbl %al, %esi
movq %rbx, %rdi
callq 0x31e0
movl $0x20, %edi
callq 0x3120
movq %rax, %rbx
leaq -0x208(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x33e0
movb $0x1, %r15b
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0x34d0
xorl %r15d, %r15d
movq 0x56d6(%rip), %rsi      # 0x8fb8
movq 0x56e7(%rip), %rdx      # 0x8fd0
movq %rbx, %rdi
callq 0x3440
jmp 0x3977
leaq -0x640(%rbp), %rdi
callq 0x31f0
leaq -0x630(%rbp), %r14
leaq 0x2700(%rip), %rsi      # 0x6010
movl $0x11, %edx
movq %r14, %rdi
callq 0x3310
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x3310
movl $0x20, %edi
callq 0x3120
movq %rax, %rbx
leaq -0x628(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x33e0
movb $0x1, %r15b
leaq -0x220(%rbp), %rsi
movq %rbx, %rdi
callq 0x34d0
xorl %r15d, %r15d
movq 0x5650(%rip), %rsi      # 0x8fb8
movq 0x5661(%rip), %rdx      # 0x8fd0
movq %rbx, %rdi
callq 0x3440
movq %rax, %r14
leaq -0x210(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x39a1
movq -0x210(%rbp), %rsi
incq %rsi
callq 0x32b0
jmp 0x39a1
movq %rax, %r14
movb $0x1, %r15b
testb %r15b, %r15b
je 0x39b3
movq %rbx, %rdi
callq 0x3210
jmp 0x39b3
movq %rax, %r14
movq 0x5606(%rip), %rsi      # 0x8fc0
leaq -0x640(%rbp), %rdi
callq 0x3220
leaq -0x5c0(%rbp), %rdi
callq 0x3080
jmp 0x3a82
jmp 0x3a71
movq %rax, %r14
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3a06
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x32b0
jmp 0x3a06
movq %rax, %r14
movb $0x1, %r15b
testb %r15b, %r15b
je 0x3a1d
movq %rbx, %rdi
callq 0x3210
jmp 0x3a1d
movq %rax, %r14
jmp 0x3a8e
movq %rax, %r14
movq 0x559c(%rip), %rsi      # 0x8fc0
leaq -0x220(%rbp), %rdi
callq 0x3220
leaq -0x1a0(%rbp), %rdi
callq 0x3080
jmp 0x3a79
jmp 0x3a76
movq %rax, %r14
movq %r15, %rdi
callq 0x3140
jmp 0x3a79
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3a82
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32b0
jmp 0x3a82
jmp 0x3a71
jmp 0x3a76
jmp 0x3a76
movq %rax, %r14
jmp 0x3a82
movq %rax, %r14
leaq -0x78(%rbp), %rdi
callq 0x3140
leaq -0x428(%rbp), %rdi
callq 0x3060
movq -0x30(%rbp), %rdi
callq 0x3190
movq %r14, %rdi
callq 0x3460
nop