// File: /workspace/github_c_makefile_star2_O1/truenas[P]binaries/src/ixnvdimm.c
// Function: firmware_update
static void
firmware_update(int fd, struct ixnvdimm_info *info, const char *f, int I)
{
	int b, ffd, r, rbs, regions, t, timeout, atimeout, try;
	struct stat sb;
	off_t size;
	uint8_t *image, status[4], buf[7 + BLOCK_SIZE];

	/* Firmware commands timeout in milliseconds. */
	timeout = i2c_read16(fd, 0x00, 0x22);
	if (timeout & 0x8000)
		timeout = (timeout & 0x7fff) * 1000;

	/* Abort commands timeout in milliseconds. */
	atimeout = i2c_read(fd, 0x00, 0x24);
	if (i2c_read(fd, 0x00, 0x11) & 0x02)
		atimeout = atimeout * 1000;

	/* Region size in blocks. */
	rbs = i2c_read(fd, 0x00, 0x32);

	if ((ffd = open(f, O_RDONLY)) < 0)
		err(EX_NOINPUT, "Can't open firmware file '%s'", f);
	if (fstat(ffd, &sb) < 0)
		err(EX_NOINPUT, "Can't stat firmware file '%s'", f);
	size = roundup(sb.st_size, rbs * BLOCK_SIZE);
	regions = size / (rbs * BLOCK_SIZE);
	if (size < BLOCK_SIZE)
		errx(EX_NOINPUT, "Firmware file '%s' is too small", f);
	image = calloc(1, size);
	if (image == NULL)
		err(EX_OSERR, "Can't allocate firmware memory");
	if (read(ffd, image, sb.st_size) != sb.st_size)
		err(EX_OSERR, "Can't read firmware file '%s'", f);
	close(ffd);

	/* Validate firmware image header. */
	if (I)
		t = 0;		/* Ignore any identifiers difference. */
	else if (image[31] == 0)
		t = 0x03;
	else if (image[31] == 1)
		t = image[19];
	else
		errx(EX_NOINPUT, "Unknown Firmware Image Header Format %u", image[31]);
	if ((t & 0x01) && le16dec(&image[0]) != info->VendorId)
		errx(EX_NOINPUT, "Module Manufacturer ID Code does not match");
	if ((t & 0x02) && le16dec(&image[2]) != info->DeviceId)
		errx(EX_NOINPUT, "Module Product Identifier does not match");
	if ((t & 0x04) && le16dec(&image[4]) != info->SubsystemVendorId)
		errx(EX_NOINPUT, "Non-Volatile Memory Subsystem Controller Module Manufacturer ID Code does not match");
	if ((t & 0x08) && le16dec(&image[6]) != info->SubsystemDeviceId)
		errx(EX_NOINPUT, "Non-Volatile Memory Subsystem Controller Module Product Identifier does not match");
	if ((t & 0x10) && image[8] != info->RevisionId)
		errx(EX_NOINPUT, "Module Revision Code does not match");
	if ((t & 0x20) && image[9] != info->SubsystemRevisionId)
		errx(EX_NOINPUT, "Non-Volatile Memory Subsystem Controller Revision Code does not match");
	if (be32dec(&image[20]) != sb.st_size)
		errx(EX_NOINPUT, "Size in firmware header does not match");
	if (be16dec(&image[24]) !=
	    Crc16((char *)image + BLOCK_SIZE, sb.st_size - BLOCK_SIZE))
		errx(EX_NOINPUT, "Checksum in firmware header does not match");

	/* Wait for the Operation In Progress bit in the NVDIMM_CMD_STATUS0 register to be clear. */
	if (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) {
		printf("Waiting for Operation In Progress to clear\n");
		for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
			usleep(1000);
		if (t >= timeout) {
			errx(EX_PROTOCOL, "NVDIMM has operation in progress: %02x",
			    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
		}
	}

	/* Start firmware update via DSM. */
	i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
	buf[0] = 1;	/* Firmware Slot */
	memset(&status, 0xff, sizeof(status));
	if (calldsm(fd, 22, buf, 1, status, sizeof(status)) != 4)
		err(EX_NOINPUT, "Can't call Start Firmware Update DSM");
	if (le32dec(&status[0]) != 0)
		errx(EX_NOINPUT, "Start Firmware Update DSM failed: %x",
		    le32dec(&status[0]));
	printf("Start Firmware Update succeeded\n");
	fflush(stdout);

	/*
	 * Wait for the Operation In Progress bit in the NVDIMM_CMD_STATUS0
	 * register to be clear.  I have no clue why ACPI DSM does not do it.
	 */
	for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
		usleep(1000);
	if (t >= timeout) {
		warnx("Start Firmware Update DSM timeout: %04x",
		    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
		goto timeout;
	}

	/* Check ACPI enabled firmware update mode. */
	if ((i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x04) == 0) {
		warnx("Firmware update mode is not enabled: %02x",
		    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
		goto error;
	}

	/* Clear firmware region. */
	i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
	i2c_write(fd, 0, FIRMWARE_OPS_CMD, 0x02);
	for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
		usleep(1000);
	if (t >= timeout) {
		warnx("Clear Firmware timeout: %04x",
		    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
		goto timeout;
	}
	if (i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x02) {
		warnx("Clear Firmware failed: %02x",
		    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
		goto error2;
	}

	/* Send firmware one region at a time */
	i2c_write(fd, 3, TYPED_BLOCK_DATA, 0x01);
	for (r = 0; r < regions; r++) {
		printf("\r%d/%d ", r, regions);
		fflush(stdout);
		try = 0;

retry:
		/* Send region blocks via Send Firmware Update Data DSM. */
		for (b = 0; b < rbs; b++) {
			le32enc(&buf[0], BLOCK_SIZE);
			le16enc(&buf[4], r);
			buf[6] = b;
			memcpy(&buf[7], &image[(r * rbs + b) * BLOCK_SIZE], BLOCK_SIZE);
			memset(&status, 0xff, sizeof(status));
			if (calldsm(fd, 23, buf, sizeof(buf), status, sizeof(status)) != 4) {
				warn("Can't call Send Firmware Update Data DSM");
				goto error2;
			}
			if (le32dec(&status[0]) != 0) {
				warnx("Send Firmware Update Data DSM failed: %x",
				    le32dec(&status[0]));
				goto error2;
			}
		}

		/* Verify region checksum. */
		i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
		i2c_write(fd, 0, FIRMWARE_OPS_CMD, 0x04);
		for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
			usleep(1000);
		if (t >= timeout) {
			warnx("Generate Firmware Checksum timeout: %04x",
			    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
			goto timeout;
		}
		if (i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x02) {
			warnx("Generate Firmware Checksum failed: %02x",
			    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
			goto error2;
		}
		if (i2c_read16(fd, 3, FW_REGION_CRC0) !=
		    Crc16((char *)image + r * rbs * BLOCK_SIZE, rbs * BLOCK_SIZE)) {
			if (++try < 3) {
				printf("Region checksum mismatch, retrying\n");
				goto retry;
			} else {
				warnx("Region checksum mismatch");
				goto error2;
			}
		}

		/*
		 * After sending the first region with the header in it ask
		 * the module to check that the new image really applies.
		 */
		if (r == 0) {
			i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
			i2c_write(fd, 0, FIRMWARE_OPS_CMD, 0x10);
			for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
				usleep(1000);
			if (t >= timeout) {
				warnx("Validate Firmware Header timeout: %04x",
				    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
				goto timeout;
			}
			if (i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x02) {
				warnx("Validate Firmware Header failed: %02x",
				    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
				goto error2;
			}
			printf("\rValidate Firmware Header succeeded\n");
		}

		/* The region seems to be correct, commit it. */
		i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
		i2c_write(fd, 0, FIRMWARE_OPS_CMD, 0x08);
		for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
			usleep(1000);
		if (t >= timeout) {
			warnx("Commit Firmware timeout: %04x",
			    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
			goto timeout;
		}
		if (i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x02) {
			warnx("Commit Firmware failed: %02x",
			    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
			goto error2;
		}
	}
	i2c_write(fd, 3, TYPED_BLOCK_DATA, 0x00);
	printf("\rSend Firmware Update Data succeeded\n");
	fflush(stdout);

	/* Validate firmware image. */
	printf("Validating firmware image... ");
	fflush(stdout);
	i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
	i2c_write(fd, 0, FIRMWARE_OPS_CMD, 0x20);
	for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
		usleep(1000);
	if (t >= timeout) {
		warnx("Validate Firmware Image timeout: %02x",
		    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
timeout:
		/* Send Abort command. */
		i2c_write(fd, 0, 0x43, 0x10);
		for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < atimeout; t++)
			usleep(1000);
		if (t >= atimeout)
			warnx("Abort command timeout: %04x",
			    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
		else if ((i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x10) == 0)
			warnx("Abort command haven't succeeded: %02x",
			    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
		goto error2;
	}
	if (i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x02) {
		warnx("Validate Firmware Image failed: %02x",
		    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
error2:
		/* Disable firmware update mode. */
		i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
		i2c_write(fd, 0, FIRMWARE_OPS_CMD, 0);
		for (t = 0; (i2c_read(fd, 0, NVDIMM_CMD_STATUS0) & 1) && t < timeout; t++)
			usleep(1000);
		if (t >= timeout)
			warnx("Disable firmware update mode timeout: %04x",
			    i2c_read16(fd, 0, NVDIMM_CMD_STATUS0));
		else if (i2c_read(fd, 0, FIRMWARE_OPS_STATUS) & 0x04)
			warnx("Firmware update mode disable error: %02x",
			    i2c_read(fd, 0, FIRMWARE_OPS_STATUS));
error:
		goto done;
	}
	printf("\rValidate Firmware Image succeeded\n");
	fflush(stdout);

	/* Finish firmware update via DSM. */
	i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
	memset(&status, 0xff, sizeof(status));
	if (calldsm(fd, 24, NULL, 0, status, sizeof(status)) != 4)
		err(EX_NOINPUT, "Can't call Finish Firmware Update DSM");
	if (le32dec(&status[0]) != 0)
		errx(EX_NOINPUT, "Finish Firmware Update DSM status: %x",
		    le32dec(&status[0]));
	printf("Finish Firmware Update succeeded\n");
	fflush(stdout);

	/* Select firmware image slot 1 */
	i2c_write(fd, 0, NVDIMM_MGT_CMD1, 1 << 1);
	buf[0] = 1;	/* Firmware Slot 1 */
	memset(&status, 0xff, sizeof(status));
	if (calldsm(fd, 25, buf, 1, status, sizeof(status)) != 4)
		err(EX_NOINPUT, "Can't call Select Firmware Image Slot DSM");
	if (le32dec(&status[0]) != 0)
		errx(EX_NOINPUT, "Select Firmware Image Slot DSM failed: %x",
		    le32dec(&status[0]));
	printf("Select Firmware Image Slot 1 succeeded\n");
	fflush(stdout);

done:
	free(image);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movl %ecx, 0x20(%rsp)
movq %rdx, %r12
movq %rsi, 0x40(%rsp)
movl %edi, %ebx
xorl %esi, %esi
movl $0x22, %edx
callq 0x2b2d
movzbl %al, %ebp
movl %ebx, %edi
xorl %esi, %esi
movl $0x23, %edx
callq 0x2b2d
movzbl %al, %eax
shll $0x8, %eax
movl %eax, %ecx
orl %ebp, %ecx
movzwl %cx, %edx
andl $0x7fff, %ecx           # imm = 0x7FFF
imull $0x3e8, %ecx, %ebp      # imm = 0x3E8
testw %ax, %ax
cmovnsl %edx, %ebp
movl %ebx, %edi
xorl %esi, %esi
movl $0x24, %edx
callq 0x2b2d
movzbl %al, %r14d
movl %ebx, %edi
xorl %esi, %esi
movl $0x11, %edx
callq 0x2b2d
imull $0x3e8, %r14d, %r15d    # imm = 0x3E8
testb $0x2, %al
cmovel %r14d, %r15d
movl %ebx, %edi
xorl %esi, %esi
movl $0x32, %edx
callq 0x2b2d
movl %eax, %r13d
movq %r12, 0x10(%rsp)
movq %r12, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2170
testl %eax, %eax
js 0x397d
movl %eax, %r14d
leaq 0x98(%rsp), %rsi
movl %eax, %edi
callq 0x21b0
testl %eax, %eax
js 0x3986
movzbl %r13b, %eax
movl %eax, 0x1c(%rsp)
movl %eax, %ecx
shll $0x5, %ecx
movq 0xc8(%rsp), %rsi
addq %rcx, %rsi
decq %rsi
movq %rsi, %rax
cqto
idivq %rcx
subq %rdx, %rsi
movq %rsi, %rax
cqto
movq %rcx, 0x50(%rsp)
idivq %rcx
movq %rax, 0x58(%rsp)
cmpq $0x1f, %rsi
jle 0x3994
movl $0x1, %edi
callq 0x2110
testq %rax, %rax
je 0x39ac
movq 0xc8(%rsp), %r13
movl %r14d, %edi
movq %rax, 0x28(%rsp)
movq %rax, %rsi
movq %r13, %rdx
callq 0x2100
cmpq %r13, %rax
jne 0x39ba
movl %r14d, %edi
callq 0x20f0
xorl %eax, %eax
cmpl $0x0, 0x20(%rsp)
movq 0x28(%rsp), %rsi
jne 0x2dab
movzbl 0x1f(%rsi), %edx
movl $0x3, %eax
testl %edx, %edx
je 0x2dab
cmpl $0x1, %edx
jne 0x3a69
movzbl 0x13(%rsi), %eax
testb $0x1, %al
movq 0x40(%rsp), %rdx
je 0x2dc0
movzwl (%rsi), %ecx
cmpw (%rdx), %cx
jne 0x3a05
testb $0x2, %al
je 0x2dd2
movzwl 0x2(%rsi), %ecx
cmpw 0x2(%rdx), %cx
jne 0x3a0e
testb $0x4, %al
je 0x2de4
movzwl 0x4(%rsi), %ecx
cmpw 0x6(%rdx), %cx
jne 0x3a17
testb $0x8, %al
je 0x2df6
movzwl 0x6(%rsi), %ecx
cmpw 0x8(%rdx), %cx
jne 0x3a20
testb $0x10, %al
je 0x2e08
movzbl 0x8(%rsi), %ecx
cmpw %cx, 0x4(%rdx)
jne 0x3a29
testb $0x20, %al
je 0x2e1a
movzbl 0x9(%rsi), %eax
cmpw %ax, 0xa(%rdx)
jne 0x3a32
movl 0x14(%rsi), %eax
bswapl %eax
cmpq %rax, %r13
jne 0x39d2
movzwl 0x18(%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
addl $-0x20, %r13d
testl %r13d, %r13d
jle 0x2e7f
leaq 0x20(%rsi), %rdx
xorl %ecx, %ecx
movsbl (%rdx), %esi
shll $0x8, %esi
xorl %esi, %ecx
movl $0x8, %esi
movl %ecx, %edi
addl %ecx, %edi
movl %edi, %r8d
xorl $0x1021, %r8d           # imm = 0x1021
testw %cx, %cx
movl %r8d, %ecx
cmovnsl %edi, %ecx
decl %esi
jne 0x2e4f
leal -0x1(%r13), %esi
incq %rdx
cmpl $0x2, %r13d
movl %esi, %r13d
jge 0x2e42
movzwl %cx, %ecx
jmp 0x2e81
xorl %ecx, %ecx
cmpl %eax, %ecx
jne 0x39db
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
testb $0x1, %al
je 0x2efe
leaq 0x3be7(%rip), %rdi      # 0x6a89
callq 0x2070
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
testl %ebp, %ebp
setne %cl
testb $0x1, %al
je 0x2ef6
testl %ebp, %ebp
je 0x2ef6
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r14d
setb %cl
testb $0x1, %al
je 0x2ef6
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jb 0x2ec8
testb %cl, %cl
je 0x3a45
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
leaq 0x70(%rsp), %rdx
movb $0x1, (%rdx)
leaq 0xc(%rsp), %r8
movl $0xffffffff, (%r8)      # imm = 0xFFFFFFFF
movl $0x1, %ecx
movl $0x4, %r9d
movl %ebx, %edi
movl $0x16, %esi
callq 0x461f
cmpq $0x4, %rax
jne 0x39e4
movl 0xc(%rsp), %edx
testl %edx, %edx
jne 0x39f7
leaq 0x3b5b(%rip), %rdi      # 0x6ab4
callq 0x2070
movq 0x605b(%rip), %r12      # 0x8fc0
movq (%r12), %rdi
callq 0x2160
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
testl %ebp, %ebp
setne %cl
testb $0x1, %al
je 0x2fbd
testl %ebp, %ebp
je 0x2fbd
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r14d
setb %cl
testb $0x1, %al
je 0x2fbd
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jb 0x2f8f
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x2ff4
movl $0x71, %edx
callq 0x2b2d
testb $0x4, %al
jne 0x31dc
movl %ebx, %edi
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x250f(%rip), %rdi      # 0x54fe
jmp 0x31ba
movl $0x61, %edx
callq 0x2b2d
movzbl %al, %r14d
movl %ebx, %edi
xorl %esi, %esi
movl $0x62, %edx
callq 0x2b2d
movzbl %al, %esi
shll $0x8, %esi
orl %r14d, %esi
leaq 0x24b6(%rip), %rdi      # 0x54d6
xorl %eax, %eax
callq 0x20b0
movl %ebx, %edi
xorl %esi, %esi
movl $0x43, %edx
movl $0x10, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
testl %r15d, %r15d
setne %cl
testb $0x1, %al
je 0x308b
testl %r15d, %r15d
je 0x308b
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %r15d, %r14d
setb %cl
testb $0x1, %al
je 0x308b
leal 0x1(%r14), %eax
cmpl %r15d, %r14d
movl %eax, %r14d
jb 0x305d
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x30bb
movl $0x71, %edx
callq 0x2b2d
testb $0x10, %al
jne 0x30ee
movl %ebx, %edi
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x2654(%rip), %rdi      # 0x570d
jmp 0x30e7
movl $0x61, %edx
callq 0x2b2d
movzbl %al, %r14d
movl %ebx, %edi
xorl %esi, %esi
movl $0x62, %edx
callq 0x2b2d
movzbl %al, %esi
shll $0x8, %esi
orl %r14d, %esi
leaq 0x260a(%rip), %rdi      # 0x56f1
xorl %eax, %eax
callq 0x20b0
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x4a, %edx
xorl %ecx, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
testl %ebp, %ebp
setne %cl
testb $0x1, %al
je 0x3160
testl %ebp, %ebp
je 0x3160
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r14d
setb %cl
testb $0x1, %al
je 0x3160
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jb 0x3132
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x3190
movl $0x71, %edx
callq 0x2b2d
testb $0x4, %al
je 0x31c1
movl %ebx, %edi
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x25f5(%rip), %rdi      # 0x5783
jmp 0x31ba
movl $0x61, %edx
callq 0x2b2d
movzbl %al, %ebp
movl %ebx, %edi
xorl %esi, %esi
movl $0x62, %edx
callq 0x2b2d
movzbl %al, %esi
shll $0x8, %esi
orl %ebp, %esi
leaq 0x259e(%rip), %rdi      # 0x5758
xorl %eax, %eax
callq 0x20b0
movq 0x28(%rsp), %rdi
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x4a, %edx
movl $0x2, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
testl %ebp, %ebp
setne %cl
testb $0x1, %al
je 0x3251
testl %ebp, %ebp
je 0x3251
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r14d
setb %cl
testb $0x1, %al
je 0x3251
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jb 0x3223
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x3829
movl $0x71, %edx
callq 0x2b2d
movl %ebx, %edi
testb $0x2, %al
jne 0x385a
movl $0x3, %esi
movl $0x4, %edx
movl $0x1, %ecx
callq 0x3b94
movq 0x58(%rsp), %rdx
testl %edx, %edx
jle 0x3674
movl 0x1c(%rsp), %eax
movl %eax, %r14d
shll $0x5, %r14d
testl %ebp, %ebp
setne 0x10(%rsp)
movl %eax, %eax
movq %rax, 0x40(%rsp)
movl %edx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x60(%rsp)
leaq 0x22a3(%rip), %rdi      # 0x5561
movq $0x0, 0x38(%rsp)
xorl %esi, %esi
movl %r14d, 0x4c(%rsp)
xorl %eax, %eax
movq %rsi, %r13
callq 0x20a0
movq (%r12), %rdi
callq 0x2160
movl %r14d, %eax
imull %r13d, %eax
movq %r13, 0x20(%rsp)
movl %r13d, %r14d
shrl $0x8, %r14d
movq 0x28(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x34(%rsp)
cmpl $0x0, 0x1c(%rsp)
je 0x33a8
movq 0x38(%rsp), %r12
xorl %r13d, %r13d
movl $0x20, 0x70(%rsp)
movq 0x20(%rsp), %rax
movb %al, 0x74(%rsp)
movb %r14b, 0x75(%rsp)
movb %r13b, 0x76(%rsp)
movl %r12d, %eax
andl $-0x20, %eax
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
leaq 0x77(%rsp), %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movl $0x27, %ecx
movl $0x4, %r9d
movl %ebx, %edi
movl $0x17, %esi
leaq 0x70(%rsp), %rdx
leaq 0xc(%rsp), %r8
callq 0x461f
cmpq $0x4, %rax
jne 0x3875
movl 0xc(%rsp), %esi
testl %esi, %esi
jne 0x3888
incq %r13
addq $0x20, %r12
cmpq %r13, 0x40(%rsp)
movq 0x28(%rsp), %rcx
jne 0x331c
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x4a, %edx
movl $0x4, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
movb 0x10(%rsp), %cl
testb $0x1, %al
je 0x3421
movb 0x10(%rsp), %cl
testl %ebp, %ebp
je 0x3421
movl $0x1, %r12d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r12d
setb %cl
testb $0x1, %al
je 0x3421
leal 0x1(%r12), %eax
cmpl %ebp, %r12d
movl %eax, %r12d
jb 0x33f2
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x38ca
movl $0x71, %edx
callq 0x2b2d
movl %ebx, %edi
testb $0x2, %al
jne 0x38e3
movl $0x3, %esi
movl $0x40, %edx
callq 0x2b2d
movl %eax, %r13d
movl %ebx, %edi
movl $0x3, %esi
movl $0x41, %edx
callq 0x2b2d
cmpl $0x0, 0x1c(%rsp)
je 0x34bb
xorl %ecx, %ecx
movq 0x50(%rsp), %rdx
movq 0x68(%rsp), %rsi
movq 0x5b42(%rip), %r12      # 0x8fc0
movsbl (%rsi), %edi
shll $0x8, %edi
xorl %edi, %ecx
movl $0x8, %edi
movl %ecx, %r8d
addl %ecx, %r8d
movl %r8d, %r9d
xorl $0x1021, %r9d           # imm = 0x1021
testw %cx, %cx
movl %r9d, %ecx
cmovnsl %r8d, %ecx
decl %edi
jne 0x348b
leal -0x1(%rdx), %edi
incq %rsi
cmpl $0x2, %edx
movl %edi, %edx
jge 0x347e
movzwl %cx, %ecx
jmp 0x34c4
xorl %ecx, %ecx
movq 0x5afc(%rip), %r12      # 0x8fc0
movzbl %r13b, %edx
movzbl %al, %eax
shll $0x8, %eax
orl %edx, %eax
cmpl %eax, %ecx
je 0x34fd
movl 0x34(%rsp), %eax
cmpl $0x2, %eax
je 0x38fe
incl %eax
movl %eax, 0x34(%rsp)
leaq 0x369a(%rip), %rdi      # 0x6b88
callq 0x2070
movq 0x28(%rsp), %rcx
jmp 0x3309
cmpq $0x0, 0x20(%rsp)
jne 0x35ab
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x4a, %edx
movl $0x10, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
movb 0x10(%rsp), %cl
testb $0x1, %al
je 0x3581
movb 0x10(%rsp), %cl
testl %ebp, %ebp
je 0x3581
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r14d
setb %cl
testb $0x1, %al
je 0x3581
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jb 0x3553
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x3947
movl $0x71, %edx
callq 0x2b2d
testb $0x2, %al
jne 0x3960
leaq 0x35be(%rip), %rdi      # 0x6b64
callq 0x2070
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x4a, %edx
movl $0x8, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
movb 0x10(%rsp), %cl
testb $0x1, %al
je 0x3623
movb 0x10(%rsp), %cl
testl %ebp, %ebp
je 0x3623
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r14d
setb %cl
testb $0x1, %al
je 0x3623
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jb 0x35f5
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x3911
movl $0x71, %edx
callq 0x2b2d
testb $0x2, %al
movl 0x4c(%rsp), %r14d
jne 0x392a
movq 0x20(%rsp), %rsi
incq %rsi
movq 0x38(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0x1ef3(%rip), %rdi      # 0x5561
jne 0x32ce
movl %ebx, %edi
movl $0x3, %esi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x3b94
leaq 0x3446(%rip), %rdi      # 0x6ad4
callq 0x2070
movq (%r12), %rdi
callq 0x2160
leaq 0x200a(%rip), %rdi      # 0x56ad
xorl %eax, %eax
callq 0x20a0
movq (%r12), %rdi
callq 0x2160
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x4a, %edx
movl $0x20, %ecx
callq 0x3b94
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
testl %ebp, %ebp
setne %cl
testb $0x1, %al
je 0x3728
testl %ebp, %ebp
je 0x3728
movl $0x1, %r14d
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x21c0
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x2b2d
cmpl %ebp, %r14d
setb %cl
testb $0x1, %al
je 0x3728
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jb 0x36fa
movl %ebx, %edi
xorl %esi, %esi
testb %cl, %cl
je 0x3894
movl $0x71, %edx
callq 0x2b2d
testb $0x2, %al
jne 0x38ad
leaq 0x33ac(%rip), %rdi      # 0x6af9
callq 0x2070
movq (%r12), %rdi
callq 0x2160
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
leaq 0xc(%rsp), %r8
movl $0xffffffff, (%r8)      # imm = 0xFFFFFFFF
movl $0x4, %r9d
movl %ebx, %edi
movl $0x18, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x461f
cmpq $0x4, %rax
jne 0x3a72
movl 0xc(%rsp), %edx
testl %edx, %edx
jne 0x3a7e
leaq 0x336f(%rip), %rdi      # 0x6b1c
callq 0x2070
movq (%r12), %rdi
callq 0x2160
movl %ebx, %edi
xorl %esi, %esi
movl $0x41, %edx
movl $0x2, %ecx
callq 0x3b94
leaq 0x70(%rsp), %rdx
movb $0x1, (%rdx)
leaq 0xc(%rsp), %r8
movl $0xffffffff, (%r8)      # imm = 0xFFFFFFFF
movl $0x1, %ecx
movl $0x4, %r9d
movl %ebx, %edi
movl $0x19, %esi
callq 0x461f
cmpq $0x4, %rax
jne 0x3a8a
movl 0xc(%rsp), %edx
testl %edx, %edx
jne 0x3a96
leaq 0x3327(%rip), %rdi      # 0x6b3d
callq 0x2070
movq (%r12), %rdi
callq 0x2160
jmp 0x31c1
movl $0x61, %edx
callq 0x2b2d
movzbl %al, %r14d
movl %ebx, %edi
xorl %esi, %esi
movl $0x62, %edx
callq 0x2b2d
movzbl %al, %esi
shll $0x8, %esi
orl %r14d, %esi
leaq 0x1cd3(%rip), %rdi      # 0x5528
jmp 0x3020
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x1cd5(%rip), %rdi      # 0x5545
jmp 0x30e7
leaq 0x1ced(%rip), %rdi      # 0x5569
xorl %eax, %eax
callq 0x2060
jmp 0x30ee
leaq 0x1d03(%rip), %rdi      # 0x5592
jmp 0x30e7
movl $0x61, %edx
callq 0x46d7
movzwl %ax, %esi
leaq 0x1e23(%rip), %rdi      # 0x56cb
jmp 0x3020
movl %ebx, %edi
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x1e6e(%rip), %rdi      # 0x5733
jmp 0x30e7
movl $0x61, %edx
callq 0x46d7
movzwl %ax, %esi
leaq 0x1cdd(%rip), %rdi      # 0x55bb
jmp 0x3020
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x1ceb(%rip), %rdi      # 0x55e4
jmp 0x30e7
leaq 0x1d07(%rip), %rdi      # 0x560c
xorl %eax, %eax
callq 0x20b0
jmp 0x30ee
movl $0x61, %edx
callq 0x46d7
movzwl %ax, %esi
leaq 0x1d4d(%rip), %rdi      # 0x5672
jmp 0x3020
movl %ebx, %edi
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x1d4e(%rip), %rdi      # 0x5690
jmp 0x30e7
movl $0x61, %edx
callq 0x46d7
movzwl %ax, %esi
leaq 0x1cca(%rip), %rdi      # 0x5625
jmp 0x3020
movl %ebx, %edi
xorl %esi, %esi
movl $0x71, %edx
callq 0x2b2d
movzbl %al, %esi
leaq 0x1cd4(%rip), %rdi      # 0x564c
jmp 0x30e7
leaq 0x18be(%rip), %rsi      # 0x5242
jmp 0x398d
leaq 0x18d3(%rip), %rsi      # 0x5260
movl $0x42, %edi
jmp 0x39c6
leaq 0x18e3(%rip), %rsi      # 0x527e
movl $0x42, %edi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2090
leaq 0x18eb(%rip), %rsi      # 0x529e
movl $0x47, %edi
jmp 0x39f0
leaq 0x18fc(%rip), %rsi      # 0x52bd
movl $0x47, %edi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2150
leaq 0x1a3a(%rip), %rsi      # 0x5413
jmp 0x3a39
leaq 0x1a58(%rip), %rsi      # 0x543a
jmp 0x3a39
leaq 0x1aa1(%rip), %rsi      # 0x548c
movl $0x42, %edi
xorl %eax, %eax
callq 0x2150
leaq 0x1ab3(%rip), %rsi      # 0x54b1
movl $0x42, %edi
jmp 0x3a62
leaq 0x1920(%rip), %rsi      # 0x532c
jmp 0x3a39
leaq 0x196b(%rip), %rsi      # 0x5380
jmp 0x3a39
leaq 0x18e5(%rip), %rsi      # 0x5303
jmp 0x3a39
leaq 0x1930(%rip), %rsi      # 0x5357
jmp 0x3a39
leaq 0x1979(%rip), %rsi      # 0x53a9
jmp 0x3a39
leaq 0x1994(%rip), %rsi      # 0x53cd
movl $0x42, %edi
xorl %eax, %eax
callq 0x2090
movl %ebx, %edi
xorl %esi, %esi
movl $0x61, %edx
callq 0x46d7
movzwl %ax, %edx
leaq 0x1a08(%rip), %rsi      # 0x5465
movl $0x4c, %edi
xorl %eax, %eax
callq 0x2090
leaq 0x186b(%rip), %rsi      # 0x52db
jmp 0x39fe
leaq 0x1d33(%rip), %rsi      # 0x57ac
jmp 0x39eb
leaq 0x1d4d(%rip), %rsi      # 0x57d2
jmp 0x39fe
leaq 0x1d67(%rip), %rsi      # 0x57f8
jmp 0x39eb
leaq 0x1d85(%rip), %rsi      # 0x5822
jmp 0x39fe