// File: /workspace/github_c_makefile_star2_O3/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 0xffc5
movq %rax, %r15
xorl %edi, %edi
movq %rax, %rsi
xorl %edx, %edx
callq 0x67f0
movq 0xdc98(%rip), %rdi      # 0x1daf0
movl 0xdd82(%rip), %esi      # 0x1dbe0
movq %r15, %rdx
callq 0x6690
leaq 0x8(%rsp), %rdx
xorl %edi, %edi
movq %r15, %rsi
callq 0x61b0
testq %rax, %rax
je 0xffb0
movq %rax, %r13
movq 0xdc68(%rip), %rdi      # 0x1daf0
movq %rax, %rsi
callq 0x67b0
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0xffb5
leaq 0x3368(%rip), %rsi      # 0x1320c
leaq 0x4(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xfee5
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
leaq 0x3346(%rip), %rsi      # 0x1320c
movq %rsp, %rcx
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xffd7
movl (%rsp), %eax
cmpl 0x4(%rsp), %eax
jl 0xffd7
leaq 0x3326(%rip), %rsi      # 0x13212
xorl %r14d, %r14d
leaq 0x4(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xff30
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
leaq 0x3301(%rip), %rsi      # 0x13212
movq %rsp, %rcx
xorl %edx, %edx
callq 0x65a0
testl %eax, %eax
jne 0xffe4
movl (%rsp), %eax
cmpl 0x4(%rsp), %eax
jne 0xffe4
movq 0xdbb9(%rip), %r12      # 0x1daf0
movq 0x20(%rbx), %r13
leaq 0xa20e(%rip), %rbp      # 0x1a150
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
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 0xffc5
movq %r15, %rdi
jmp 0xffc0
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 0x6d86
jmp 0xfee5
movq %rbx, %rdi
callq 0x6da9
jmp 0xff30