// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-font.c
// Function: draw_number
static void draw_number(deark *c, de_bitmap *img,
	struct de_bitmap_font *dfont, i64 n, i64 xpos1, i64 ypos1,
	unsigned int flags)
{
	char buf[32];
	i64 len;
	i64 i;
	i64 xpos_start;
	i64 xpos, ypos;

	if(flags & DNFLAG_HEX) {
		if(flags & DNFLAG_LEADING_ZEROES)
			de_snprintf(buf, sizeof(buf), "%04X", (unsigned int)n);
		else
			de_snprintf(buf, sizeof(buf), "%X", (unsigned int)n);
	}
	else {
		de_snprintf(buf, sizeof(buf), "%u", (unsigned int)n);
	}
	len = (i64)de_strlen(buf);

	if(flags & DNFLAG_HCENTER)
		xpos_start = xpos1-(dfont->nominal_width*len)/2;
	else
		xpos_start = xpos1-dfont->nominal_width*len;

	// Make sure number doesn't go beyond the image
	if(xpos_start + dfont->nominal_width*len > img->width) {
		xpos_start = img->width - dfont->nominal_width*len;
	}

	for(i=len-1; i>=0; i--) {
		xpos = xpos_start + dfont->nominal_width*i;
		ypos = ypos1-dfont->nominal_height;
		de_font_paint_character_cp(c, img, dfont, buf[i], xpos, ypos,
			DE_MAKE_GRAY(255), 0, DE_PAINTFLAG_TRNSBKGD);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl 0x10(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x170f4a
movl 0x10(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x170f2b
leaq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %ecx
movl $0x20, %esi
leaq 0x64a86(%rip), %rdx     # 0x1d59a8
movb $0x0, %al
callq 0x15a980
jmp 0x170f48
leaq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %ecx
movl $0x20, %esi
leaq 0x64a6c(%rip), %rdx     # 0x1d59ad
movb $0x0, %al
callq 0x15a980
jmp 0x170f67
leaq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %ecx
movl $0x20, %esi
leaq 0x3035c(%rip), %rdx     # 0x1a12bc
movb $0x0, %al
callq 0x15a980
leaq -0x50(%rbp), %rdi
callq 0x190e0
movq %rax, -0x58(%rbp)
movl 0x10(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x170fad
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movslq (%rax), %rax
imulq -0x58(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x80(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x170fc4
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq -0x58(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq -0x58(%rbp), %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jle 0x170ffc
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq -0x58(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jl 0x171082
movq -0x68(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
imulq -0x60(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x4(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x60(%rbp), %rax
movsbl -0x50(%rbp,%rax), %ecx
movq -0x70(%rbp), %r8
movq -0x78(%rbp), %r9
xorl %eax, %eax
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0x16fd10
movq -0x60(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x171008
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)