// File: rpavlik[P]edid-decode/edid-decode.cpp
// Function: edid_state::print_timings(char const*, timings const*, char const*, char const*, bool, bool)
bool edid_state::print_timings(const char *prefix, const struct timings *t,
			       const char *type, const char *flags,
			       bool detailed, bool do_checks)
{
	if (!t) {
		// Should not happen
		if (do_checks)
			fail("Unknown video timings.\n");
		return false;
	}

	if (detailed && options[OptShortTimings])
		detailed = false;
	if (options[OptLongTimings])
		detailed = true;

	unsigned vact = t->vact;
	unsigned hbl = t->hfp + t->hsync + t->hbp + 2 * t->hborder;
	unsigned vbl = t->vfp + t->vsync + t->vbp + 2 * t->vborder;
	unsigned htotal = t->hact + hbl;
	double hor_freq_khz = htotal ? (double)t->pixclk_khz / htotal : 0;

	if (t->interlaced)
		vact /= 2;

	if (t->ycbcr420)
		hor_freq_khz /= 2;

	double vtotal = vact + vbl;

	bool ok = true;

	if (!t->hact || !hbl || !t->hfp || !t->hsync ||
	    !vact || !vbl || (!t->vfp && !t->interlaced && !t->even_vtotal) || !t->vsync) {
		if (do_checks)
			fail("0 values in the video timing:\n"
			     "    Horizontal Active/Blanking %u/%u\n"
			     "    Horizontal Frontporch/Sync Width %u/%u\n"
			     "    Vertical Active/Blanking %u/%u\n"
			     "    Vertical Frontporch/Sync Width %u/%u\n",
			     t->hact, hbl, t->hfp, t->hsync, vact, vbl, t->vfp, t->vsync);
		ok = false;
	}

	if (t->even_vtotal)
		vtotal = vact + t->vfp + t->vsync + t->vbp;
	else if (t->interlaced)
		vtotal = vact + t->vfp + t->vsync + t->vbp + 0.5;

	double refresh = (double)t->pixclk_khz * 1000.0 / (htotal * vtotal);

	std::string s;
	unsigned rb = t->rb & ~RB_ALT;
	if (rb) {
		bool alt = t->rb & RB_ALT;
		s = "RB";
		// Mark RB_CVT_V3 as preliminary since CVT 1.3 has not been
		// released yet.
		if (rb == RB_CVT_V2)
			s += std::string("v2") + (alt ? ",video-optimized" : "");
		else if (rb == RB_CVT_V3)
			s += std::string("v3-is-preliminary") + (alt ? ",h-blank-160" : "");
	}
	add_str(s, flags);
	if (t->hsize_mm || t->vsize_mm)
		add_str(s, std::to_string(t->hsize_mm) + " mm x " + std::to_string(t->vsize_mm) + " mm");
	if (t->hsize_mm > dtd_max_hsize_mm)
		dtd_max_hsize_mm = t->hsize_mm;
	if (t->vsize_mm > dtd_max_vsize_mm)
		dtd_max_vsize_mm = t->vsize_mm;
	if (!s.empty())
		s = " (" + s + ")";
	unsigned pixclk_khz = t->pixclk_khz / (t->ycbcr420 ? 2 : 1);

	char buf[10];

	sprintf(buf, "%u%s", t->vact, t->interlaced ? "i" : "");
	printf("%s%s: %5ux%-5s %7.3f Hz %3u:%-3u %7.3f kHz %8.3f MHz%s\n",
	       prefix, type,
	       t->hact, buf,
	       refresh,
	       t->hratio, t->vratio,
	       hor_freq_khz,
	       pixclk_khz / 1000.0,
	       s.c_str());

	unsigned len = strlen(prefix) + 2;

	if (!t->ycbcr420 && detailed && options[OptXModeLineTimings])
		print_modeline(len, t, refresh);
	else if (!t->ycbcr420 && detailed && options[OptFBModeTimings])
		print_fbmode(len, t, refresh, hor_freq_khz);
	else if (!t->ycbcr420 && detailed && options[OptV4L2Timings])
		print_v4l2_timing(t, refresh, type);
	else if (detailed)
		print_detailed_timing(len + strlen(type) + 6, t);

	if (!do_checks)
		return ok;

	if (!memcmp(type, "DTD", 3)) {
		unsigned vic, dmt;
		const timings *vic_t = cta_close_match_to_vic(*t, vic);

		if (vic_t)
			warn("DTD is similar but not identical to VIC %u.\n", vic);

		const timings *dmt_t = close_match_to_dmt(*t, dmt);
		if (!vic_t && dmt_t)
			warn("DTD is similar but not identical to DMT 0x%02x.\n", dmt);
	}

	if (refresh) {
		min_vert_freq_hz = min(min_vert_freq_hz, refresh);
		max_vert_freq_hz = max(max_vert_freq_hz, refresh);
	}
	if (hor_freq_khz) {
		min_hor_freq_hz = min(min_hor_freq_hz, hor_freq_khz * 1000.0);
		max_hor_freq_hz = max(max_hor_freq_hz, hor_freq_khz * 1000.0);
		max_pixclk_khz = max(max_pixclk_khz, pixclk_khz);
		if (t->pos_pol_hsync && !t->pos_pol_vsync && t->vsync == 3)
			base.max_pos_neg_hor_freq_khz = hor_freq_khz;
	}

	if (t->ycbcr420 && t->pixclk_khz < 590000)
		warn_once("Some YCbCr 4:2:0 timings are invalid for HDMI (which requires an RGB timings pixel rate >= 590 MHz).\n");
	if (t->hfp <= 0)
		fail("0 or negative horizontal front porch.\n");
	if (t->hbp <= 0)
		fail("0 or negative horizontal back porch.\n");
	if (t->vbp <= 0)
		fail("0 or negative vertical back porch.\n");
	if (!base.max_display_width_mm && !base.max_display_height_mm) {
		/* this is valid */
	} else if (!t->hsize_mm && !t->vsize_mm) {
		/* this is valid */
	} else if (t->hsize_mm > base.max_display_width_mm + 9 ||
		   t->vsize_mm > base.max_display_height_mm + 9) {
		fail("Mismatch of image size %ux%u mm vs display size %ux%u mm.\n",
		     t->hsize_mm, t->vsize_mm, base.max_display_width_mm, base.max_display_height_mm);
	} else if (t->hsize_mm < base.max_display_width_mm - 9 &&
		   t->vsize_mm < base.max_display_height_mm - 9) {
		fail("Mismatch of image size %ux%u mm vs display size %ux%u mm.\n",
		     t->hsize_mm, t->vsize_mm, base.max_display_width_mm, base.max_display_height_mm);
	}
	return ok;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
movl %r9d, %eax
movq %rcx, -0x290(%rbp)
movq %rdx, %rcx
movq -0x290(%rbp), %rdx
movq %rcx, -0x288(%rbp)
movq %rsi, %rcx
movq -0x288(%rbp), %rsi
movq %rcx, -0x280(%rbp)
movq %rdi, %r9
movq -0x280(%rbp), %rdi
movb %al, %cl
movb 0x10(%rbp), %al
movq %r9, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
andb $0x1, %cl
movb %cl, -0x39(%rbp)
andb $0x1, %al
movb %al, -0x3a(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x278(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5157
testb $0x1, -0x3a(%rbp)
je 0x514e
xorl %edi, %edi
leaq 0x2a158(%rip), %rsi     # 0x2f29f
movb $0x0, %al
callq 0x47d0
movb $0x0, -0x9(%rbp)
jmp 0x601b
testb $0x1, -0x39(%rbp)
je 0x516a
cmpb $0x0, 0x4b3ff(%rip)     # 0x50563
je 0x516a
movb $0x0, -0x39(%rbp)
cmpb $0x0, 0x4b3eb(%rip)     # 0x5055c
je 0x5177
movb $0x1, -0x39(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x28(%rbp), %rcx
addl 0x20(%rcx), %eax
movq -0x28(%rbp), %rcx
addl 0x24(%rcx), %eax
movq -0x28(%rbp), %rcx
movl 0x3c(%rcx), %ecx
shll %ecx
addl %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x28(%rbp), %rcx
addl 0x30(%rcx), %eax
movq -0x28(%rbp), %rcx
addl 0x34(%rcx), %eax
movq -0x28(%rbp), %rcx
movl 0x40(%rcx), %ecx
shll %ecx
addl %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x51fb
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
cvtsi2sd %rax, %xmm0
movl -0x4c(%rbp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x298(%rbp)
jmp 0x5208
xorps %xmm0, %xmm0
movsd %xmm0, -0x298(%rbp)
jmp 0x5208
movsd -0x298(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x5227
movl -0x40(%rbp), %eax
shrl %eax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x50(%rax)
je 0x5247
movsd -0x58(%rbp), %xmm0
movsd 0x29dd2(%rip), %xmm1    # 0x2f010
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x40(%rbp), %eax
movl -0x48(%rbp), %ecx
addl %ecx, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x60(%rbp)
movb $0x1, -0x61(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x52b4
cmpl $0x0, -0x44(%rbp)
je 0x52b4
movq -0x28(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x52b4
movq -0x28(%rbp), %rax
cmpl $0x0, 0x20(%rax)
je 0x52b4
cmpl $0x0, -0x40(%rbp)
je 0x52b4
cmpl $0x0, -0x48(%rbp)
je 0x52b4
movq -0x28(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jne 0x52aa
movq -0x28(%rbp), %rax
testb $0x1, 0x18(%rax)
jne 0x52aa
movq -0x28(%rbp), %rax
testb $0x1, 0x44(%rax)
je 0x52b4
movq -0x28(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x530e
testb $0x1, -0x3a(%rbp)
je 0x530a
movq -0x28(%rbp), %rax
movl (%rax), %edx
movl -0x44(%rbp), %ecx
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %r8d
movq -0x28(%rbp), %rax
movl 0x20(%rax), %r9d
movl -0x40(%rbp), %ebx
movl -0x48(%rbp), %r11d
movq -0x28(%rbp), %rax
movl 0x2c(%rax), %r10d
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
xorl %edi, %edi
leaq 0x29fc5(%rip), %rsi     # 0x2f2b7
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x47d0
movb $0x0, -0x61(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x44(%rax)
je 0x533a
movl -0x40(%rbp), %eax
movq -0x28(%rbp), %rcx
movl 0x2c(%rcx), %esi
movl 0x30(%rcx), %edx
addl %esi, %eax
addl %edx, %eax
movl 0x34(%rcx), %ecx
addl %ecx, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x5372
movq -0x28(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x5370
movl -0x40(%rbp), %eax
movq -0x28(%rbp), %rcx
movl 0x2c(%rcx), %esi
movl 0x30(%rcx), %edx
addl %esi, %eax
addl %edx, %eax
movl 0x34(%rcx), %ecx
addl %ecx, %eax
cvtsi2sd %rax, %xmm0
movsd 0x29cb1(%rip), %xmm1    # 0x2f018
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x5372
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x29c9a(%rip), %xmm1    # 0x2f020
mulsd %xmm1, %xmm0
movl -0x4c(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd -0x60(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4430
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
movl %eax, -0x94(%rbp)
cmpl $0x0, -0x94(%rbp)
je 0x5622
movq -0x28(%rbp), %rax
movb 0x14(%rax), %al
shrb $0x7, %al
movb %al, -0x95(%rbp)
leaq 0x29f90(%rip), %rsi     # 0x2f372
leaq -0x90(%rbp), %rdi
callq 0x4420
jmp 0x53f0
cmpl $0x2, -0x94(%rbp)
jne 0x5514
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x4560
movq -0x2a0(%rbp), %rdx
leaq 0x38263(%rip), %rsi     # 0x3d681
leaq -0xe8(%rbp), %rdi
callq 0xb510
jmp 0x542c
movb -0x95(%rbp), %cl
leaq 0x29f3c(%rip), %rax     # 0x2f375
leaq 0x2aa79(%rip), %rdx     # 0x2feb9
testb $0x1, %cl
cmovneq %rax, %rdx
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xb4c0
jmp 0x545c
leaq -0x90(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x43f0
jmp 0x5471
leaq -0xc8(%rbp), %rdi
callq 0x41f0
leaq -0xe8(%rbp), %rdi
callq 0x41f0
leaq -0xe9(%rbp), %rdi
callq 0x4370
jmp 0x5620
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x600d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x5503
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x54f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x41f0
leaq -0xe8(%rbp), %rdi
callq 0x41f0
leaq -0xe9(%rbp), %rdi
callq 0x4370
jmp 0x600d
cmpl $0x3, -0x94(%rbp)
jne 0x561e
leaq -0x131(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x4560
movq -0x2a8(%rbp), %rdx
leaq 0x29e44(%rip), %rsi     # 0x2f386
leaq -0x130(%rbp), %rdi
callq 0xb510
jmp 0x5550
movb -0x95(%rbp), %cl
leaq 0x29e3b(%rip), %rax     # 0x2f398
leaq 0x2a955(%rip), %rdx     # 0x2feb9
testb $0x1, %cl
cmovneq %rax, %rdx
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xb4c0
jmp 0x5580
leaq -0x90(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x43f0
jmp 0x5595
leaq -0x110(%rbp), %rdi
callq 0x41f0
leaq -0x130(%rbp), %rdi
callq 0x41f0
leaq -0x131(%rbp), %rdi
callq 0x4370
jmp 0x561e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x560d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x5601
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x41f0
leaq -0x130(%rbp), %rdi
callq 0x41f0
leaq -0x131(%rbp), %rdi
callq 0x4370
jmp 0x600d
jmp 0x5620
jmp 0x5622
movq -0x38(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x4560
movq -0x2b8(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
leaq -0x158(%rbp), %rdi
callq 0xb510
jmp 0x565c
leaq -0x90(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x6040
jmp 0x5671
leaq -0x158(%rbp), %rdi
callq 0x41f0
leaq -0x159(%rbp), %rdi
callq 0x4370
movq -0x28(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jne 0x56a1
movq -0x28(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
je 0x585b
movq -0x28(%rbp), %rax
movl 0x48(%rax), %esi
leaq -0x1e0(%rbp), %rdi
callq 0xb6d0
jmp 0x56b6
leaq 0x29ce8(%rip), %rdx     # 0x2f3a5
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0xb4c0
jmp 0x56d2
movq -0x28(%rbp), %rax
movl 0x4c(%rax), %esi
leaq -0x200(%rbp), %rdi
callq 0xb6d0
jmp 0x56e7
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
leaq -0x200(%rbp), %rdx
callq 0xb7b0
jmp 0x5703
leaq 0x29ca2(%rip), %rdx     # 0x2f3ac
leaq -0x180(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0xb4c0
jmp 0x571f
leaq -0x90(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x6040
jmp 0x5734
leaq -0x180(%rbp), %rdi
callq 0x41f0
leaq -0x1a0(%rbp), %rdi
callq 0x41f0
leaq -0x200(%rbp), %rdi
callq 0x41f0
leaq -0x1c0(%rbp), %rdi
callq 0x41f0
leaq -0x1e0(%rbp), %rdi
callq 0x41f0
jmp 0x585b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x57a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x41f0
leaq -0x159(%rbp), %rdi
callq 0x4370
jmp 0x600d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x584a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x583e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x5832
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x5826
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x41f0
leaq -0x1a0(%rbp), %rdi
callq 0x41f0
leaq -0x200(%rbp), %rdi
callq 0x41f0
leaq -0x1c0(%rbp), %rdi
callq 0x41f0
leaq -0x1e0(%rbp), %rdi
callq 0x41f0
jmp 0x600d
movq -0x278(%rbp), %rcx
movq -0x28(%rbp), %rax
movl 0x48(%rax), %eax
cmpl 0x74(%rcx), %eax
jbe 0x587f
movq -0x278(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x48(%rcx), %ecx
movl %ecx, 0x74(%rax)
movq -0x278(%rbp), %rcx
movq -0x28(%rbp), %rax
movl 0x4c(%rax), %eax
cmpl 0x78(%rcx), %eax
jbe 0x58a3
movq -0x278(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x4c(%rcx), %ecx
movl %ecx, 0x78(%rax)
leaq -0x90(%rbp), %rdi
callq 0x4510
testb $0x1, %al
jne 0x593f
leaq 0x3824a(%rip), %rsi     # 0x3db08
leaq -0x240(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0xb5c0
jmp 0x58d3
leaq 0x3703b(%rip), %rdx     # 0x3c915
leaq -0x220(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0xb4c0
jmp 0x58ef
leaq -0x90(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x43d0
leaq -0x220(%rbp), %rdi
callq 0x41f0
leaq -0x240(%rbp), %rdi
callq 0x41f0
jmp 0x593f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x41f0
jmp 0x600d
movq -0x28(%rbp), %rcx
movl 0x10(%rcx), %eax
movzbl 0x50(%rcx), %ecx
andl $0x1, %ecx
incl %ecx
xorl %edx, %edx
movl %edx, -0x300(%rbp)
divl %ecx
movl %eax, %ecx
movl -0x300(%rbp), %eax
movl %ecx, -0x244(%rbp)
movq -0x28(%rbp), %rcx
movl 0x4(%rcx), %edx
movb 0x18(%rcx), %dil
leaq 0x29a3c(%rip), %rsi     # 0x2f3b5
leaq 0x2a539(%rip), %rcx     # 0x2feb9
testb $0x1, %dil
cmovneq %rsi, %rcx
leaq 0x29a21(%rip), %rsi     # 0x2f3b0
leaq -0x24e(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x40a0
movq -0x20(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x28(%rbp), %rax
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x2d8(%rbp)
movl (%rax), %ecx
movl %ecx, -0x2e4(%rbp)
movl 0x8(%rax), %ecx
movl %ecx, -0x2cc(%rbp)
movl 0xc(%rax), %eax
movl %eax, -0x2fc(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x2c8(%rbp)
movl -0x244(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x2961d(%rip), %xmm1    # 0x2f020
divsd %xmm1, %xmm0
movsd %xmm0, -0x2c0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4150
movl -0x2fc(%rbp), %edi
movq -0x2f8(%rbp), %rsi
movq -0x2f0(%rbp), %rdx
movl -0x2e4(%rbp), %ecx
movq -0x2e0(%rbp), %r8
movsd -0x2d8(%rbp), %xmm0
movl -0x2cc(%rbp), %r9d
movsd -0x2c8(%rbp), %xmm1
movsd -0x2c0(%rbp), %xmm2
movq %rax, %r10
movq %rsp, %rax
movq %r10, 0x8(%rax)
movl %edi, (%rax)
leaq 0x29949(%rip), %rdi     # 0x2f3b7
movb $0x3, %al
callq 0x4050
jmp 0x5a77
movq -0x20(%rbp), %rdi
callq 0x4180
addq $0x2, %rax
movl %eax, -0x254(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x50(%rax)
jne 0x5abe
testb $0x1, -0x39(%rbp)
je 0x5abe
cmpb $0x0, 0x4aac7(%rip)     # 0x50568
je 0x5abe
movl -0x254(%rbp), %edi
movq -0x28(%rbp), %rsi
movsd -0x70(%rbp), %xmm0
callq 0x60f0
jmp 0x5ab9
jmp 0x5b61
movq -0x28(%rbp), %rax
testb $0x1, 0x50(%rax)
jne 0x5af4
testb $0x1, -0x39(%rbp)
je 0x5af4
cmpb $0x0, 0x4aa81(%rip)     # 0x50556
je 0x5af4
movl -0x254(%rbp), %edi
movq -0x28(%rbp), %rsi
movsd -0x70(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
callq 0x6390
jmp 0x5af2
jmp 0x5b5f
movq -0x28(%rbp), %rax
testb $0x1, 0x50(%rax)
jne 0x5b23
testb $0x1, -0x39(%rbp)
je 0x5b23
cmpb $0x0, 0x4aa5b(%rip)     # 0x50566
je 0x5b23
movq -0x28(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
movq -0x30(%rbp), %rsi
callq 0x6670
jmp 0x5b21
jmp 0x5b5d
testb $0x1, -0x39(%rbp)
je 0x5b5b
movl -0x254(%rbp), %eax
movl %eax, -0x304(%rbp)
movq -0x30(%rbp), %rdi
callq 0x4180
movl -0x304(%rbp), %ecx
movl %eax, %edx
movl %ecx, %eax
movl %edx, %ecx
leal 0x6(%rax,%rcx), %edi
movq -0x28(%rbp), %rsi
callq 0x71a0
jmp 0x5b59
jmp 0x5b5b
jmp 0x5b5d
jmp 0x5b5f
jmp 0x5b61
testb $0x1, -0x3a(%rbp)
jne 0x5b7e
movb -0x61(%rbp), %al
andb $0x1, %al
movb %al, -0x9(%rbp)
movl $0x1, -0x258(%rbp)
jmp 0x5fff
movq -0x30(%rbp), %rdi
leaq 0x29866(%rip), %rsi     # 0x2f3ef
movl $0x3, %edx
callq 0x4190
cmpl $0x0, %eax
jne 0x5c44
movq -0x28(%rbp), %rdi
leaq -0x25c(%rbp), %rsi
callq 0x155c0
movq %rax, -0x310(%rbp)
jmp 0x5bb5
movq -0x310(%rbp), %rax
movq %rax, -0x268(%rbp)
cmpq $0x0, -0x268(%rbp)
je 0x5bea
movl -0x25c(%rbp), %edx
leaq 0x29819(%rip), %rsi     # 0x2f3f3
xorl %eax, %eax
movl $0x1, %edi
callq 0x47d0
jmp 0x5be8
jmp 0x5bea
movq -0x28(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0xe8f0
movq %rax, -0x318(%rbp)
jmp 0x5c03
movq -0x318(%rbp), %rax
movq %rax, -0x270(%rbp)
cmpq $0x0, -0x268(%rbp)
jne 0x5c42
cmpq $0x0, -0x270(%rbp)
je 0x5c42
movl -0x260(%rbp), %edx
leaq 0x297ee(%rip), %rsi     # 0x2f420
xorl %eax, %eax
movl $0x1, %edi
callq 0x47d0
jmp 0x5c40
jmp 0x5c42
jmp 0x5c44
movsd -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5c59
jp 0x5c59
jmp 0x5cea
movq -0x278(%rbp), %rax
movsd 0x60(%rax), %xmm1
movsd -0x70(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5c86
movq -0x278(%rbp), %rax
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x320(%rbp)
jmp 0x5c93
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x320(%rbp)
movq -0x278(%rbp), %rax
movsd -0x320(%rbp), %xmm0
movsd %xmm0, 0x60(%rax)
movsd 0x68(%rax), %xmm0
ucomisd -0x70(%rbp), %xmm0
jbe 0x5cc9
movq -0x278(%rbp), %rax
movsd 0x68(%rax), %xmm0
movsd %xmm0, -0x328(%rbp)
jmp 0x5cd6
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x328(%rbp)
movq -0x278(%rbp), %rax
movsd -0x328(%rbp), %xmm0
movsd %xmm0, 0x68(%rax)
movsd -0x58(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5cff
jp 0x5cff
jmp 0x5e32
movq -0x278(%rbp), %rax
movl 0x54(%rax), %eax
cvtsi2sd %rax, %xmm1
movsd 0x2930a(%rip), %xmm0    # 0x2f020
mulsd -0x58(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5d3a
movq -0x278(%rbp), %rax
movl 0x54(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x330(%rbp)
jmp 0x5d4f
movsd 0x292de(%rip), %xmm0    # 0x2f020
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x330(%rbp)
movq -0x278(%rbp), %rax
movsd -0x330(%rbp), %xmm0
cvttsd2si %xmm0, %rcx
movl %ecx, 0x54(%rax)
movl 0x58(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x292aa(%rip), %xmm1    # 0x2f020
mulsd -0x58(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x5d9a
movq -0x278(%rbp), %rax
movl 0x58(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x338(%rbp)
jmp 0x5daf
movsd 0x2927e(%rip), %xmm0    # 0x2f020
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x338(%rbp)
movq -0x278(%rbp), %rax
movsd -0x338(%rbp), %xmm0
cvttsd2si %xmm0, %rcx
movl %ecx, 0x58(%rax)
movl 0x70(%rax), %eax
cmpl -0x244(%rbp), %eax
jbe 0x5de3
movq -0x278(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x33c(%rbp)
jmp 0x5def
movl -0x244(%rbp), %eax
movl %eax, -0x33c(%rbp)
movq -0x278(%rbp), %rax
movl -0x33c(%rbp), %ecx
movl %ecx, 0x70(%rax)
movq -0x28(%rbp), %rax
testb $0x1, 0x28(%rax)
je 0x5e30
movq -0x28(%rbp), %rax
testb $0x1, 0x38(%rax)
jne 0x5e30
movq -0x28(%rbp), %rax
cmpl $0x3, 0x30(%rax)
jne 0x5e30
movq -0x278(%rbp), %rax
cvttsd2si -0x58(%rbp), %rcx
movl %ecx, 0x17c(%rax)
jmp 0x5e32
movq -0x28(%rbp), %rax
testb $0x1, 0x50(%rax)
je 0x5e78
movq -0x28(%rbp), %rax
cmpl $0x900b0, 0x10(%rax)    # imm = 0x900B0
jae 0x5e78
jmp 0x5e4b
testb $0x1, 0x4a7be(%rip)     # 0x50610
jne 0x5e72
movb $0x1, 0x4a7b5(%rip)     # 0x50610
leaq 0x295ef(%rip), %rsi     # 0x2f451
xorl %eax, %eax
movl $0x1, %edi
callq 0x47d0
jmp 0x5e70
jmp 0x5e72
jmp 0x5e74
jmp 0x5e76
jmp 0x5e78
movq -0x28(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jg 0x5e97
leaq 0x2962e(%rip), %rsi     # 0x2f4b7
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x5e95
jmp 0x5e97
movq -0x28(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jg 0x5eb6
leaq 0x29636(%rip), %rsi     # 0x2f4de
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x5eb4
jmp 0x5eb6
movq -0x28(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jg 0x5ed5
leaq 0x2963d(%rip), %rsi     # 0x2f504
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x5ed3
jmp 0x5ed5
movq -0x278(%rbp), %rax
cmpl $0x0, 0x174(%rax)
jne 0x5efa
movq -0x278(%rbp), %rax
cmpl $0x0, 0x178(%rax)
jne 0x5efa
jmp 0x5fed
movq -0x28(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jne 0x5f13
movq -0x28(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
jne 0x5f13
jmp 0x5feb
movq -0x278(%rbp), %rcx
movq -0x28(%rbp), %rax
movl 0x48(%rax), %eax
movl 0x174(%rcx), %ecx
addl $0x9, %ecx
cmpl %ecx, %eax
ja 0x5f49
movq -0x278(%rbp), %rcx
movq -0x28(%rbp), %rax
movl 0x4c(%rax), %eax
movl 0x178(%rcx), %ecx
addl $0x9, %ecx
cmpl %ecx, %eax
jbe 0x5f7d
movq -0x278(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x48(%rcx), %edx
movl 0x4c(%rcx), %ecx
movl 0x174(%rax), %r8d
movl 0x178(%rax), %r9d
leaq 0x295b9(%rip), %rsi     # 0x2f528
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x5f7b
jmp 0x5fe9
movq -0x278(%rbp), %rcx
movq -0x28(%rbp), %rax
movl 0x48(%rax), %eax
movl 0x174(%rcx), %ecx
subl $0x9, %ecx
cmpl %ecx, %eax
jae 0x5fe7
movq -0x278(%rbp), %rcx
movq -0x28(%rbp), %rax
movl 0x4c(%rax), %eax
movl 0x178(%rcx), %ecx
subl $0x9, %ecx
cmpl %ecx, %eax
jae 0x5fe7
movq -0x278(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x48(%rcx), %edx
movl 0x4c(%rcx), %ecx
movl 0x174(%rax), %r8d
movl 0x178(%rax), %r9d
leaq 0x2954f(%rip), %rsi     # 0x2f528
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x5fe5
jmp 0x5fe7
jmp 0x5fe9
jmp 0x5feb
jmp 0x5fed
movb -0x61(%rbp), %al
andb $0x1, %al
movb %al, -0x9(%rbp)
movl $0x1, -0x258(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x41f0
jmp 0x601b
leaq -0x90(%rbp), %rdi
callq 0x41f0
jmp 0x602a
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0x4550
nopw %cs:(%rax,%rax)