// File: /workspace/github_c_makefile_star2_O1/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 0x1160
cmpl $0x2, %eax
jne 0x2c63
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 0x1160
cmpl $0x4, %eax
jne 0x2c63
leaq 0xc(%rsp), %rdi
movl $0x0, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1160
cmpl $0x4, %eax
jne 0x2c63
leaq 0xc(%rsp), %rdi
movl $0x36, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1160
cmpl $0x4, %eax
jne 0x2c63
leaq 0xc(%rsp), %rdi
movl $0x28, (%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x1160
cmpl $0x4, %eax
jne 0x2c63
movl (%r14), %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
jne 0x2c63
movl 0x4(%r14), %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
jne 0x2c63
leaq 0xc(%rsp), %rdi
movw $0x1, (%rdi)
movl $0x1, %esi
movl $0x2, %edx
movq %rbx, %rcx
callq 0x1160
cmpl $0x2, %eax
jne 0x2c63
leaq 0xc(%rsp), %rdi
movw $0x18, (%rdi)
movl $0x1, %esi
movl $0x2, %edx
movq %rbx, %rcx
callq 0x1160
cmpl $0x2, %eax
jne 0x2c63
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
jne 0x2c63
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
jne 0x2c63
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
jne 0x2c63
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
jne 0x2c63
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
jne 0x2c63
xorl %ebp, %ebp
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2cce
testl %eax, %eax
je 0x2c7c
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 0x2c68
leal -0x1(%r15), %r12d
xorl %ebp, %ebp
movl (%r14), %eax
testl %eax, %eax
jle 0x2cbc
xorl %r13d, %r13d
movq 0x8(%r14), %rcx
imull %r12d, %eax
cltq
addq %r13, %rax
movl (%rcx,%rax,4), %edi
movq %rbx, %rsi
callq 0x2cf9
testl %eax, %eax
jne 0x2c63
movl (%r14), %eax
incq %r13
cmpl %eax, %r13d
jl 0x2c95
leal -0x1(%r15), %eax
decl %r12d
cmpl $0x2, %r15d
movl %eax, %r15d
jge 0x2c8b
jmp 0x2c68