// File: /workspace/github_c_makefile_star2_O0/odknt[P]st/x.c
// Function: xloadfont
int
xloadfont(Font *f, FcPattern *pattern)
{
	FcPattern *configured = NULL;
	FcPattern *match = NULL;
	FcResult result;
	FcChar8 *path = NULL;
	double fontsize;
	cairo_text_extents_t extents;
	int wantattr, haveattr;
	double dpi;

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

	/* get dpi and set to pattern */
	dpi = (((double)DisplayHeight(xw.dpy, xw.scr) * 25.4) /
	      (double)DisplayHeightMM(xw.dpy, xw.scr));
	FcPatternAddDouble(configured, FC_DPI, dpi);

	FcConfigSubstitute(NULL, configured, FcMatchPattern);
	FcDefaultSubstitute(configured);

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

	if (FcPatternGetString(match, FC_FILE, 0, &path) == FcResultNoMatch) {
		FcPatternDestroy(configured);
		FcPatternDestroy(match);
		return 1;
	}

	if (FT_New_Face(ftlib, (const char *)path, 0, &f->match.face)) {
		FcPatternDestroy(configured);
		FcPatternDestroy(match);
		return 1;
	}

	/* initialize font data */
	f->set = NULL;
	f->pattern = configured;
	f->match.pattern = match;
	f->match.cairo = cairo_ft_font_face_create_for_ft_face(
	                 f->match.face, FT_LOAD_COLOR);

	if ((FcPatternGetInteger(pattern, FC_SLANT, 0, &wantattr) ==
	    FcResultMatch)) {
		/*
		 * Check if fontconfig was unable to find a font with
		 * the appropriate slant but gave us one anyway.
		 * Try to mitigate.
		 */
		if ((FcPatternGetInteger(f->match.pattern, FC_SLANT, 0,
		    &haveattr) != FcResultMatch) || haveattr < wantattr) {
			f->badslant = 1;
			fputs("font slant does not match\n", stderr);
		} else {
			/* synthesize to oblique font */
			cairo_ft_font_face_set_synthesize(f->match.cairo,
			                                  CAIRO_FT_SYNTHESIZE_OBLIQUE);
		}
	}

	if ((FcPatternGetInteger(pattern, FC_WEIGHT, 0, &wantattr) ==
	    FcResultMatch)) {
		if ((FcPatternGetInteger(f->match.pattern, FC_WEIGHT, 0,
		    &haveattr) != FcResultMatch) || haveattr != wantattr) {
			f->badweight = 1;
			fputs("font weight does not match\n", stderr);
		} else {
			/* synthesize to bold font */
			cairo_ft_font_face_set_synthesize(f->match.cairo,
			                                  CAIRO_FT_SYNTHESIZE_BOLD);
		}
	}

	FcPatternGetDouble(f->match.pattern, FC_PIXEL_SIZE, 0, &fontsize);
	cairo_set_font_size(xw.draw, fontsize);
	cairo_set_font_face(xw.draw, f->match.cairo);
	cairo_text_extents(xw.draw, ascii_printable, &extents);

	f->ascent = -extents.y_bearing;
	f->descent = extents.height + extents.y_bearing;
	f->lbearing = 0;
	f->rbearing = f->match.face->max_advance_width;
	f->height = extents.height;
	f->width = DIVCEIL(extents.x_advance, strlen(ascii_printable));

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x60e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x11bab
movl $0x1, -0x4(%rbp)
jmp 0x11f79
movq 0x109de(%rip), %rax     # 0x22590
movq 0xe8(%rax), %rax
movslq 0x10ac0(%rip), %rcx     # 0x22680
shlq $0x7, %rcx
addq %rcx, %rax
cvtsi2sdl 0x1c(%rax), %xmm0
movsd 0x337c(%rip), %xmm1     # 0x14f50
mulsd %xmm1, %xmm0
movq 0x109b1(%rip), %rax     # 0x22590
movq 0xe8(%rax), %rax
movslq 0x10a93(%rip), %rcx     # 0x22680
shlq $0x7, %rcx
addq %rcx, %rax
cvtsi2sdl 0x24(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x20(%rbp), %rdi
movsd -0x80(%rbp), %xmm0
leaq 0x37eb(%rip), %rsi      # 0x153fd
callq 0x6180
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
xorl %edx, %edx
callq 0x68e0
movq -0x20(%rbp), %rdi
callq 0x6930
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq -0x2c(%rbp), %rdx
callq 0x61e0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x11c60
movq -0x20(%rbp), %rdi
callq 0x6050
movl $0x1, -0x4(%rbp)
jmp 0x11f79
movq -0x28(%rbp), %rdi
leaq 0x2e8c(%rip), %rsi      # 0x14af7
xorl %edx, %edx
leaq -0x38(%rbp), %rcx
callq 0x64b0
cmpl $0x1, %eax
jne 0x11c99
movq -0x20(%rbp), %rdi
callq 0x6050
movq -0x28(%rbp), %rdi
callq 0x6050
movl $0x1, -0x4(%rbp)
jmp 0x11f79
movq 0x10a10(%rip), %rdi     # 0x226b0
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rcx
addq $0x20, %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6800
cmpl $0x0, %eax
je 0x11cd8
movq -0x20(%rbp), %rdi
callq 0x6050
movq -0x28(%rbp), %rdi
callq 0x6050
movl $0x1, -0x4(%rbp)
jmp 0x11f79
movq -0x10(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movl $0x100000, %esi         # imm = 0x100000
callq 0x6100
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rdi
leaq 0x36cc(%rip), %rsi      # 0x153f0
xorl %edx, %edx
leaq -0x74(%rbp), %rcx
callq 0x66c0
cmpl $0x0, %eax
jne 0x11d92
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x36ad(%rip), %rsi      # 0x153f0
xorl %edx, %edx
leaq -0x78(%rbp), %rcx
callq 0x66c0
cmpl $0x0, %eax
jne 0x11d5b
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x11d7e
movq -0x10(%rbp), %rax
movl $0x1, 0x10(%rax)
movq 0x7283(%rip), %rax      # 0x18ff0
movq (%rax), %rsi
leaq 0x368a(%rip), %rdi      # 0x15401
callq 0x65c0
jmp 0x11d90
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movl $0x2, %esi
callq 0x69c0
jmp 0x11d92
movq -0x18(%rbp), %rdi
leaq 0x3659(%rip), %rsi      # 0x153f6
xorl %edx, %edx
leaq -0x74(%rbp), %rcx
callq 0x66c0
cmpl $0x0, %eax
jne 0x11e0b
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x363a(%rip), %rsi      # 0x153f6
xorl %edx, %edx
leaq -0x78(%rbp), %rcx
callq 0x66c0
cmpl $0x0, %eax
jne 0x11dd4
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
je 0x11df7
movq -0x10(%rbp), %rax
movl $0x1, 0x14(%rax)
movq 0x720a(%rip), %rax      # 0x18ff0
movq (%rax), %rsi
leaq 0x362c(%rip), %rdi      # 0x1541c
callq 0x65c0
jmp 0x11e09
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movl $0x1, %esi
callq 0x69c0
jmp 0x11e0b
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x35cc(%rip), %rsi      # 0x153e6
xorl %edx, %edx
leaq -0x40(%rbp), %rcx
callq 0x61c0
movq 0x107d4(%rip), %rdi     # 0x22600
movsd -0x40(%rbp), %xmm0
callq 0x64e0
movq 0x107c3(%rip), %rdi     # 0x22600
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x6450
movq 0x107af(%rip), %rdi     # 0x22600
leaq 0x8498(%rip), %rsi      # 0x1a2f0
movq %rsi, -0xb8(%rbp)
leaq -0x70(%rbp), %rdx
callq 0x6950
movq -0xb8(%rbp), %rdi
movaps 0x30ea(%rip), %xmm1     # 0x14f60
movsd -0x68(%rbp), %xmm0
pxor %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movsd -0x68(%rbp), %xmm1
movsd -0x58(%rbp), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movw 0x90(%rcx), %cx
movw %cx, 0x1a(%rax)
cvttsd2si -0x58(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
callq 0x6410
movsd -0xc0(%rbp), %xmm0
movq -0xb8(%rbp), %rdi
decq %rax
movq %rax, %xmm1
movaps 0x3075(%rip), %xmm2     # 0x14f70
movaps %xmm2, -0xb0(%rbp)
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x3072(%rip), %xmm2     # 0x14f80
movaps %xmm2, -0xa0(%rbp)
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
callq 0x6410
movaps -0xb0(%rbp), %xmm3
movaps -0xa0(%rbp), %xmm2
movsd -0x88(%rbp), %xmm0
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)