// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rsi, %r14
movl 0xccc5(%rip), %eax      # 0x19e14
movl 0x10acf(%rip), %esi     # 0x1dc24
imull 0x10ac3(%rip), %r8d     # 0x1dc20
movq $0x0, 0x20(%rsp)
testl %edx, %edx
jle 0xd55f
movq %rdi, %r12
addl %eax, %r8d
cvtsi2ss %r8d, %xmm0
cvtsi2ssl 0x1089f(%rip), %xmm1 # 0x1da20
movss %xmm0, 0x18(%rsp)
addss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x10(%rsp)
imull %esi, %ecx
addl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x14(%rsp)
movl %edx, %ecx
leaq 0x1085f(%rip), %r10     # 0x1da18
movw $0xffff, 0x6(%rsp)      # imm = 0xFFFF
xorl %ebx, %ebx
xorl %eax, %eax
movl $0x0, 0x8(%rsp)
movq %r14, 0x28(%rsp)
movq %rdi, 0x40(%rsp)
movq %rcx, 0x48(%rsp)
movq %rbx, %rdi
shlq $0x4, %rdi
movzwl 0x4(%r14,%rdi), %r9d
cmpl $0x400, %r9d            # imm = 0x400
je 0xd549
movq %rax, 0x50(%rsp)
cmpw %r9w, 0x6(%rsp)
je 0xd297
xorps %xmm0, %xmm0
cvtsi2ssl 0x10a13(%rip), %xmm0 # 0x1dc24
xorl %ecx, %ecx
btl $0x9, %r9d
setae %cl
leaq 0x5a56(%rip), %rdx      # 0x12c78
mulss (%rdx,%rcx,4), %xmm0
movss %xmm0, 0x10(%rsp)
movl %r9d, %ecx
andl $0x1, %ecx
movl %r9d, %edx
notl %edx
xorl %esi, %esi
testb $0x5, %dl
sete %sil
leaq 0x10840(%rip), %rdx     # 0x1da88
leaq 0x10871(%rip), %rax     # 0x1dac0
cmoveq %rax, %rdx
testl %ecx, %ecx
leaq 0x107f4(%rip), %r10     # 0x1da50
leaq 0x107b5(%rip), %r8      # 0x1da18
cmoveq %r8, %r10
addl %ecx, %ecx
testb $0x4, %r9b
cmovneq %rdx, %r10
leal 0x1(%rsi,%rsi), %eax
xorps %xmm0, %xmm0
cvtsi2ssl 0x8(%r10), %xmm0
cmovel %ecx, %eax
movl %eax, 0x8(%rsp)
addss 0x18(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movw %r9w, 0x6(%rsp)
movl (%r14,%rdi), %r13d
btl $0xb, %r9d
jb 0xd2bd
movq 0x10857(%rip), %rdi     # 0x1db00
movq %r10, %rbp
movq 0x20(%r10), %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %r15d
jmp 0xd2cc
movq %r10, %rbp
addq %r14, %rdi
callq 0x10875
movzwl %ax, %r15d
testl %r15d, %r15d
je 0xd2dd
movq %rbp, %r10
leaq 0x20(%rbp), %rax
jmp 0xd500
cmpl $0x0, 0x109cc(%rip)     # 0x1dcb0
jle 0xd352
xorl %r14d, %r14d
xorl %r12d, %r12d
movq 0x1080d(%rip), %rdi     # 0x1db00
movq 0x109be(%rip), %rax     # 0x1dcb8
movq (%rax,%r14), %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %r15d
movq 0x109a8(%rip), %rax     # 0x1dcb8
testl %r15d, %r15d
je 0xd322
movl 0x8(%rsp), %ecx
cmpl %ecx, 0x8(%rax,%r14)
jne 0xd338
jmp 0xd34b
movl 0x8(%rsp), %ecx
cmpl %ecx, 0x8(%rax,%r14)
jne 0xd338
cmpl %r13d, 0xc(%rax,%r14)
je 0xd557
incq %r12
movslq 0x1096e(%rip), %rax     # 0x1dcb0
addq $0x10, %r14
cmpq %rax, %r12
jl 0xd2ec
movq 0x28(%rsp), %r14
jmp 0xd358
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpl 0x10951(%rip), %r12d    # 0x1dcb0
movq %rbp, %r10
jl 0xd4ed
cmpq $0x0, 0x28(%r10)
jne 0xd390
movq 0x30(%r10), %rsi
xorl %edi, %edi
movl $0x1, %edx
xorl %ecx, %ecx
leaq 0x1c(%rsp), %r8
movq %r10, %r15
callq 0x65b0
movq %r15, %r10
movq %rax, 0x28(%r15)
movq 0x28(%r10), %rax
movq %rax, 0x20(%rsp)
movq %r10, 0x38(%rsp)
movq 0x30(%r10), %rdi
callq 0x60e0
movq %rax, %rbp
callq 0x6270
movq %rax, %r15
movq %rax, %rdi
movl %r13d, %esi
callq 0x6040
movq %rbp, %rdi
leaq 0x5c36(%rip), %rsi      # 0x12ffd
movq %r15, 0x30(%rsp)
movq %r15, %rdx
callq 0x69b0
movq %rbp, %rdi
leaq 0x5c27(%rip), %rsi      # 0x13005
movl $0x1, %edx
callq 0x6620
xorl %edi, %edi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x6800
movq %rbp, %rdi
callq 0x6850
xorl %edi, %edi
leaq 0x20(%rsp), %rsi
movl $0x1, %edx
movq %rbp, %rcx
leaq 0x1c(%rsp), %r8
callq 0x66b0
movq %rax, %r15
movslq 0x108a1(%rip), %rsi     # 0x1dcc0
cmpl %esi, 0x1088b(%rip)     # 0x1dcb0
jl 0xd448
addq $0x10, %rsi
movl %esi, 0x1088f(%rip)     # 0x1dcc0
movq 0x10880(%rip), %rdi     # 0x1dcb8
shlq $0x4, %rsi
callq 0x7049
movq %rax, 0x10870(%rip)     # 0x1dcb8
movq 0x106b1(%rip), %rdi     # 0x1db00
movq %r15, %rsi
callq 0x67c0
movq 0x1085a(%rip), %rcx     # 0x1dcb8
movslq 0x1084b(%rip), %rdx     # 0x1dcb0
shlq $0x4, %rdx
movq %rax, (%rcx,%rdx)
testq %rax, %rax
jne 0xd48f
callq 0x65c0
movl (%rax), %edi
callq 0x6470
leaq 0x5b89(%rip), %rdi      # 0x1300e
movq %rax, %rsi
xorl %eax, %eax
callq 0x6faf
movq 0x10822(%rip), %rax     # 0x1dcb8
movslq 0x10813(%rip), %rcx     # 0x1dcb0
shlq $0x4, %rcx
movl 0x8(%rsp), %edx
movl %edx, 0x8(%rax,%rcx)
movl %r13d, 0xc(%rax,%rcx)
movq 0x1064b(%rip), %rdi     # 0x1db00
movq (%rax,%rcx), %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %r15d
movl 0x107e5(%rip), %r12d    # 0x1dcb0
leal 0x1(%r12), %eax
movl %eax, 0x107da(%rip)     # 0x1dcb0
movq %rbp, %rdi
callq 0x6050
movq 0x30(%rsp), %rdi
callq 0x66e0
movq 0x38(%rsp), %r10
movslq %r12d, %rax
shlq $0x4, %rax
addq 0x107bd(%rip), %rax     # 0x1dcb8
movq 0x40(%rsp), %r12
movq (%rax), %rdx
movq 0x50(%rsp), %rax
cltq
movq %rax, %rcx
shlq $0x4, %rcx
movq %rdx, (%r12,%rcx)
movl %r15d, 0x8(%r12,%rcx)
movss 0x14(%rsp), %xmm0
cvttss2si %xmm0, %esi
cvttss2si 0xc(%rsp), %edx
movw %si, 0xc(%r12,%rcx)
movw %dx, 0xe(%r12,%rcx)
addss 0x10(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
incl %eax
movq 0x48(%rsp), %rcx
incq %rbx
cmpq %rcx, %rbx
jne 0xd1db
jmp 0xd561
xorl %r15d, %r15d
jmp 0xd34b
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq