// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %rdi
movw $0x4d42, (%rdi)         # imm = 0x4D42
movl $0x1, %esi
movl $0x2, %edx
movq %rbx, %rcx
callq 0x1170
cmpl $0x2, %eax
jne 0x2e44
movl (%r14), %eax
imull 0x4(%r14), %eax
leal (%rax,%rax,2), %eax
addl $0x36, %eax
leaq 0xc(%rsp), %rdi
movl %eax, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1170
cmpl $0x4, %eax
jne 0x2e44
leaq 0xc(%rsp), %rdi
movl $0x0, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1170
cmpl $0x4, %eax
jne 0x2e44
leaq 0xc(%rsp), %rdi
movl $0x36, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1170
cmpl $0x4, %eax
jne 0x2e44
leaq 0xc(%rsp), %rdi
movl $0x28, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1170
cmpl $0x4, %eax
jne 0x2e44
movl (%r14), %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
jne 0x2e44
movl 0x4(%r14), %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
jne 0x2e44
leaq 0xc(%rsp), %rdi
movw $0x1, (%rdi)
movl $0x1, %esi
movl $0x2, %edx
movq %rbx, %rcx
callq 0x1170
cmpl $0x2, %eax
jne 0x2e44
leaq 0xc(%rsp), %rdi
movw $0x18, (%rdi)
movl $0x1, %esi
movl $0x2, %edx
movq %rbx, %rcx
callq 0x1170
cmpl $0x2, %eax
jne 0x2e44
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
jne 0x2e44
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
jne 0x2e44
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
jne 0x2e44
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
jne 0x2e44
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
jne 0x2e44
xorl %ebp, %ebp
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2eaf
testl %eax, %eax
je 0x2e5d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r14), %r15d
testl %r15d, %r15d
jle 0x2e49
movl (%r14), %eax
leal -0x1(%r15), %r12d
xorl %ebp, %ebp
testl %eax, %eax
jle 0x2e9d
xorl %r13d, %r13d
movq 0x8(%r14), %rcx
imull %r12d, %eax
cltq
addq %r13, %rax
movl (%rcx,%rax,4), %edi
movq %rbx, %rsi
callq 0x2eda
testl %eax, %eax
jne 0x2e44
movl (%r14), %eax
incq %r13
cmpl %eax, %r13d
jl 0x2e76
leal -0x1(%r15), %ecx
decl %r12d
cmpl $0x2, %r15d
movl %ecx, %r15d
jge 0x2e6f
jmp 0x2e49