// File: /workspace/github_c_makefile_star2_O2/GangZhuo[P]rbtree/test/bitmap.c
// Function: bitmap_print
int bitmap_print(bitmap_t *bitmap, FILE *pf)
{
	char buf[1024];
	int r, i, j;

	buf[0] = 'B';
	buf[1] = 'M';

	r = fwrite(buf, 1, 2, pf);
	if (r != 2) return -1;

	r = fwritei32(bitmap->w * bitmap->h * 3 + 54, pf);
	if (r != 0) return -1;

	r = fwritei32(0, pf);
	if (r != 0) return -1;

	r = fwritei32(54, pf);
	if (r != 0) return -1;

	r = fwritei32(40, pf);
	if (r != 0) return -1;

	r = fwritei32(bitmap->w, pf);
	if (r != 0) return -1;

	r = fwritei32(bitmap->h, pf);
	if (r != 0) return -1;

	r = fwritei16(1, pf);
	if (r != 0) return -1;

	r = fwritei16(24, pf);
	if (r != 0) return -1;

	r = fwritei32(0, pf);
	if (r != 0) return -1;

	r = fwritei32(0, pf);
	if (r != 0) return -1;

	r = fwritei32(0, pf);
	if (r != 0) return -1;

	r = fwritei32(0, pf);
	if (r != 0) return -1;

	r = fwritei32(0, pf);
	if (r != 0) return -1;

	r = fwritei32(0, pf);
	if (r != 0) return -1;

	for (j = bitmap->h - 1; j >= 0; j--) {
		for (i = 0; i < bitmap->w; i++) {
			r = fwritei24(bitmap->colors[i + j * bitmap->w], pf);
			if (r != 0) return -1;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %rsi, %r14
movq %rdi, %r15
leaq 0x10(%rsp), %rdi
movw $0x4d42, (%rdi)         # imm = 0x4D42
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
movq %r14, %rcx
callq 0x1180
pushq $-0x1
popq %rbx
cmpl $0x2, %eax
jne 0x28d4
movl (%r15), %eax
imull 0x4(%r15), %eax
leal (%rax,%rax,2), %edi
addl $0x36, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
xorl %edi, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
pushq $0x36
popq %rdi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
pushq $0x28
popq %rdi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
movl (%r15), %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
movl 0x4(%r15), %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
pushq $0x1
popq %rdi
movq %r14, %rsi
callq 0x2985
testl %eax, %eax
jne 0x28d4
pushq $0x18
popq %rdi
movq %r14, %rsi
callq 0x2985
testl %eax, %eax
jne 0x28d4
xorl %edi, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
xorl %edi, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
xorl %edi, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
xorl %edi, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
xorl %edi, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
jne 0x28d4
xorl %edi, %edi
movq %r14, %rsi
callq 0x295e
testl %eax, %eax
je 0x28e8
movl %ebx, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r15), %eax
movq %rax, 0x8(%rsp)
leal -0x1(%rax), %r12d
pushq $0x3
popq %rbp
cmpl $0x0, 0x8(%rsp)
jle 0x2957
movq 0x8(%rsp), %rax
decl %eax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
movl (%r15), %eax
cmpl %eax, %r13d
jge 0x2952
movq 0x8(%r15), %rcx
imull %r12d, %eax
addl %r13d, %eax
cltq
movl (%rcx,%rax,4), %eax
movb %al, 0x4(%rsp)
movb %ah, 0x5(%rsp)
shrl $0x10, %eax
movb %al, 0x6(%rsp)
leaq 0x4(%rsp), %rdi
pushq $0x1
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x1180
incl %r13d
cmpl $0x3, %eax
je 0x290e
jmp 0x28d4
decl %r12d
jmp 0x28f8
xorl %ebx, %ebx
jmp 0x28d4