// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb $0x42, -0x420(%rbp)
movb $0x4d, -0x41f(%rbp)
leaq -0x420(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
movl $0x2, %edx
callq 0x1160
movl %eax, -0x424(%rbp)
cmpl $0x2, -0x424(%rbp)
je 0x3786
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x4(%rcx), %eax
imull $0x3, %eax, %edi
addl $0x36, %edi
movq -0x18(%rbp), %rsi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x37be
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x37e4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
movl $0x36, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x380d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
movl $0x28, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x3836
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x10(%rbp), %rax
movl (%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x3860
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x18(%rbp), %rsi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x388b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
movl $0x1, %edi
callq 0x3b00
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x38b4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
movl $0x18, %edi
callq 0x3b00
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x38dd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x3903
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x3929
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x394f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x3975
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x399b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x3a80
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x39c1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x42c(%rbp)
cmpl $0x0, -0x42c(%rbp)
jl 0x3a63
movl $0x0, -0x428(%rbp)
movl -0x428(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x3a4d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x428(%rbp), %ecx
movl -0x42c(%rbp), %edx
movq -0x10(%rbp), %rsi
imull (%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edi
movq -0x18(%rbp), %rsi
callq 0x3b70
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
je 0x3a3a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3a6a
jmp 0x3a3c
movl -0x428(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x428(%rbp)
jmp 0x39e8
jmp 0x3a4f
movl -0x42c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x42c(%rbp)
jmp 0x39d1
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
nopw %cs:(%rax,%rax)