// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x60e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x130a0
movl $0x1, -0x4(%rbp)
jmp 0x132ff
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
xorl %edx, %edx
callq 0x6810
movq 0xe7fa(%rip), %rdi      # 0x218b0
movl 0xe8e4(%rip), %esi      # 0x219a0
movq -0x20(%rbp), %rdx
callq 0x66b0
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq -0x2c(%rbp), %rdx
callq 0x61b0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x130f6
movq -0x20(%rbp), %rdi
callq 0x6050
movl $0x1, -0x4(%rbp)
jmp 0x132ff
movq 0xe7b3(%rip), %rdi      # 0x218b0
movq -0x28(%rbp), %rsi
callq 0x67d0
movq -0x10(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x13132
movq -0x20(%rbp), %rdi
callq 0x6050
movq -0x28(%rbp), %rdi
callq 0x6050
movl $0x1, -0x4(%rbp)
jmp 0x132ff
movq -0x18(%rbp), %rdi
leaq 0x436f(%rip), %rsi      # 0x174ac
xorl %edx, %edx
leaq -0x3c(%rbp), %rcx
callq 0x65b0
cmpl $0x0, %eax
jne 0x1319b
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rdi
leaq 0x434c(%rip), %rsi      # 0x174ac
xorl %edx, %edx
leaq -0x40(%rbp), %rcx
callq 0x65b0
cmpl $0x0, %eax
jne 0x13178
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x13199
movq -0x10(%rbp), %rax
movl $0x1, 0x10(%rax)
movq 0x7e66(%rip), %rax      # 0x1aff0
movq (%rax), %rsi
leaq 0x4325(%rip), %rdi      # 0x174b9
callq 0x64c0
jmp 0x1319b
movq -0x18(%rbp), %rdi
leaq 0x430c(%rip), %rsi      # 0x174b2
xorl %edx, %edx
leaq -0x3c(%rbp), %rcx
callq 0x65b0
cmpl $0x0, %eax
jne 0x13204
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rdi
leaq 0x42e9(%rip), %rsi      # 0x174b2
xorl %edx, %edx
leaq -0x40(%rbp), %rcx
callq 0x65b0
cmpl $0x0, %eax
jne 0x131e1
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x13202
movq -0x10(%rbp), %rax
movl $0x1, 0x14(%rax)
movq 0x7dfd(%rip), %rax      # 0x1aff0
movq (%rax), %rsi
leaq 0x42d7(%rip), %rdi      # 0x174d4
callq 0x64c0
jmp 0x13204
movq 0xe6a5(%rip), %rax      # 0x218b0
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
leaq 0x916e(%rip), %rdi      # 0x1c390
callq 0x6390
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl %eax, %ecx
leaq 0x9158(%rip), %rdx      # 0x1c390
leaq -0x38(%rbp), %r8
callq 0x67a0
movq -0x10(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl 0xc(%rax), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x1a(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
addl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movswq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x90d0(%rip), %rdi      # 0x1c390
callq 0x6390
movq %rax, %rcx
movq -0x50(%rbp), %rax
subq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
leaq 0x90b2(%rip), %rdi      # 0x1c390
callq 0x6390
movq %rax, %rcx
movq -0x48(%rbp), %rax
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)