// File: /workspace/github_c_makefile_star2_O3/lb3361[P]dosfs/ff.c
// Function: create_partition
static FRESULT create_partition (
	BYTE drv,			/* Physical drive number */
	const LBA_t plst[],	/* Partition list */
	BYTE sys,			/* System ID (for only MBR, temp setting) */
	BYTE* buf			/* Working buffer for a sector */
)
{
	UINT i, cy;
	LBA_t sz_drv;
	DWORD sz_drv32, s_lba32, n_lba32;
	BYTE *pte, hd, n_hd, sc, n_sc;

	/* Get drive size */
	if (disk_ioctl(drv, GET_SECTOR_COUNT, &sz_drv) != RES_OK) return FR_DISK_ERR;

#if FF_LBA64
	if (sz_drv >= FF_MIN_GPT) {	/* Create partitions in GPT */
		WORD ss;
		UINT sz_pt, pi, si, ofs;
		DWORD bcc, rnd, align;
		QWORD s_lba64, n_lba64, sz_pool, s_bpt;
		static const BYTE gpt_mbr[16] = {0x00, 0x00, 0x02, 0x00, 0xEE, 0xFE, 0xFF, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};

#if FF_MAX_SS != FF_MIN_SS
		if (disk_ioctl(drv, GET_SECTOR_SIZE, &ss) != RES_OK) return FR_DISK_ERR;	/* Get sector size */
		if (ss > FF_MAX_SS || ss < FF_MIN_SS || (ss & (ss - 1))) return FR_DISK_ERR;
#else
		ss = FF_MAX_SS;
#endif
		rnd = GET_FATTIME();			/* Random seed */
		align = GPT_ALIGN / ss;			/* Partition alignment [sector] */
		sz_pt = GPT_ITEMS * SZ_GPTE / ss;	/* Size of PT [sector] */
		s_bpt = sz_drv - sz_pt - 1;		/* Backup PT start sector */
		s_lba64 = 2 + sz_pt;			/* First allocatable sector */
		sz_pool = s_bpt - s_lba64;		/* Size of allocatable area */
		bcc = 0xFFFFFFFF; n_lba64 = 1;
		pi = si = 0;	/* partition table index, size table index */
		do {
			if (pi * SZ_GPTE % ss == 0) mem_set(buf, 0, ss);	/* Clean the buffer if needed */
			if (n_lba64 != 0) {	/* Is the size table not termintated? */
				s_lba64 = (s_lba64 + align - 1) & ((QWORD)0 - align);	/* Align partition start */
				n_lba64 = plst[si++];	/* Get a partition size */
				if (n_lba64 <= 100) {	/* Is the size in percentage? */
					n_lba64 = sz_pool * n_lba64 / 100;
					n_lba64 = (n_lba64 + align - 1) & ((QWORD)0 - align);	/* Align partition end (only if in percentage) */
				}
				if (s_lba64 + n_lba64 > s_bpt) {	/* Clip at end of the pool */
					n_lba64 = (s_lba64 < s_bpt) ? s_bpt - s_lba64 : 0;
				}
			}
			if (n_lba64 != 0) {		/* Add a partition? */
				ofs = pi * SZ_GPTE % ss;
				mem_cpy(buf + ofs + GPTE_PtGuid, GUID_MS_Basic, 16);	/* Partition GUID (Microsoft Basic Data) */
				rnd = make_rand(rnd, buf + ofs + GPTE_UpGuid, 16);		/* Unique partition GUID */
				st_qword(buf + ofs + GPTE_FstLba, s_lba64);				/* Partition start LBA */
				st_qword(buf + ofs + GPTE_LstLba, s_lba64 + n_lba64 - 1);	/* Partition end LBA */
				s_lba64 += n_lba64;		/* Next partition LBA */
			}
			if ((pi + 1) * SZ_GPTE % ss == 0) {		/* Write the buffer if it is filled up */
				for (i = 0; i < ss; bcc = crc32(bcc, buf[i++])) ;	/* Calculate table check sum */
				if (disk_write(drv, buf, 2 + pi * SZ_GPTE / ss, 1) != RES_OK) return FR_DISK_ERR;		/* Primary table */
				if (disk_write(drv, buf, s_bpt + pi * SZ_GPTE / ss, 1) != RES_OK) return FR_DISK_ERR;	/* Secondary table */
			}
		} while (++pi < GPT_ITEMS);

		/* Create primary GPT header */
		mem_set(buf, 0, ss);
		mem_cpy(buf + GPTH_Sign, "EFI PART" "\0\0\1\0" "\x5C\0\0", 16);	/* Signature, version (1.0) and size (92) */
		st_dword(buf + GPTH_PtBcc, ~bcc);				/* Table check sum */
		st_qword(buf + GPTH_CurLba, 1);					/* LBA of this header */
		st_qword(buf + GPTH_BakLba, sz_drv - 1);		/* LBA of another header */
		st_qword(buf + GPTH_FstLba, 2 + sz_pt);			/* LBA of first allocatable sector */
		st_qword(buf + GPTH_LstLba, s_bpt - 1);			/* LBA of last allocatable sector */
		st_dword(buf + GPTH_PteSize, SZ_GPTE);			/* Size of a table entry */
		st_dword(buf + GPTH_PtNum, GPT_ITEMS);			/* Number of table entries */
		st_dword(buf + GPTH_PtOfs, 2);					/* LBA of this table */
		rnd = make_rand(rnd, buf + GPTH_DskGuid, 16);	/* Disk GUID */
		for (i = 0, bcc= 0xFFFFFFFF; i < 92; bcc = crc32(bcc, buf[i++])) ;	/* Calculate header check sum */
		st_dword(buf + GPTH_Bcc, ~bcc);					/* Header check sum */
		if (disk_write(drv, buf, 1, 1) != RES_OK) return FR_DISK_ERR;

		/* Create secondary GPT header */
		st_qword(buf + GPTH_CurLba, sz_drv - 1);		/* LBA of this header */
		st_qword(buf + GPTH_BakLba, 1);					/* LBA of another header */
		st_qword(buf + GPTH_PtOfs, s_bpt);				/* LBA of this table */
		st_dword(buf + GPTH_Bcc, 0);
		for (i = 0, bcc= 0xFFFFFFFF; i < 92; bcc = crc32(bcc, buf[i++])) ;	/* Calculate header check sum */
		st_dword(buf + GPTH_Bcc, ~bcc);					/* Header check sum */
		if (disk_write(drv, buf, sz_drv - 1, 1) != RES_OK) return FR_DISK_ERR;

		/* Create protective MBR */
		mem_set(buf, 0, ss);
		mem_cpy(buf + MBR_Table, gpt_mbr, 16);			/* Create a GPT partition */
		st_word(buf + BS_55AA, 0xAA55);
		if (disk_write(drv, buf, 0, 1) != RES_OK) return FR_DISK_ERR;

	} else
#endif
	{					/* Create partitions in MBR */
		sz_drv32 = (DWORD)sz_drv;
		n_sc = N_SEC_TRACK;		/* Determine drive CHS without any consideration of the drive geometry */
		for (n_hd = 8; n_hd != 0 && sz_drv32 / n_hd / n_sc > 1024; n_hd *= 2) ;
		if (n_hd == 0) n_hd = 255;	/* Number of heads needs to be <256 */

		mem_set(buf, 0, FF_MAX_SS);	/* Clear MBR */
		pte = buf + MBR_Table;	/* Partition table in the MBR */
		for (i = 0, s_lba32 = n_sc; i < 4 && s_lba32 != 0 && s_lba32 < sz_drv32; i++, s_lba32 += n_lba32) {
			n_lba32 = (DWORD)plst[i];	/* Get partition size */
			if (n_lba32 <= 100) n_lba32 = (n_lba32 == 100) ? sz_drv32 : sz_drv32 / 100 * n_lba32;	/* Size in percentage? */
			if (s_lba32 + n_lba32 > sz_drv32 || s_lba32 + n_lba32 < s_lba32) n_lba32 = sz_drv32 - s_lba32;	/* Clip at drive size */
			if (n_lba32 == 0) break;	/* End of table or no sector to allocate? */

			st_dword(pte + PTE_StLba, s_lba32);		/* Start LBA */
			st_dword(pte + PTE_SizLba, n_lba32);	/* Number of sectors */
			pte[PTE_System] = sys;					/* System type */

			cy = (UINT)(s_lba32 / n_sc / n_hd);		/* Start cylinder */
			hd = (BYTE)(s_lba32 / n_sc % n_hd);		/* Start head */
			sc = (BYTE)(s_lba32 % n_sc + 1);		/* Start sector */
			pte[PTE_StHead] = hd;
			pte[PTE_StSec] = (BYTE)((cy >> 2 & 0xC0) | sc);
			pte[PTE_StCyl] = (BYTE)cy;

			cy = (UINT)((s_lba32 + n_lba32 - 1) / n_sc / n_hd);	/* End cylinder */
			hd = (BYTE)((s_lba32 + n_lba32 - 1) / n_sc % n_hd);	/* End head */
			sc = (BYTE)((s_lba32 + n_lba32 - 1) % n_sc + 1);	/* End sector */
			pte[PTE_EdHead] = hd;
			pte[PTE_EdSec] = (BYTE)((cy >> 2 & 0xC0) | sc);
			pte[PTE_EdCyl] = (BYTE)cy;

			pte += SZ_PTE;		/* Next entry */
		}

		st_word(buf + BS_55AA, 0xAA55);		/* MBR signature */
		if (disk_write(drv, buf, 0, 1) != RES_OK) return FR_DISK_ERR;	/* Write it to the MBR */
	}

	return FR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x8(%rsp)
movl %edx, %r15d
movq %rsi, 0x28(%rsp)
movl %edi, %ebp
movl $0x1, %r12d
leaq 0x18(%rsp), %rdx
movl $0x1, %esi
callq 0x2dfa
testl %eax, %eax
je 0xaafe
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %r12
movzbl %bpl, %eax
movl %eax, 0x4(%rsp)
cmpq $0x10000000, %r12       # imm = 0x10000000
jb 0xb03f
callq 0x2e66
movl %eax, %r15d
movq 0x18(%rsp), %rcx
leaq -0x21(%rcx), %rax
movq %rax, 0x20(%rsp)
movq %rcx, 0x30(%rsp)
leaq -0x43(%rcx), %rax
movq %rax, 0x38(%rsp)
movl $0x1, %r14d
movl $0x22, %r12d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movl $0x0, 0x14(%rsp)
movl %r13d, %ebx
shll $0x7, %ebx
andl $0x180, %ebx            # imm = 0x180
jne 0xab77
movl $0x200, %edx            # imm = 0x200
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x2110
testq %r14, %r14
je 0xacf2
movl 0x14(%rsp), %esi
movl %esi, %eax
movq 0x28(%rsp), %rcx
movq (%rcx,%rax,8), %rax
cmpq $0x64, %rax
ja 0xabbf
imulq 0x38(%rsp), %rax
shrq $0x2, %rax
movabsq $0x28f5c28f5c28f5c3, %rcx # imm = 0x28F5C28F5C28F5C3
mulq %rcx
movq %rdx, %rax
shrq $0x2, %rax
addq $0x7ff, %rax            # imm = 0x7FF
andq $-0x800, %rax           # imm = 0xF800
addq $0x7ff, %r12            # imm = 0x7FF
movq %r12, %rcx
andq $-0x800, %rcx           # imm = 0xF800
incl %esi
movl %esi, 0x14(%rsp)
leaq (%rax,%rcx), %rdx
movq 0x20(%rsp), %rsi
movq %rsi, %r14
subq %rcx, %r14
movl $0x0, %edi
cmovbq %rdi, %r14
cmpq %rsi, %rdx
cmovbeq %rax, %r14
testq %r14, %r14
je 0xacf7
movl %r13d, %edx
andl $0x3, %edx
shll $0x7, %edx
movq 0x8(%rsp), %rsi
addq %rsi, %rdx
movl %ebx, %eax
addq %rsi, %rax
xorl %esi, %esi
leaq 0x2873(%rip), %r8       # 0xd490
movb (%rsi,%r8), %dil
movb %dil, (%rdx,%rsi)
incq %rsi
cmpl $0x10, %esi
jne 0xac1d
leaq 0x10(%rax), %rdx
cmpl $0x1, %r15d
adcl $0x0, %r15d
movl $0x10, %esi
movl $0x8, %edi
movl %r15d, %r8d
shrl %r8d
movl %r8d, %r9d
xorl $0xa3000000, %r9d       # imm = 0xA3000000
testb $0x1, %r15b
movl %r9d, %r15d
cmovel %r8d, %r15d
decl %edi
jne 0xac43
movb %r15b, (%rdx)
incq %rdx
decl %esi
jne 0xac3e
movb $0x0, 0x20(%rax)
movb %ch, 0x21(%rax)
movl %r12d, %edx
shrl $0x10, %edx
movb %dl, 0x22(%rax)
movl %r12d, %edx
shrl $0x18, %edx
movb %dl, 0x23(%rax)
movq %r12, %rdx
shrq $0x20, %rdx
movb %dl, 0x24(%rax)
movq %r12, %rdx
shrq $0x28, %rdx
movb %dl, 0x25(%rax)
movq %r12, %rdx
shrq $0x30, %rdx
movb %dl, 0x26(%rax)
shrq $0x38, %r12
movb %r12b, 0x27(%rax)
leaq (%r14,%rcx), %r12
addq %r14, %rcx
decq %rcx
movb %cl, 0x28(%rax)
movb %ch, 0x29(%rax)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x2a(%rax)
movl %ecx, %edx
shrl $0x18, %edx
movb %dl, 0x2b(%rax)
movq %rcx, %rdx
shrq $0x20, %rdx
movb %dl, 0x2c(%rax)
movq %rcx, %rdx
shrq $0x28, %rdx
movb %dl, 0x2d(%rax)
movq %rcx, %rdx
shrq $0x30, %rdx
movb %dl, 0x2e(%rax)
shrq $0x38, %rcx
movb %cl, 0x2f(%rax)
jmp 0xacfd
xorl %r14d, %r14d
jmp 0xacfd
xorl %r14d, %r14d
movq %rcx, %r12
leal 0x1(%r13), %ebx
testb $0x3, %bl
movq %r12, 0x40(%rsp)
jne 0xad98
xorl %eax, %eax
movq 0x8(%rsp), %rcx
movb (%rcx,%rax), %cl
movb $0x1, %dl
testb %cl, %dl
sete %sil
xorb %bpl, %sil
movl %ebp, %edi
shrl %edi
movl %edi, %ebp
xorl $0xedb88320, %ebp       # imm = 0xEDB88320
testb $0x1, %sil
cmovnel %edi, %ebp
addb %dl, %dl
jne 0xad1b
incq %rax
cmpq $0x200, %rax            # imm = 0x200
jne 0xad11
shrl $0x2, %r13d
leal 0x2(%r13), %edx
movl $0x1, %r12d
movl 0x4(%rsp), %edi
movq 0x8(%rsp), %rsi
movl $0x1, %ecx
callq 0x2d75
testl %eax, %eax
jne 0xaaec
movl %r13d, %edx
addq 0x20(%rsp), %rdx
movl $0x1, %r12d
movl 0x4(%rsp), %edi
movq 0x8(%rsp), %rsi
movl $0x1, %ecx
callq 0x2d75
testl %eax, %eax
jne 0xaaec
movl %ebx, %r13d
cmpl $0x80, %ebx
movq 0x40(%rsp), %r12
jne 0xab58
xorl %ebx, %ebx
movl $0x200, %edx            # imm = 0x200
movq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2110
movq %r14, %rsi
leaq 0x26d4(%rip), %rax      # 0xd4a0
movb (%rbx,%rax), %cl
movb %cl, (%rsi,%rbx)
incq %rbx
cmpl $0x10, %ebx
jne 0xadcc
notl %ebp
movl %ebp, 0x58(%rsi)
movb $0x1, 0x18(%rsi)
xorl %eax, %eax
movl %eax, 0x19(%rsi)
movl %eax, 0x1c(%rsi)
movq 0x18(%rsp), %rcx
decq %rcx
leaq 0x21(%rsi), %r14
movb %cl, 0x20(%rsi)
movb %ch, 0x21(%rsi)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x22(%rsi)
movl %ecx, %edx
shrl $0x18, %edx
movb %dl, 0x23(%rsi)
movq %rcx, %rdx
shrq $0x20, %rdx
movb %dl, 0x24(%rsi)
movq %rcx, %rdx
shrq $0x28, %rdx
movb %dl, 0x25(%rsi)
movq %rcx, %rdx
shrq $0x30, %rdx
movb %dl, 0x26(%rsi)
shrq $0x38, %rcx
movb %cl, 0x27(%rsi)
movb $0x22, 0x28(%rsi)
movq 0x30(%rsp), %rdx
addq $-0x22, %rdx
movl %eax, 0x29(%rsi)
movl %eax, 0x2c(%rsi)
movb %dl, 0x30(%rsi)
movb %dh, 0x31(%rsi)
movl %edx, %ecx
shrl $0x10, %ecx
movb %cl, 0x32(%rsi)
movl %edx, %ecx
shrl $0x18, %ecx
movb %cl, 0x33(%rsi)
movq %rdx, %rcx
shrq $0x20, %rcx
movb %cl, 0x34(%rsi)
movq %rdx, %rcx
shrq $0x28, %rcx
movb %cl, 0x35(%rsi)
movq %rdx, %rcx
shrq $0x30, %rcx
movb %cl, 0x36(%rsi)
shrq $0x38, %rdx
movb %dl, 0x37(%rsi)
movabsq $0x8000000080, %rcx     # imm = 0x8000000080
movq %rcx, 0x50(%rsi)
movl $0x2, 0x48(%rsi)
leaq 0x38(%rsi), %rcx
cmpl $0x1, %r15d
adcl %eax, %r15d
movl $0x10, %eax
movl $0x8, %edx
movl %r15d, %r8d
shrl %r8d
movl %r8d, %edi
xorl $0xa3000000, %edi       # imm = 0xA3000000
testb $0x1, %r15b
movl %edi, %r15d
cmovel %r8d, %r15d
decl %edx
jne 0xaeaa
movb %r15b, (%rcx)
incq %rcx
decl %eax
jne 0xaea5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movb (%rsi,%rcx), %dl
movb $0x1, %r9b
testb %dl, %r9b
sete %dil
xorb %al, %dil
movl %eax, %r8d
shrl %r8d
movl %r8d, %eax
xorl $0xedb88320, %eax       # imm = 0xEDB88320
testb $0x1, %dil
cmovnel %r8d, %eax
addb %r9b, %r9b
jne 0xaedf
incq %rcx
cmpq $0x5c, %rcx
jne 0xaed9
notl %eax
movl %eax, 0x10(%rsi)
movl $0x1, %r12d
movl $0x1, %edx
movl 0x4(%rsp), %edi
movl $0x1, %ecx
callq 0x2d75
testl %eax, %eax
jne 0xaaec
movq 0x18(%rsp), %rdx
decq %rdx
movq 0x8(%rsp), %rsi
movb %dl, 0x18(%rsi)
movb %dh, 0x19(%rsi)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x1a(%rsi)
movl %edx, %eax
shrl $0x18, %eax
movb %al, 0x1b(%rsi)
movq %rdx, %rax
shrq $0x20, %rax
movb %al, 0x1c(%rsi)
movq %rdx, %rax
shrq $0x28, %rax
movb %al, 0x1d(%rsi)
movq %rdx, %rax
shrq $0x30, %rax
movb %al, 0x1e(%rsi)
movq %rdx, %rax
shrq $0x38, %rax
movb %al, 0x1f(%rsi)
movb $0x1, 0x20(%rsi)
xorl %eax, %eax
movl %eax, 0x3(%r14)
movl %eax, (%r14)
movq 0x20(%rsp), %rcx
movq %rcx, 0x48(%rsi)
movl %eax, 0x10(%rsi)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movb (%rsi,%rax), %r10b
movb $0x1, %dil
testb %r10b, %dil
sete %r8b
xorb %cl, %r8b
movl %ecx, %r9d
shrl %r9d
movl %r9d, %ecx
xorl $0xedb88320, %ecx       # imm = 0xEDB88320
testb $0x1, %r8b
cmovnel %r9d, %ecx
addb %dil, %dil
jne 0xafa3
incq %rax
cmpq $0x5c, %rax
jne 0xaf9c
notl %ecx
movl %ecx, 0x10(%rsi)
movl $0x1, %r12d
movl 0x4(%rsp), %edi
movl $0x1, %ecx
callq 0x2d75
testl %eax, %eax
jne 0xaaec
xorl %ebx, %ebx
movl $0x1fe, %edx            # imm = 0x1FE
movq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2110
leaq 0x24a0(%rip), %rax      # 0xd4b0
movb (%rbx,%rax), %cl
movb %cl, 0x1be(%r14,%rbx)
incq %rbx
cmpl $0x10, %ebx
jne 0xb010
movw $0xaa55, 0x1fe(%r14)    # imm = 0xAA55
movl $0x1, %r12d
movl 0x4(%rsp), %edi
movq %r14, %rsi
jmp 0xb1c0
movb $0x8, %bl
movq 0x8(%rsp), %rdi
movzbl %bl, %ecx
movl %r12d, %eax
xorl %edx, %edx
divl %ecx
cmpl $0xfc3f, %eax           # imm = 0xFC3F
jb 0xb05d
addb %bl, %bl
jne 0xb046
movb $-0x1, %bl
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x2110
cmpq $0x40, %r12
jb 0xb1a8
movl %r12d, %eax
imulq $0x51eb851f, %rax, %rsi # imm = 0x51EB851F
shrq $0x25, %rsi
movzbl %bl, %edi
movq 0x8(%rsp), %rax
leaq 0x1cd(%rax), %rbp
movl $0x3f, %edx
xorl %r8d, %r8d
movl $0xc0, %r9d
movq 0x28(%rsp), %rax
movl (%rax,%r8,8), %eax
movl %esi, %ebx
imull %eax, %ebx
cmpl $0x64, %eax
cmovel %r12d, %ebx
cmoval %eax, %ebx
movl %r12d, %eax
subl %edx, %eax
movl %ebx, %ecx
addl %edx, %ecx
cmovbl %eax, %ebx
cmpl %r12d, %ecx
cmoval %eax, %ebx
testl %ebx, %ebx
je 0xb1a8
movb %dl, -0x7(%rbp)
movb %dh, -0x6(%rbp)
movl %edx, %eax
shrl $0x10, %eax
movb %al, -0x5(%rbp)
movl %edx, %eax
shrl $0x18, %eax
movb %al, -0x4(%rbp)
movb %bl, -0x3(%rbp)
movb %bh, -0x2(%rbp)
movl %ebx, %eax
shrl $0x10, %eax
movb %al, -0x1(%rbp)
movl %ebx, %eax
shrl $0x18, %eax
movb %al, (%rbp)
movb %r15b, -0xb(%rbp)
movl %edx, %eax
imulq $0x4104105, %rax, %rax  # imm = 0x4104105
shrq $0x20, %rax
movl %edx, %ecx
subl %eax, %ecx
shrl %ecx
addl %eax, %ecx
shrl $0x5, %ecx
movq %rdx, %r14
movl %ecx, %edx
shll $0x6, %edx
movl %ecx, %eax
subl %edx, %ecx
xorl %edx, %edx
divl %edi
addl %r14d, %ecx
incl %ecx
movb %dl, -0xe(%rbp)
movl %eax, %edx
shrl $0x2, %edx
andl %r9d, %edx
orl %ecx, %edx
movb %dl, -0xd(%rbp)
movb %al, -0xc(%rbp)
addl %ebx, %r14d
movl %r14d, %r11d
addl $-0x1, %r11d
setb %r10b
imulq $0x4104105, %r11, %rax  # imm = 0x4104105
shrq $0x20, %rax
movl %r11d, %ecx
subl %eax, %ecx
shrl %ecx
addl %eax, %ecx
shrl $0x5, %ecx
movl %ecx, %edx
shll $0x6, %edx
movl %ecx, %eax
subl %edx, %ecx
xorl %edx, %edx
divl %edi
addl %r11d, %ecx
incl %ecx
movb %dl, -0xa(%rbp)
movl %eax, %edx
shrl $0x2, %edx
andl %r9d, %edx
orl %ecx, %edx
movb %dl, -0x9(%rbp)
movb %al, -0x8(%rbp)
cmpq $0x2, %r8
ja 0xb1a8
testb %r10b, %r10b
je 0xb1a8
movq %r14, %rdx
incq %r8
addq $0x10, %rbp
cmpl %r12d, %edx
jb 0xb09e
movq 0x8(%rsp), %rsi
movw $0xaa55, 0x1fe(%rsi)    # imm = 0xAA55
movl $0x1, %r12d
movl 0x4(%rsp), %edi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x2d75
testl %eax, %eax
jne 0xaaec
xorl %r12d, %r12d
jmp 0xaaec