// File: /workspace/github_c_makefile_star2_O0/michaelforney[P]wld/pixman.c
// Function: renderer_draw_text
void
renderer_draw_text(struct wld_renderer *base,
                   struct font *font, uint32_t color,
                   int32_t x, int32_t y, const char *text,
                   uint32_t length, struct wld_extents *extents)
{
	struct pixman_renderer *renderer = pixman_renderer(base);
	int ret;
	uint32_t c;
	struct glyph *glyph;
	FT_UInt glyph_index;
	pixman_glyph_t *glyphs;
	uint32_t index = 0, origin_x = 0;
	pixman_color_t pixman_color = PIXMAN_COLOR(color);
	pixman_image_t *solid;

	if (length == -1)
		length = strlen(text);
	glyphs = malloc(length * sizeof(glyphs[0]));
	if (!glyphs)
		return;
	solid = pixman_image_create_solid_fill(&pixman_color);

	while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
		text += ret;
		length -= ret;
		glyph_index = FT_Get_Char_Index(font->face, c);

		if (!font_ensure_glyph(font, glyph_index))
			continue;

		glyph = font->glyphs[glyph_index];

		glyphs[index].x = origin_x;
		glyphs[index].y = 0;
		glyphs[index].glyph = pixman_glyph_cache_lookup(renderer->glyph_cache,
		                                                font, glyph);

		/* If we don't have the glyph in our cache, do some conversions to make
		 * pixman happy, and then insert it. */
		if (!glyphs[index].glyph) {
			uint8_t *src, *dst;
			uint32_t row, byte_index, bytes_per_row, pitch;
			pixman_image_t *image;
			FT_Bitmap *bitmap;

			bitmap = &glyph->bitmap;
			image = pixman_image_create_bits(PIXMAN_a1, bitmap->width, bitmap->rows, NULL, bitmap->pitch);

			if (!image)
				goto advance;

			pitch = pixman_image_get_stride(image);
			bytes_per_row = (bitmap->width + 7) / 8;
			src = bitmap->buffer;
			dst = (uint8_t *)pixman_image_get_data(image);

			for (row = 0; row < bitmap->rows; ++row) {
				/* Pixman's A1 format expects the bits in the opposite order
				 * that Freetype gives us. Sigh... */
				for (byte_index = 0; byte_index < bytes_per_row; ++byte_index)
					dst[byte_index] = reverse(src[byte_index]);

				dst += pitch;
				src += bitmap->pitch;
			}

			/* Insert the glyph into the cache. */
			pixman_glyph_cache_freeze(renderer->glyph_cache);
			glyphs[index].glyph = pixman_glyph_cache_insert(renderer->glyph_cache, font, glyph,
			                                                -glyph->x, -glyph->y, image);
			pixman_glyph_cache_thaw(renderer->glyph_cache);

			/* The glyph cache copies the contents of the glyph bitmap. */
			pixman_image_unref(image);
		}

		++index;

	advance:
		origin_x += glyph->advance;
	}

	pixman_composite_glyphs_no_mask(PIXMAN_OP_OVER, solid, renderer->target,
	                                0, 0, x, y, renderer->glyph_cache,
	                                index, glyphs);

	free(glyphs);
	pixman_image_unref(solid);

	if (extents)
		extents->advance = origin_x;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0xc8, %rsp
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10990
movq %rax, -0x38(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
imull $0x101, %eax, %eax      # imm = 0x101
movw %ax, -0x68(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
imull $0x101, %eax, %eax      # imm = 0x101
movw %ax, -0x66(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x0, %eax
andl $0xff, %eax
imull $0x101, %eax, %eax      # imm = 0x101
movw %ax, -0x64(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x18, %eax
andl $0xff, %eax
imull $0x101, %eax, %eax      # imm = 0x101
movw %ax, -0x62(%rbp)
cmpl $-0x1, 0x10(%rbp)
jne 0x105ca
movq -0x30(%rbp), %rdi
callq 0x9260
movl %eax, 0x10(%rbp)
movl 0x10(%rbp), %eax
movl %eax, %edi
shlq $0x4, %rdi
callq 0x9590
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x105e8
jmp 0x10928
leaq -0x68(%rbp), %rdi
callq 0x90a0
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rdi
movl 0x10(%rbp), %edx
leaq -0x40(%rbp), %rsi
callq 0x92b0
movl %eax, %ecx
movl %ecx, -0x3c(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xa1(%rbp)
jle 0x10624
cmpl $0x0, -0x40(%rbp)
setne %al
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x10633
jmp 0x108c1
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x3c(%rbp), %ecx
movl 0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, 0x10(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x40(%rbp), %eax
movl %eax, %esi
callq 0x9660
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0xa940
testb $0x1, %al
jne 0x10679
jmp 0x105f5
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movl -0x60(%rbp), %ecx
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x9550
movq %rax, %rcx
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jne 0x108a5
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %esi
movq -0xa0(%rbp), %rax
movl (%rax), %edx
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %r8d
movl $0x1011000, %edi        # imm = 0x1011000
xorl %eax, %eax
movl %eax, %ecx
callq 0x9690
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x10744
jmp 0x108ae
movq -0x98(%rbp), %rdi
callq 0x9530
movl %eax, -0x90(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x7, %eax
shrl $0x3, %eax
movl %eax, -0x8c(%rbp)
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x98(%rbp), %rdi
callq 0x97c0
movq %rax, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
movq -0xa0(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x10834
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jae 0x107f5
movq -0x78(%rbp), %rax
movl -0x88(%rbp), %ecx
movzbl (%rax,%rcx), %edi
callq 0x10c60
movb %al, %dl
movq -0x80(%rbp), %rax
movl -0x88(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x107b4
movl -0x90(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x78(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x10795
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x9680
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x48(%rbp), %rax
movswl 0x28(%rax), %eax
xorl %ecx, %ecx
subl %eax, %ecx
movq -0x48(%rbp), %rax
movswl 0x2a(%rax), %eax
xorl %r8d, %r8d
subl %eax, %r8d
movq -0x98(%rbp), %r9
callq 0x9580
movq %rax, %rcx
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x9290
movq -0x98(%rbp), %rdi
callq 0x9400
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x48(%rbp), %rax
movzwl 0x2c(%rax), %eax
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x105f5
movq -0x70(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdx
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %ebx
movq -0x38(%rbp), %rax
movq 0x18(%rax), %r11
movl -0x5c(%rbp), %r10d
movq -0x58(%rbp), %rax
movl $0x3, %edi
xorl %r8d, %r8d
movl %r8d, %ecx
movl %ebx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x92f0
movq -0x58(%rbp), %rdi
callq 0x9060
movq -0x70(%rbp), %rdi
callq 0x9400
cmpq $0x0, 0x18(%rbp)
je 0x10928
movl -0x60(%rbp), %ecx
movq 0x18(%rbp), %rax
movl %ecx, (%rax)
addq $0xc8, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)