// File: /workspace/github_c_makefile_star2_O0/uobikiemukot[P]yaft/tools/bdf.h
// Function: shift_glyph
void shift_glyph(struct bdf_header_t *bdf_header, struct bdf_char_t *bdf_char)
{
	int i, byte, shift;
	bitmap_width_t bitmap;

	for (i = 0; i < bdf_char->bbh; i++) {
		bitmap  = bdf_char->bitmap[i];
		byte    = bit2byte(bdf_char->bbw);
		bitmap <<= (bit2byte(bdf_char->dwidth) - byte) * BITS_PER_BYTE;
		if (bdf_char->bbx >= 0)
			bitmap >>= bdf_char->bbx;
		else {
			logging(ERROR, "maybe overlapping (glpyh:%X bbx:%d)\n", bdf_char->encoding, bdf_char->bbx);
			bitmap <<= abs(bdf_char->bbx);
		}
		bdf_char->bitmap[i] = bitmap;
	}

	shift = bdf_header->ascent - (bdf_char->bbh + bdf_char->bby);
	if (shift >= 0) {
		memmove(bdf_char->bitmap + shift, bdf_char->bitmap, sizeof(bitmap_width_t) * bdf_char->bbh);
		memset(bdf_char->bitmap, 0, sizeof(bitmap_width_t) * shift);
	}
	else {
		logging(ERROR, "maybe overlapping (glpyh:%X vertical shift:%d)\n", bdf_char->encoding, shift);
		memmove(bdf_char->bitmap, bdf_char->bitmap + abs(shift), sizeof(bitmap_width_t) * bdf_char->bbh);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x1622
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edi
callq 0x1520
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edi
callq 0x1520
movl %eax, %ecx
subl -0x18(%rbp), %ecx
shll $0x3, %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x15c7
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x28(%rbp)
jmp 0x1603
movq -0x10(%rbp), %rax
movl 0x14(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x2, %edi
leaq 0x1a9a(%rip), %rsi      # 0x307b
movb $0x0, %al
callq 0x1280
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovnsl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, 0x18(%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1557
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq -0x10(%rbp), %rdx
addl 0xc(%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x1687
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
movq -0x10(%rbp), %rax
movslq 0x4(%rax), %rdx
shlq $0x3, %rdx
callq 0x1120
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movslq -0x1c(%rbp), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x10b0
jmp 0x16d8
movq -0x10(%rbp), %rax
movl 0x14(%rax), %edx
movl -0x1c(%rbp), %ecx
movl $0x2, %edi
leaq 0x1a03(%rip), %rsi      # 0x30a0
movb $0x0, %al
callq 0x1280
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
movl -0x1c(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cltq
shlq $0x3, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movslq 0x4(%rax), %rdx
shlq $0x3, %rdx
callq 0x1120
addq $0x30, %rsp
popq %rbp
retq
nop