// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, %r12
movl 0xc483(%rip), %eax      # 0x19e04
movl 0x1028d(%rip), %esi     # 0x1dc14
imull 0x10281(%rip), %r8d     # 0x1dc10
movq $0x0, 0x18(%rsp)
testl %edx, %edx
jle 0xdd8a
movq %rdi, %rbx
addl %eax, %r8d
cvtsi2ss %r8d, %xmm0
cvtsi2ssl 0x1005d(%rip), %xmm1 # 0x1da10
movss %xmm0, 0x10(%rsp)
addss %xmm0, %xmm1
movaps %xmm1, 0x50(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
movss %xmm0, 0xc(%rsp)
imull %esi, %ecx
addl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movaps %xmm0, 0x60(%rsp)
movl %edx, %ecx
leaq 0x1001f(%rip), %r10     # 0x1da08
movw $0xffff, 0x6(%rsp)      # imm = 0xFFFF
xorl %r14d, %r14d
xorl %eax, %eax
movl $0x0, 0x8(%rsp)
movq %r12, 0x20(%rsp)
movq %rdi, 0x38(%rsp)
movq %rcx, 0x40(%rsp)
movq %r14, %rdi
shlq $0x4, %rdi
movzwl 0x4(%r12,%rdi), %r9d
cmpl $0x400, %r9d            # imm = 0x400
je 0xdd7c
movq %rax, 0x48(%rsp)
cmpw %r9w, 0x6(%rsp)
je 0xdac7
xorps %xmm0, %xmm0
cvtsi2ssl 0x101d2(%rip), %xmm0 # 0x1dc14
xorl %ecx, %ecx
btl $0x9, %r9d
setae %cl
leaq 0x523d(%rip), %rdx      # 0x12c90
mulss (%rdx,%rcx,4), %xmm0
movss %xmm0, 0xc(%rsp)
movl %r9d, %ecx
andl $0x1, %ecx
movl %r9d, %edx
notl %edx
xorl %esi, %esi
testb $0x5, %dl
sete %sil
leaq 0xffff(%rip), %rdx      # 0x1da78
leaq 0x10030(%rip), %rax     # 0x1dab0
cmoveq %rax, %rdx
testl %ecx, %ecx
leaq 0xffb3(%rip), %r10      # 0x1da40
leaq 0xff74(%rip), %r8       # 0x1da08
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 0x10(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
movw %r9w, 0x6(%rsp)
movl (%r12,%rdi), %r13d
btl $0xb, %r9d
jb 0xdaed
movq 0x10017(%rip), %rdi     # 0x1daf0
movq %r10, %rbp
movq 0x20(%r10), %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %r15d
jmp 0xdafc
movq %r10, %rbp
addq %r12, %rdi
callq 0x110ad
movzwl %ax, %r15d
testl %r15d, %r15d
je 0xdb0d
movq %rbp, %r10
leaq 0x20(%rbp), %rax
jmp 0xdd34
movl 0x1018d(%rip), %eax     # 0x1dca0
testl %eax, %eax
jle 0xdb84
movq 0x1018a(%rip), %rax     # 0x1dca8
xorl %r12d, %r12d
xorl %ebx, %ebx
movq 0xffc6(%rip), %rdi      # 0x1daf0
movq (%rax,%r12), %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %r15d
movq 0x10168(%rip), %rax     # 0x1dca8
testl %r15d, %r15d
je 0xdb52
movl 0x8(%rsp), %ecx
cmpl %ecx, 0x8(%rax,%r12)
jne 0xdb64
jmp 0xdb77
movl 0x8(%rsp), %ecx
cmpl %ecx, 0x8(%rax,%r12)
jne 0xdb64
cmpl %r13d, 0xc(%rax,%r12)
je 0xdb77
incq %rbx
movslq 0x10132(%rip), %rcx     # 0x1dca0
addq $0x10, %r12
cmpq %rcx, %rbx
jl 0xdb23
movl 0x10123(%rip), %eax     # 0x1dca0
movq 0x20(%rsp), %r12
jmp 0xdb89
xorl %ebx, %ebx
xorl %r15d, %r15d
cmpl %eax, %ebx
movq %rbp, %r10
jl 0xdd21
movq 0x28(%r10), %rax
testq %rax, %rax
jne 0xdbbe
movq 0x30(%r10), %rsi
xorl %edi, %edi
movl $0x1, %edx
xorl %ecx, %ecx
leaq 0x14(%rsp), %r8
movq %r10, %rbx
callq 0x65b0
movq %rbx, %r10
movq %rax, 0x28(%rbx)
movq %rax, 0x18(%rsp)
movq %r10, 0x30(%rsp)
movq 0x30(%r10), %rdi
callq 0x60e0
movq %rax, %rbp
callq 0x6270
movq %rax, %rbx
movq %rax, %rdi
movl %r13d, %esi
callq 0x6040
movq %rbp, %rdi
leaq 0x542c(%rip), %rsi      # 0x1301d
movq %rbx, 0x28(%rsp)
movq %rbx, %rdx
callq 0x69a0
movq %rbp, %rdi
leaq 0x541d(%rip), %rsi      # 0x13025
movl $0x1, %edx
callq 0x6620
xorl %edi, %edi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x67f0
movq %rbp, %rdi
callq 0x6840
xorl %edi, %edi
leaq 0x18(%rsp), %rsi
movl $0x1, %edx
movq %rbp, %rcx
leaq 0x14(%rsp), %r8
callq 0x66a0
movq %rax, %r15
movslq 0x10067(%rip), %rsi     # 0x1dcb0
cmpl %esi, 0x10051(%rip)     # 0x1dca0
jl 0xdc72
addq $0x10, %rsi
movl %esi, 0x10055(%rip)     # 0x1dcb0
movq 0x10046(%rip), %rdi     # 0x1dca8
shlq $0x4, %rsi
callq 0x7039
movq %rax, 0x10036(%rip)     # 0x1dca8
movq 0xfe77(%rip), %rdi      # 0x1daf0
movq %r15, %rsi
callq 0x67b0
movq 0x10020(%rip), %rcx     # 0x1dca8
movslq 0x10011(%rip), %rdx     # 0x1dca0
movq %rdx, %rsi
shlq $0x4, %rsi
movq %rax, (%rcx,%rsi)
testq %rax, %rax
jne 0xdcd5
callq 0x65c0
movl (%rax), %edi
callq 0x6470
leaq 0x537c(%rip), %rdi      # 0x1302e
movq %rax, %rsi
xorl %eax, %eax
callq 0x6f9f
movq 0xffe5(%rip), %rcx      # 0x1dca8
movslq 0xffd6(%rip), %rdx      # 0x1dca0
movq %rdx, %rax
shlq $0x4, %rax
movq (%rcx,%rax), %rax
shlq $0x4, %rdx
movl 0x8(%rsp), %esi
movl %esi, 0x8(%rcx,%rdx)
movl %r13d, 0xc(%rcx,%rdx)
movq 0xfe03(%rip), %rdi      # 0x1daf0
movq %rax, %rsi
movl %r13d, %edx
callq 0x6410
movl %eax, %r15d
movl 0xff9f(%rip), %ebx      # 0x1dca0
leal 0x1(%rbx), %eax
movl %eax, 0xff96(%rip)      # 0x1dca0
movq %rbp, %rdi
callq 0x6050
movq 0x28(%rsp), %rdi
callq 0x66d0
movq 0x30(%rsp), %r10
movslq %ebx, %rax
shlq $0x4, %rax
addq 0xff79(%rip), %rax      # 0x1dca8
movq 0x38(%rsp), %rbx
movq (%rax), %rdx
movq 0x48(%rsp), %rax
cltq
movq %rax, %rcx
shlq $0x4, %rcx
movq %rdx, (%rbx,%rcx)
movl %r15d, 0x8(%rbx,%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(%rbx,%rcx)
addss 0xc(%rsp), %xmm1
movaps %xmm1, 0x60(%rsp)
incl %eax
movq 0x40(%rsp), %rcx
incq %r14
cmpq %rcx, %r14
jne 0xda0c
jmp 0xdd8c
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq