// File: /workspace/github_c_makefile_star2_O1/mrdotx[P]st/x.c
// Function: xloadfont
int
xloadfont(Font *f, FcPattern *pattern)
{
	FcPattern *configured;
	FcPattern *match;
	FcResult result;
	XGlyphInfo extents;
	int wantattr, haveattr;

	/*
	 * Manually configure instead of calling XftMatchFont
	 * so that we can use the configured pattern for
	 * "missing glyph" lookups.
	 */
	configured = FcPatternDuplicate(pattern);
	if (!configured)
		return 1;

	FcConfigSubstitute(NULL, configured, FcMatchPattern);
	XftDefaultSubstitute(xw.dpy, xw.scr, configured);

	match = FcFontMatch(NULL, configured, &result);
	if (!match) {
		FcPatternDestroy(configured);
		return 1;
	}

	if (!(f->match = XftFontOpenPattern(xw.dpy, match))) {
		FcPatternDestroy(configured);
		FcPatternDestroy(match);
		return 1;
	}

	if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) ==
	    XftResultMatch)) {
		/*
		 * Check if xft was unable to find a font with the appropriate
		 * slant but gave us one anyway. Try to mitigate.
		 */
		if ((XftPatternGetInteger(f->match->pattern, "slant", 0,
		    &haveattr) != XftResultMatch) || haveattr < wantattr) {
			f->badslant = 1;
			fputs("font slant does not match\n", stderr);
		}
	}

	if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) ==
	    XftResultMatch)) {
		if ((XftPatternGetInteger(f->match->pattern, "weight", 0,
		    &haveattr) != XftResultMatch) || haveattr != wantattr) {
			f->badweight = 1;
			fputs("font weight does not match\n", stderr);
		}
	}

	XftTextExtentsUtf8(xw.dpy, f->match,
		(const FcChar8 *) ascii_printable,
		strlen(ascii_printable), &extents);

	f->set = NULL;
	f->pattern = configured;

	f->ascent = f->match->ascent;
	f->descent = f->match->descent;
	f->lbearing = 0;
	f->rbearing = f->match->max_advance_width;

	f->height = f->ascent + f->descent;
	f->width = DIVCEIL(extents.xOff, strlen(ascii_printable));

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x60e0
movl $0x1, %r14d
testq %rax, %rax
je 0xf774
movq %rax, %r15
xorl %edi, %edi
movq %rax, %rsi
xorl %edx, %edx
callq 0x6800
movq 0xe4f9(%rip), %rdi      # 0x1db00
movl 0xe5e3(%rip), %esi      # 0x1dbf0
movq %r15, %rdx
callq 0x66a0
leaq 0x8(%rsp), %rdx
xorl %edi, %edi
movq %r15, %rsi
callq 0x61b0
testq %rax, %rax
je 0xf75f
movq %rax, %r13
movq 0xe4c9(%rip), %rdi      # 0x1db00
movq %rax, %rsi
callq 0x67c0
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0xf764
leaq 0x3b99(%rip), %rsi      # 0x131ec
leaq 0x4(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xf694
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
leaq 0x3b77(%rip), %rsi      # 0x131ec
movq %rsp, %rcx
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xf786
movl (%rsp), %eax
cmpl 0x4(%rsp), %eax
jl 0xf786
leaq 0x3b57(%rip), %rsi      # 0x131f2
xorl %r14d, %r14d
leaq 0x4(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xf6df
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
leaq 0x3b32(%rip), %rsi      # 0x131f2
movq %rsp, %rcx
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xf793
movl (%rsp), %eax
cmpl 0x4(%rsp), %eax
jne 0xf793
movq 0xe41a(%rip), %r12      # 0x1db00
movq 0x20(%rbx), %r13
leaq 0xaa6f(%rip), %rbp      # 0x1a160
movq %rbp, %rdi
callq 0x6390
leaq 0xc(%rsp), %r8
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl %eax, %ecx
movq %r8, %r12
callq 0x6790
movq $0x0, 0x28(%rbx)
movq %r15, 0x30(%rbx)
movq 0x20(%rbx), %rax
movl (%rax), %ecx
movl %ecx, 0x8(%rbx)
movl 0x4(%rax), %edx
movl %edx, 0xc(%rbx)
movw $0x0, 0x18(%rbx)
movzwl 0xc(%rax), %eax
movw %ax, 0x1a(%rbx)
addl %ecx, %edx
movl %edx, (%rbx)
movswq 0x8(%r12), %r15
movq %rbp, %rdi
callq 0x6390
movq %rax, %rcx
addq %r15, %rax
decq %rax
xorl %edx, %edx
divq %rcx
movl %eax, 0x4(%rbx)
jmp 0xf774
movq %r15, %rdi
jmp 0xf76f
movq %r15, %rdi
callq 0x6050
movq %r13, %rdi
callq 0x6050
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x6d96
jmp 0xf694
movq %rbx, %rdi
callq 0x6db9
jmp 0xf6df