// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heather.cpp
// Function: dump_bmp_file(int, int)
int dump_bmp_file(int invert, int top_line)
{
int x, y, c;

   // main header
   dump_byte('B');   dump_byte('M');                          // magic number
   dump_dword((SCREEN_HEIGHT-top_line)*SCREEN_WIDTH/2L+BM_HEADER_SIZE);  // file size
   dump_dword(0L);              // reserved
   dump_dword(BM_HEADER_SIZE);  // offset of bitmap data in the file

   // info header
   dump_dword(40L);             // info header length
   dump_dword(SCREEN_WIDTH);    // screen size
   dump_dword(SCREEN_HEIGHT-top_line);
   dump_word(1);                // number of planes
   dump_word(4);                // bits per pixel
   dump_dword(0L);              // no compression
   dump_dword(SCREEN_WIDTH*(SCREEN_HEIGHT-top_line)/2L);// picture size in bytes
   dump_dword(0L);              // horizontal resolution
   dump_dword(0L);              // vertical resolution
   dump_dword(16L);             // number of used colors
   dump_dword(16L);             // number of important colors

   // palette
   for(c=0; c<16; c++) {
      x = (c << 2);
      if(invert) {
         if     (c == WHITE)  x = (BLACK << 2);
         else if(c == BLACK)  x = (WHITE << 2);
         else if(c == YELLOW) x = (BMP_YELLOW << 2);
      }
      dump_byte(bmp_pal[x++]);
      dump_byte(bmp_pal[x++]);
      dump_byte(bmp_pal[x++]);
      dump_byte(bmp_pal[x]);
   }

   for(y=SCREEN_HEIGHT-1; y>=top_line; y--) {
      update_pwm();
      for(x=0; x<SCREEN_WIDTH; x+=2) {
         c = (get_pixel(x, y) & 0x0F) << 4;
         c |= (get_pixel(x+1, y) & 0x0F);
         dump_byte(c);
      }
   }

   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %r14d
pushq $0x42
popq %rdi
callq 0xefa0
pushq $0x4d
popq %rdi
callq 0xefa0
movl 0x1f37c7(%rip), %eax    # 0x202804
subl %ebx, %eax
imull 0x1f37ba(%rip), %eax    # 0x202800
pushq $0x2
popq %r15
cltd
idivl %r15d
leal 0x76(%rax), %edi
callq 0xefd5
xorl %r12d, %r12d
xorl %edi, %edi
callq 0xefd5
pushq $0x76
popq %rdi
callq 0xefd5
pushq $0x28
popq %rdi
callq 0xefd5
movl 0x1f378a(%rip), %edi    # 0x202800
callq 0xefd5
movl 0x1f3783(%rip), %edi    # 0x202804
subl %ebx, %edi
callq 0xefd5
pushq $0x1
popq %rdi
callq 0xefb5
pushq $0x4
popq %rdi
callq 0xefb5
xorl %edi, %edi
callq 0xefd5
movl 0x1f375f(%rip), %eax    # 0x202804
movl %ebx, -0x2c(%rbp)
subl %ebx, %eax
imull 0x1f374f(%rip), %eax    # 0x202800
cltd
idivl %r15d
movl %eax, %edi
callq 0xefd5
xorl %edi, %edi
callq 0xefd5
xorl %edi, %edi
callq 0xefd5
pushq $0x10
popq %r15
movl %r15d, %edi
callq 0xefd5
movl %r15d, %edi
callq 0xefd5
leaq 0x31af7b(%rip), %r15    # 0x32a060
xorl %r13d, %r13d
cmpl $0x10, %r13d
je 0xf14d
movl %r12d, %eax
testl %r14d, %r14d
je 0xf117
cmpl $0xf, %r13d
je 0xf110
cmpl $0xe, %r13d
je 0xf10b
testl %r13d, %r13d
jne 0xf114
pushq $0x3c
jmp 0xf10d
pushq $0x40
popq %rax
jmp 0xf117
xorl %eax, %eax
jmp 0xf117
movl %r12d, %eax
movl %eax, %ebx
movzbl (%rbx,%r15), %edi
callq 0xefa0
movzbl 0x1(%rbx,%r15), %edi
callq 0xefa0
movzbl 0x2(%rbx,%r15), %edi
callq 0xefa0
movzbl 0x3(%rbx,%r15), %edi
callq 0xefa0
incl %r13d
addl $0x4, %r12d
jmp 0xf0e8
movl 0x1f36b0(%rip), %r14d   # 0x202804
movl -0x2c(%rbp), %ebx
cmpl %ebx, %r14d
jle 0xf1a1
decl %r14d
callq 0xc067d
xorl %r15d, %r15d
cmpl 0x1f3692(%rip), %r15d   # 0x202800
jge 0xf157
movl %r15d, %edi
movl %r14d, %esi
callq 0xebd0
movl %eax, %r12d
shlb $0x4, %r12b
leal 0x1(%r15), %edi
movl %r14d, %esi
callq 0xebd0
andb $0xf, %al
orb %r12b, %al
movzbl %al, %edi
callq 0xefa0
addl $0x2, %r15d
jmp 0xf167
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq