// File: /workspace/github_cpp_makefile_star2_O1/ksherlock[P]wdc-utils/omf.cpp
// Function: save_omf(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<omf::segment, std::allocator<omf::segment>>&, unsigned int)
void save_omf(const std::string &path, std::vector<omf::segment> &segments, unsigned flags) {

	// expressload doesn't support links to other files. 
	// fortunately, we don't either.

	std::vector<uint8_t> expr_headers;
	std::vector<unsigned> expr_offsets;


	bool compress = !(flags & OMF_NO_COMPRESS);
	bool super = !(flags & OMF_NO_SUPER);
	bool expressload = !(flags & OMF_NO_EXPRESS);
	bool v1 = flags & OMF_V1;

	if (v1) {
		expressload = false;
		super = false;
	}

	int fd;
	fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
	if (fd < 0) {
		err(EX_CANTCREAT, "Unable to open %s", path.c_str());
	}


	uint32_t offset = 0;
	if (expressload) {
		for (auto &s : segments) {
			s.segnum++;
			for (auto &r : s.intersegs) r.segment++;
		}

		// calculate express load segment size.
		// sizeof includes the trailing 0, so no need to add in byte size.
		offset = sizeof(omf_header) + 10 + sizeof("~ExpressLoad");

		offset += 6; // lconst + end
		offset += 6;  // header.
		for (auto &s : segments) {
			offset += 8 + 2;
			offset += sizeof(omf_express_header) + 10;
			offset += s.segname.length() + 1;
		}

		lseek(fd, offset, SEEK_SET);
	}


	for (auto &s : segments) {
		omf_header h;
		h.length = s.data.size() + s.reserved_space;
		h.kind = s.kind;
		h.banksize = s.data.size() > 0xffff ? 0x0000 : 0x010000;
		h.segnum = s.segnum;
		h.alignment = s.alignment;
		h.reserved_space = s.reserved_space;
		h.org = s.org;

		uint32_t reserved_space = 0;
		if (expressload) {
			std::swap(reserved_space, h.reserved_space);
		}

		// length field INCLUDES reserved space.  Express expand reserved space.


		std::vector<uint8_t> data;

		// push segname and load name onto data.
		// data.insert(data.end(), 10, ' ');
		push(data, s.loadname, 10);
		push(data, s.segname);

		h.dispname = sizeof(omf_header);
		h.dispdata = sizeof(omf_header) + data.size();



		uint32_t lconst_offset = offset + sizeof(omf_header) + data.size() + 5;
		uint32_t lconst_size = s.data.size() + reserved_space;


		//lconst record
		push(data, (uint8_t)omf::LCONST);
		push(data, (uint32_t)lconst_size);

		size_t data_offset = data.size();

		data.insert(data.end(), s.data.begin(), s.data.end());

		if (reserved_space) {
			data.insert(data.end(), reserved_space, 0);
		}

		uint32_t reloc_offset = offset + sizeof(omf_header) + data.size();
		uint32_t reloc_size = 0;

		reloc_size = add_relocs(data, data_offset, s, compress, super);

		// end-of-record
		push(data, (uint8_t)omf::END);

		h.bytecount = data.size() + sizeof(omf_header);

		if (expressload) {

			expr_offsets.emplace_back(expr_headers.size());

			if (lconst_size == 0) lconst_offset = 0;
			if (reloc_size == 0) reloc_offset = 0;


			push(expr_headers, (uint32_t)lconst_offset);
			push(expr_headers, (uint32_t)lconst_size);
			push(expr_headers, (uint32_t)reloc_offset);
			push(expr_headers, (uint32_t)reloc_size);

			push(expr_headers, h.unused1);
			push(expr_headers, h.lablen);
			push(expr_headers, h.numlen);
			push(expr_headers, h.version);
			push(expr_headers, h.banksize);
			push(expr_headers, h.kind);
			push(expr_headers, h.unused2);
			push(expr_headers, h.org);
			push(expr_headers, h.alignment);
			push(expr_headers, h.numsex);
			push(expr_headers, h.unused3);
			push(expr_headers, h.segnum);
			push(expr_headers, h.entry);
			push(expr_headers, (uint16_t)(h.dispname));
			push(expr_headers, h.dispdata);

			expr_headers.insert(expr_headers.end(), 10, ' ');
			push(expr_headers, s.segname);
		}

		if (v1) to_v1(h);
		to_little(h);

		offset += write(fd, &h, sizeof(h));
		offset += write(fd, data.data(), data.size());

		// version 1 needs 512-byte padding for all but final segment.
		if (v1 && &s != &segments.back()) {
			static uint8_t zero[512];
			offset += write(fd, zero, 512 - (offset & 511) );
		}
	}

	if (expressload) {
		omf_header h;
		h.segnum = 1;
		h.banksize = 0x00010000;
		h.kind = 0x8001;
		h.dispname = 0x2c;
		h.dispdata = 0x43;

		unsigned fudge = 10 * segments.size();

		h.length = 6 + expr_headers.size() + fudge;

		std::vector<uint8_t> data;
		data.insert(data.begin(), 10, ' ');
		push(data, std::string("~ExpressLoad"));
		push(data, (uint8_t)0xf2); // lconst.
		push(data, (uint32_t)h.length);

		push(data, (uint32_t)0); // reserved
		push(data, (uint16_t)(segments.size() - 1)); // seg count - 1


		for (auto &offset : expr_offsets) {
			push(data, (uint16_t)(fudge + offset));
			push(data, (uint16_t)0);
			push(data, (uint32_t)0);
			fudge -= 8;
		}

		for (auto &s : segments) {
			push(data, (uint16_t)s.segnum);
		}

		data.insert(data.end(), expr_headers.begin(), expr_headers.end());
		push(data, (uint8_t)0); // end.

		h.bytecount = data.size() + sizeof(omf_header);

		to_little(h);
		lseek(fd, 0, SEEK_SET);
		write(fd, &h, sizeof(h));
		write(fd, data.data(), data.size());

	}

	close(fd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %edx, 0x78(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movq (%rdi), %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x21f0
movl %eax, 0xc(%rsp)
testl %eax, %eax
js 0xd465
xorl %r12d, %r12d
testb $0x9, 0x78(%rsp)
jne 0xcc08
movq 0xb0(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpq %rcx, %rax
je 0xcbdd
movq %rax, %rdx
incw (%rdx)
movq 0x68(%rdx), %rsi
movq 0x70(%rdx), %rdi
cmpq %rdi, %rsi
je 0xcbd1
incw 0xa(%rsi)
addq $0x10, %rsi
jmp 0xcbc2
addq $0x98, %rdx
cmpq %rcx, %rdx
jne 0xcbb7
movl $0x4f, %r12d
cmpq %rcx, %rax
je 0xcbfa
movl 0x38(%rax), %edx
addl %edx, %r12d
addl $0x45, %r12d
addq $0x98, %rax
jmp 0xcbe3
movl %r12d, %esi
movl 0xc(%rsp), %edi
xorl %edx, %edx
callq 0x2420
movq 0xb0(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rax), %rax
movq %rax, 0xd8(%rsp)
cmpq %rax, %r15
je 0xd146
leaq 0x50(%rsp), %r14
xorl %eax, %eax
movq %rax, 0x86(%rsp)
movq %rax, 0x80(%rsp)
movw $0x204, 0x8e(%rsp)      # imm = 0x204
leaq 0x90(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rax)
movups %xmm0, (%rax)
movq 0x58(%r15), %rcx
subq 0x50(%r15), %rcx
xorl %edx, %edx
cmpq $0x10000, %rcx          # imm = 0x10000
setb %dl
movl 0x8(%r15), %eax
addl %eax, %ecx
shll $0x10, %edx
movl %ecx, 0x88(%rsp)
movzwl 0x2(%r15), %ecx
movw %cx, 0x94(%rsp)
movl %edx, 0x90(%rsp)
movzwl (%r15), %ecx
movw %cx, 0xa2(%rsp)
movl 0x4(%r15), %ecx
movl %ecx, 0x9c(%rsp)
movl %eax, 0x84(%rsp)
movl 0xc(%r15), %ecx
movl %ecx, 0x98(%rsp)
movl $0x0, %ebx
testb $0x9, 0x78(%rsp)
jne 0xccd5
movl $0x0, 0x84(%rsp)
movl %eax, %ebx
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0x10(%r15), %rsi
movl $0xa, %edx
movq %r14, %rdi
callq 0xc30f
leaq 0x30(%r15), %rsi
movq %r14, %rdi
movq %rsi, 0xe0(%rsp)
callq 0xc2cf
movw $0x2c, 0xa8(%rsp)
movl 0x58(%rsp), %ebp
subl 0x50(%rsp), %ebp
leal 0x2c(%rbp), %eax
movl %eax, 0xbc(%rsp)
movw %ax, 0xaa(%rsp)
movl 0x58(%r15), %r13d
subl 0x50(%r15), %r13d
movq %r14, %rdi
movl $0xf2, %esi
callq 0xc228
addl %ebx, %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0xc27b
movq 0x58(%rsp), %rsi
movq %r14, %rdi
movq %rsi, %r14
subq 0x50(%rsp), %r14
movq 0x50(%r15), %rdx
movq 0x58(%r15), %rcx
callq 0xdcfa
testl %ebx, %ebx
je 0xcd8b
movq 0x58(%rsp), %rsi
movl %ebx, %edx
movb $0x0, 0x10(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rcx
callq 0x9226
movq %r12, 0xf0(%rsp)
movl %r12d, %ebx
addq $0x2c, %rbx
xorl %r8d, %r8d
movl 0x78(%rsp), %eax
testb $0x3, %al
sete %r8b
xorl %ecx, %ecx
testb $0x4, %al
sete %cl
movl 0x58(%rsp), %r12d
addl %ebx, %r12d
subl 0x50(%rsp), %r12d
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xc3a3
movl %eax, %r14d
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0xc228
movl 0x58(%rsp), %eax
subl 0x50(%rsp), %eax
movq %rax, 0xe8(%rsp)
addl $0x2c, %eax
movl %eax, 0x80(%rsp)
testb $0x9, 0x78(%rsp)
jne 0xd04e
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xc8(%rsp), %rsi
cmpq 0xd0(%rsp), %rsi
je 0xce30
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xc8(%rsp)
jmp 0xce42
leaq 0xc0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xdf0c
leal (%rbx,%rbp), %esi
addl $0x5, %esi
testl %r13d, %r13d
cmovel %r13d, %esi
testl %r14d, %r14d
cmovel %r14d, %r12d
leaq 0x30(%rsp), %rdi
callq 0xc27b
leaq 0x30(%rsp), %rdi
movl %r13d, %esi
callq 0xc27b
leaq 0x30(%rsp), %rdi
movl %r12d, %esi
callq 0xc27b
leaq 0x30(%rsp), %rdi
movl %r14d, %esi
callq 0xc27b
movzbl 0x8c(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc228
movzbl 0x8d(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc228
movzbl 0x8e(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc228
movzbl 0x8f(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc228
movl 0x90(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc27b
movzwl 0x94(%rsp), %ebx
movb %bl, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movb %bh, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movzwl 0x96(%rsp), %ebx
movb %bl, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movb %bh, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movl 0x98(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc27b
movl 0x9c(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc27b
movzbl 0xa0(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc228
movzbl 0xa1(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc228
movzwl 0xa2(%rsp), %ebx
movb %bl, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movb %bh, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movl 0xa4(%rsp), %esi
leaq 0x30(%rsp), %rdi
callq 0xc27b
movb $0x2c, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movb $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movl 0xbc(%rsp), %eax
movb %al, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movl 0xbc(%rsp), %eax
movb %ah, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd76c
movq 0x38(%rsp), %rsi
movb $0x20, 0x10(%rsp)
movl $0xa, %edx
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
leaq 0x10(%rsp), %rcx
callq 0x9226
movq %rbx, %rdi
movq 0xe0(%rsp), %rsi
callq 0xc2cf
testb $0x1, 0x78(%rsp)
je 0xd08c
movb $0x1, 0x8f(%rsp)
movq 0xe8(%rsp), %rax
addl $0x22b, %eax            # imm = 0x22B
shrl $0x9, %eax
movl %eax, 0x80(%rsp)
movb 0x94(%rsp), %al
movb %al, 0x8c(%rsp)
movw $0x0, 0x94(%rsp)
movl $0x2c, %edx
movl 0xc(%rsp), %edi
leaq 0x80(%rsp), %rsi
callq 0x2100
movq %rax, %rbx
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
subq %rsi, %rdx
movl 0xc(%rsp), %edi
callq 0x2100
movq 0xf0(%rsp), %rcx
addl %ebx, %ecx
movl %eax, %r12d
addl %ecx, %r12d
testb $0x1, 0x78(%rsp)
je 0xd115
movq 0xb0(%rsp), %rax
movq 0x8(%rax), %rax
movq $-0x98, %rcx
addq %rcx, %rax
cmpq %rax, %r15
je 0xd115
movq %r12, %rbx
movl %r12d, %eax
andl $0x1ff, %eax            # imm = 0x1FF
movl $0x200, %edx            # imm = 0x200
subl %eax, %edx
movl 0xc(%rsp), %edi
leaq 0x86f6(%rip), %rsi      # 0x15800
callq 0x2100
movq %rbx, %r12
addl %eax, %r12d
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
leaq 0x50(%rsp), %r14
je 0xd131
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
addq $0x98, %r15
cmpq 0xd8(%rsp), %r15
jne 0xcc2d
testb $0x9, 0x78(%rsp)
jne 0xd416
xorl %eax, %eax
movq %rax, 0x86(%rsp)
movq %rax, 0x80(%rsp)
movw $0x204, 0x8e(%rsp)      # imm = 0x204
xorps %xmm0, %xmm0
movups %xmm0, 0x9c(%rsp)
movups %xmm0, 0x90(%rsp)
movw $0x1, 0xa2(%rsp)
movl $0x10000, 0x90(%rsp) # imm = 0x10000
movw $0x8001, 0x94(%rsp)     # imm = 0x8001
movl $0x43002c, 0xa8(%rsp) # imm = 0x43002C
movq 0xb0(%rsp), %rdx
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
sarq $0x3, %rcx
movabsq $-0x79435e50d79435e5, %r14 # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %r14
leal (%r14,%r14), %ecx
movl 0x38(%rsp), %edx
subl 0x30(%rsp), %edx
leal (%rcx,%rcx,4), %r15d
leal (%rdx,%r15), %ebx
addl $0x6, %ebx
movl %ebx, 0x88(%rsp)
leaq 0x10(%rsp), %rdi
movq %rax, 0x10(%rdi)
movaps %xmm0, (%rdi)
leaq 0x50(%rsp), %rcx
movb $0x20, (%rcx)
movl $0xa, %edx
xorl %esi, %esi
callq 0x9226
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x279c(%rip), %rsi      # 0xf9b6
leaq 0x27a1(%rip), %rdx      # 0xf9c2
leaq 0x50(%rsp), %rdi
callq 0x7e88
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xc2cf
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0xd251
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2260
leaq 0x10(%rsp), %rdi
movl $0xf2, %esi
callq 0xc228
leaq 0x10(%rsp), %rdi
movl %ebx, %esi
callq 0xc27b
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0xc27b
movq 0xb0(%rsp), %rcx
movl 0x8(%rcx), %eax
subl (%rcx), %eax
shrl $0x3, %eax
imull $0xffffca1b, %eax, %ebx # imm = 0xFFFFCA1B
decl %ebx
leaq 0x50(%rsp), %rsi
movb %bl, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xd76c
movb %bh, 0x50(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xd76c
movq 0xc0(%rsp), %r12
movq 0xc8(%rsp), %rax
movq %rax, 0x78(%rsp)
cmpq %rax, %r12
je 0xd346
addl %r14d, %r14d
leal (%r14,%r14,4), %eax
movzbl %al, %ebp
leaq 0x10(%rsp), %r13
leaq 0x50(%rsp), %r14
movl (%r12), %ebx
leal (%rbx,%rbp), %eax
movb %al, 0x50(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd76c
addl %r15d, %ebx
movb %bh, 0x50(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd76c
movb $0x0, 0x50(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd76c
movb $0x0, 0x50(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd76c
movq %r13, %rdi
xorl %esi, %esi
callq 0xc27b
addl $-0x8, %r15d
addq $0x4, %r12
addl $-0x8, %ebp
cmpq 0x78(%rsp), %r12
jne 0xd2e2
movq 0xb0(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rax), %r12
cmpq %r12, %r15
je 0xd392
leaq 0x10(%rsp), %r13
leaq 0x50(%rsp), %r14
movzwl (%r15), %ebx
movb %bl, 0x50(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd76c
movb %bh, 0x50(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd76c
addq $0x98, %r15
cmpq %r12, %r15
jne 0xd364
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0xdcfa
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0xc228
movl 0x18(%rsp), %eax
subl 0x10(%rsp), %eax
addl $0x2c, %eax
leaq 0x80(%rsp), %rbx
movl %eax, (%rbx)
movl 0xc(%rsp), %ebp
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2420
movl $0x2c, %edx
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2100
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
subq %rsi, %rdx
movl 0xc(%rsp), %edi
callq 0x2100
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xd416
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
movl 0xc(%rsp), %edi
callq 0x2460
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xd43c
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xd453
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rdx
leaq 0x2056(%rip), %rsi      # 0xf4c5
movl $0x49, %edi
xorl %eax, %eax
callq 0x2240
jmp 0xd4b0
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0xd4b3
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2260
jmp 0xd4b3
jmp 0xd4b0
jmp 0xd4b0
jmp 0xd49f
movq %rax, %rbx
jmp 0xd4e2
jmp 0xd4c8
jmp 0xd4b0
jmp 0xd4c8
jmp 0xd4c8
jmp 0xd4b0
jmp 0xd4c8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xd4e2
movq 0x20(%rsp), %rsi
jmp 0xd4da
jmp 0xd4c8
jmp 0xd4c8
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xd4e2
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xd4ff
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xd516
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2260
movq %rbx, %rdi
callq 0x23c0