// File: /workspace/github_c_makefile_star2_O2/spacifici[P]st/src/hb.c
// Function: hbtransform
void
hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y)
{
	int start = 0, length = 1, gstart = 0;
	hb_codepoint_t *codepoints = calloc(len, sizeof(hb_codepoint_t));

	for (int idx = 1, specidx = 1; idx < len; idx++) {
		if (glyphs[idx].mode & ATTR_WDUMMY) {
			length += 1;
			continue;
		}

		if (specs[specidx].font != specs[start].font || ATTRCMP(glyphs[gstart], glyphs[idx]) || selected(x + idx, y) != selected(x + gstart, y)) {
			hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length);

			/* Reset the sequence. */
			length = 1;
			start = specidx;
			gstart = idx;
		} else {
			length += 1;
		}

		specidx++;
	}

	/* EOL. */
	hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length);

	/* Apply the transformation to glyph specs. */
	for (int i = 0, specidx = 0; i < len; i++) {
		if (glyphs[i].mode & ATTR_WDUMMY)
			continue;

		if (codepoints[i] != specs[specidx].glyph)
			((Glyph *)glyphs)[i].mode |= ATTR_LIGA;

		specs[specidx++].glyph = codepoints[i];
	}

	free(codepoints);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, 0xc(%rsp)
movl %ecx, %r15d
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0x18(%rsp)
pushq $0x4
popq %rsi
movq %rdx, %rdi
callq 0x67e0
movq %rbx, %rdx
movq %rax, 0x28(%rsp)
movq %r15, 0x40(%rsp)
movl %r15d, %eax
movq %rax, 0x38(%rsp)
leaq 0x1c(%r14), %r12
xorl %ecx, %ecx
pushq $0x1
popq %r15
pushq $0x1
popq %rbp
movl %r15d, %r13d
xorl %r8d, %r8d
movq %rbx, 0x30(%rsp)
movslq %r8d, %rbx
cmpq %rdx, %rbp
jae 0xe24f
movzwl -0x8(%r12), %eax
btl $0xa, %eax
jb 0xe210
movslq %r15d, %rsi
shlq $0x4, %rsi
shlq $0x4, %rbx
movq 0x18(%rsp), %rdx
movq (%rdx,%rbx), %rdi
cmpq %rdi, (%rdx,%rsi)
jne 0xe222
movslq %ecx, %rsi
shlq $0x4, %rsi
movzwl 0x4(%r14,%rsi), %edx
andl $0xf6ff, %edx           # imm = 0xF6FF
andl $0xf2ff, %eax           # imm = 0xF2FF
cmpl %edx, %eax
jne 0xe222
addq %r14, %rsi
movl 0x8(%rsi), %eax
cmpl -0x4(%r12), %eax
jne 0xe222
movl 0xc(%rsi), %eax
cmpl (%r12), %eax
jne 0xe222
movl %r8d, 0x20(%rsp)
movq 0x38(%rsp), %rax
leal (%rax,%rbp), %edi
movl 0xc(%rsp), %esi
movq %rcx, 0x10(%rsp)
callq 0x6fef
movl %eax, 0x24(%rsp)
movq 0x40(%rsp), %rax
movq 0x10(%rsp), %rcx
leal (%rcx,%rax), %edi
movl 0xc(%rsp), %esi
callq 0x6fef
cmpl %eax, 0x24(%rsp)
jne 0xe215
incl %r13d
movq 0x10(%rsp), %rcx
movl 0x20(%rsp), %r8d
jmp 0xe23b
incl %r13d
jmp 0xe243
addq 0x18(%rsp), %rbx
movq (%rbx), %rdi
movq 0x10(%rsp), %rcx
movq %r14, %rsi
movq 0x28(%rsp), %rdx
movl %r13d, %r8d
callq 0xe2d3
pushq $0x1
popq %r13
movl %ebp, %ecx
movl %r15d, %r8d
incl %r15d
movq 0x30(%rsp), %rdx
incq %rbp
addq $0x10, %r12
jmp 0xe15a
shlq $0x4, %rbx
movq 0x18(%rsp), %rax
movq (%rax,%rbx), %rdi
movq %rax, %rbx
movq %r14, %rsi
movq 0x28(%rsp), %r15
movq %r15, %rdx
movl %r13d, %r8d
callq 0xe2d3
movq 0x30(%rsp), %r8
addq $0x4, %r14
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %rax, %r8
je 0xe2bd
movl (%r14), %esi
btl $0xa, %esi
jb 0xe2b4
movl (%r15,%rax,4), %edx
movslq %ecx, %rdi
shlq $0x4, %rdi
cmpl 0x8(%rbx,%rdi), %edx
je 0xe2a8
orl $0x800, %esi            # imm = 0x800
movw %si, (%r14)
leaq (%rbx,%rdi), %rsi
addq $0x8, %rsi
incl %ecx
movl %edx, (%rsi)
incq %rax
addq $0x10, %r14
jmp 0xe27f
movq %r15, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6360