// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %r15
testq %rax, %rax
je 0xebc1
movq %rax, %r14
xorl %edi, %edi
movq %rax, %rsi
xorl %edx, %edx
callq 0x67f0
movq 0xe098(%rip), %rdi      # 0x1caf0
movl 0xe182(%rip), %esi      # 0x1cbe0
movq %r14, %rdx
callq 0x6690
leaq 0x8(%rsp), %rdx
xorl %edi, %edi
movq %r14, %rsi
callq 0x61b0
testq %rax, %rax
je 0xebac
movq %rax, %r13
movq 0xe068(%rip), %rdi      # 0x1caf0
movq %rax, %rsi
callq 0x67b0
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0xebb1
leaq 0x3738(%rip), %rsi      # 0x121dc
leaq 0x4(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xeae5
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
leaq 0x3716(%rip), %rsi      # 0x121dc
movq %rsp, %rcx
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xebd3
movl (%rsp), %eax
cmpl 0x4(%rsp), %eax
jl 0xebd3
leaq 0x36f6(%rip), %rsi      # 0x121e2
xorl %r15d, %r15d
leaq 0x4(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xeb30
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
leaq 0x36d1(%rip), %rsi      # 0x121e2
movq %rsp, %rcx
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xebf5
movl (%rsp), %eax
cmpl 0x4(%rsp), %eax
jne 0xebf5
movq 0xdfb9(%rip), %r12      # 0x1caf0
movq 0x20(%rbx), %r13
leaq 0xa60e(%rip), %rbp      # 0x19150
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 0x6780
andq $0x0, 0x28(%rbx)
movq %r14, 0x30(%rbx)
movq 0x20(%rbx), %rax
movl (%rax), %ecx
movl %ecx, 0x8(%rbx)
movl 0x4(%rax), %edx
movl %edx, 0xc(%rbx)
andw $0x0, 0x18(%rbx)
movzwl 0xc(%rax), %eax
movw %ax, 0x1a(%rbx)
addl %ecx, %edx
movl %edx, (%rbx)
movswq 0x8(%r12), %r14
movq %rbp, %rdi
callq 0x6390
movq %rax, %rcx
addq %r14, %rax
decq %rax
xorl %edx, %edx
divq %rcx
movl %eax, 0x4(%rbx)
jmp 0xebc1
movq %r14, %rdi
jmp 0xebbc
movq %r14, %rdi
callq 0x6050
movq %r13, %rdi
callq 0x6050
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, 0x10(%rbx)
movq 0x940f(%rip), %rax      # 0x17ff0
movq (%rax), %rsi
leaq 0x35fe(%rip), %rdi      # 0x121e9
callq 0x64b0
jmp 0xeae5
movl $0x1, 0x14(%rbx)
movq 0x93ed(%rip), %rax      # 0x17ff0
movq (%rax), %rsi
leaq 0x35f7(%rip), %rdi      # 0x12204
callq 0x64b0
jmp 0xeb30