// File: /workspace/github_c_makefile_star2_O2/mrdotx[P]st/x.c
// Function: xmakeglyphfontspecs
int
xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
{
	float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
	ushort mode, prevmode = USHRT_MAX;
	Font *font = &dc.font;
	int frcflags = FRC_NORMAL;
	float runewidth = win.cw;
	Rune rune;
	FT_UInt glyphidx;
	FcResult fcres;
	FcPattern *fcpattern, *fontpattern;
	FcFontSet *fcsets[] = { NULL };
	FcCharSet *fccharset;
	int i, f, numspecs = 0;

	for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) {
		/* Fetch rune and mode for current glyph. */
		rune = glyphs[i].u;
		mode = glyphs[i].mode;

		/* Skip dummy wide-character spacing. */
		if (mode == ATTR_WDUMMY)
			continue;

		/* Determine font for glyph if different from previous glyph. */
		if (prevmode != mode) {
			prevmode = mode;
			font = &dc.font;
			frcflags = FRC_NORMAL;
			runewidth = win.cw * ((mode & ATTR_WIDE) ? 2.0f : 1.0f);
			if ((mode & ATTR_ITALIC) && (mode & ATTR_BOLD)) {
				font = &dc.ibfont;
				frcflags = FRC_ITALICBOLD;
			} else if (mode & ATTR_ITALIC) {
				font = &dc.ifont;
				frcflags = FRC_ITALIC;
			} else if (mode & ATTR_BOLD) {
				font = &dc.bfont;
				frcflags = FRC_BOLD;
			}
			yp = winy + font->ascent;
		}

		if (mode & ATTR_BOXDRAW) {
			/* minor shoehorning: boxdraw uses only this ushort */
			glyphidx = boxdrawindex(&glyphs[i]);
		} else {
			/* Lookup character index with default font. */
			glyphidx = XftCharIndex(xw.dpy, font->match, rune);
		}
		if (glyphidx) {
			specs[numspecs].font = font->match;
			specs[numspecs].glyph = glyphidx;
			specs[numspecs].x = (short)xp;
			specs[numspecs].y = (short)yp;
			xp += runewidth;
			numspecs++;
			continue;
		}

		/* Fallback on font cache, search the font cache for match. */
		for (f = 0; f < frclen; f++) {
			glyphidx = XftCharIndex(xw.dpy, frc[f].font, rune);
			/* Everything correct. */
			if (glyphidx && frc[f].flags == frcflags)
				break;
			/* We got a default font for a not found glyph. */
			if (!glyphidx && frc[f].flags == frcflags
					&& frc[f].unicodep == rune) {
				break;
			}
		}

		/* Nothing was found. Use fontconfig to find matching font. */
		if (f >= frclen) {
			if (!font->set)
				font->set = FcFontSort(0, font->pattern,
				                       1, 0, &fcres);
			fcsets[0] = font->set;

			/*
			 * Nothing was found in the cache. Now use
			 * some dozen of Fontconfig calls to get the
			 * font for one single character.
			 *
			 * Xft and fontconfig are design failures.
			 */
			fcpattern = FcPatternDuplicate(font->pattern);
			fccharset = FcCharSetCreate();

			FcCharSetAddChar(fccharset, rune);
			FcPatternAddCharSet(fcpattern, FC_CHARSET,
					fccharset);
			FcPatternAddBool(fcpattern, FC_SCALABLE, 1);

			FcConfigSubstitute(0, fcpattern,
					FcMatchPattern);
			FcDefaultSubstitute(fcpattern);

			fontpattern = FcFontSetMatch(0, fcsets, 1,
					fcpattern, &fcres);

			/* Allocate memory for the new cache entry. */
			if (frclen >= frccap) {
				frccap += 16;
				frc = xrealloc(frc, frccap * sizeof(Fontcache));
			}

			frc[frclen].font = XftFontOpenPattern(xw.dpy,
					fontpattern);
			if (!frc[frclen].font)
				die("XftFontOpenPattern failed seeking fallback font: %s\n",
					strerror(errno));
			frc[frclen].flags = frcflags;
			frc[frclen].unicodep = rune;

			glyphidx = XftCharIndex(xw.dpy, frc[frclen].font, rune);

			f = frclen;
			frclen++;

			FcPatternDestroy(fcpattern);
			FcCharSetDestroy(fccharset);
		}

		specs[numspecs].font = frc[f].font;
		specs[numspecs].glyph = glyphidx;
		specs[numspecs].x = (short)xp;
		specs[numspecs].y = (short)yp;
		xp += runewidth;
		numspecs++;
	}

	return numspecs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl 0xc755(%rip), %eax      # 0x18e04
movl 0x1055e(%rip), %r9d     # 0x1cc14
imull %r9d, %ecx
addl %eax, %ecx
cvtsi2ss %ecx, %xmm0
movaps %xmm0, 0x60(%rsp)
movl %edx, %r14d
imull 0x10540(%rip), %r8d     # 0x1cc10
addl %eax, %r8d
cvtsi2ss %r8d, %xmm0
movq %rsi, %r15
cvtsi2ss %r9d, %xmm1
movss %xmm1, 0x4(%rsp)
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
movq %rdi, 0x48(%rsp)
cvtsi2ssl 0x10314(%rip), %xmm1 # 0x1ca10
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %r14d
movss %xmm0, 0x10(%rsp)
addss %xmm0, %xmm1
movaps %xmm1, 0x50(%rsp)
movw $0xffff, 0x2(%rsp)      # imm = 0xFFFF
leaq 0x102e7(%rip), %rax     # 0x1ca08
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movq %r14, 0x40(%rsp)
movq %rsi, 0x18(%rsp)
cmpq %r14, %r12
je 0xca91
movq %r12, %rdi
shlq $0x4, %rdi
movzwl 0x4(%r15,%rdi), %r9d
cmpl $0x400, %r9d            # imm = 0x400
je 0xca89
movq %rax, 0x20(%rsp)
cmpw %r9w, 0x2(%rsp)
je 0xc7f5
cvtsi2ssl 0x104a1(%rip), %xmm0 # 0x1cc14
xorl %ecx, %ecx
btl $0x9, %r9d
setae %cl
leaq 0x54dc(%rip), %rdx      # 0x11c60
mulss (%rdx,%rcx,4), %xmm0
movss %xmm0, 0x4(%rsp)
movl %r9d, %ecx
andl $0x1, %ecx
movl %r9d, %edx
notl %edx
xorl %esi, %esi
testb $0x5, %dl
sete %sil
leaq 0x102ce(%rip), %rdx     # 0x1ca78
leaq 0x102ff(%rip), %r8      # 0x1cab0
cmoveq %r8, %rdx
testl %ecx, %ecx
leaq 0x10282(%rip), %rax     # 0x1ca40
leaq 0x10243(%rip), %r8      # 0x1ca08
cmoveq %r8, %rax
addl %ecx, %ecx
testb $0x4, %r9b
cmovneq %rdx, %rax
leal 0x1(%rsi,%rsi), %ebp
movq %rax, 0x8(%rsp)
cvtsi2ssl 0x8(%rax), %xmm0
cmovel %ecx, %ebp
addss 0x10(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
movw %r9w, 0x2(%rsp)
movl (%r15,%rdi), %r13d
btl $0xb, %r9d
jb 0xc81c
movq 0x102e9(%rip), %rdi     # 0x1caf0
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %ebx
jmp 0xc827
addq %r15, %rdi
callq 0xfc0c
movzwl %ax, %ebx
testl %ebx, %ebx
je 0xc839
movq 0x8(%rsp), %rax
leaq 0x20(%rax), %rcx
jmp 0xca42
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebx, %ebx
movslq 0x10458(%rip), %rax     # 0x1cca0
cmpq %rax, %r14
jge 0xc896
movq 0x1029c(%rip), %rdi     # 0x1caf0
movq 0x1044d(%rip), %rax     # 0x1cca8
movq (%rax,%r15), %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %ebx
movq 0x10438(%rip), %rax     # 0x1cca8
testl %ebx, %ebx
je 0xc87d
cmpl %ebp, 0x8(%rax,%r15)
jne 0xc88b
jmp 0xc896
cmpl %ebp, 0x8(%rax,%r15)
jne 0xc88b
cmpl %r13d, 0xc(%rax,%r15)
je 0xc894
incq %r14
addq $0x10, %r15
jmp 0xc841
xorl %ebx, %ebx
cmpl %r14d, 0x10403(%rip)    # 0x1cca0
jle 0xc8a9
movq 0x18(%rsp), %r15
jmp 0xca2f
movq 0x8(%rsp), %rbx
movq 0x28(%rbx), %rax
testq %rax, %rax
movq 0x18(%rsp), %r15
jne 0xc8d5
movq 0x30(%rbx), %rsi
xorl %edi, %edi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
leaq 0x14(%rsp), %r8
callq 0x65b0
movq %rax, 0x28(%rbx)
movq %rax, 0x28(%rsp)
movq 0x30(%rbx), %rdi
callq 0x60e0
movq %rax, %r14
callq 0x6270
movq %rax, %rbx
movq %rax, %rdi
movl %r13d, %esi
callq 0x6040
movq %r14, %rdi
leaq 0x56ea(%rip), %rsi      # 0x11fed
movq %rbx, 0x30(%rsp)
movq %rbx, %rdx
callq 0x69a0
movq %r14, %rdi
leaq 0x56db(%rip), %rsi      # 0x11ff5
pushq $0x1
popq %rbx
movl %ebx, %edx
callq 0x6620
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x67f0
movq %r14, %rdi
callq 0x6840
xorl %edi, %edi
leaq 0x28(%rsp), %rsi
movl %ebx, %edx
movq %r14, 0x38(%rsp)
movq %r14, %rcx
leaq 0x14(%rsp), %r8
callq 0x66a0
movq %rax, %rbx
movslq 0x10353(%rip), %rsi     # 0x1ccb0
cmpl %esi, 0x1033d(%rip)     # 0x1cca0
jl 0xc986
addq $0x10, %rsi
movl %esi, 0x10341(%rip)     # 0x1ccb0
movq 0x10332(%rip), %rdi     # 0x1cca8
shlq $0x4, %rsi
callq 0x6bf2
movq %rax, 0x10322(%rip)     # 0x1cca8
movq 0x10163(%rip), %rdi     # 0x1caf0
movq %rbx, %rsi
callq 0x67b0
movq 0x1030c(%rip), %rcx     # 0x1cca8
movslq 0x102fd(%rip), %rdx     # 0x1cca0
movq %rdx, %rsi
shlq $0x4, %rsi
movq %rax, (%rcx,%rsi)
testq %rax, %rax
jne 0xc9e9
callq 0x65c0
movl (%rax), %edi
callq 0x6470
leaq 0x5638(%rip), %rdi      # 0x11ffe
movq %rax, %rsi
xorl %eax, %eax
callq 0x6b5a
movq 0x102d1(%rip), %rcx     # 0x1cca8
movslq 0x102c2(%rip), %rdx     # 0x1cca0
movq %rdx, %rax
shlq $0x4, %rax
movq (%rcx,%rax), %rax
shlq $0x4, %rdx
movl %ebp, 0x8(%rcx,%rdx)
movl %r13d, 0xc(%rcx,%rdx)
movq 0x100f3(%rip), %rdi     # 0x1caf0
movq %rax, %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %ebx
movl 0x1028f(%rip), %r14d    # 0x1cca0
leal 0x1(%r14), %eax
movl %eax, 0x10285(%rip)     # 0x1cca0
movq 0x38(%rsp), %rdi
callq 0x6050
movq 0x30(%rsp), %rdi
callq 0x66d0
movslq %r14d, %rcx
shlq $0x4, %rcx
addq 0x1026b(%rip), %rcx     # 0x1cca8
movq 0x40(%rsp), %r14
movq 0x20(%rsp), %rax
movq (%rcx), %rsi
cltq
movq %rax, %rcx
shlq $0x4, %rcx
movq 0x48(%rsp), %rdx
movq %rsi, (%rdx,%rcx)
movl %ebx, 0x8(%rdx,%rcx)
movaps 0x60(%rsp), %xmm1
movaps %xmm1, %xmm0
unpcklps 0x50(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
cvttps2dq %xmm0, %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
movd %xmm0, 0xc(%rdx,%rcx)
addss 0x4(%rsp), %xmm1
movaps %xmm1, 0x60(%rsp)
incl %eax
incq %r12
jmp 0xc737
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq