// File: /workspace/github_cpp_makefile_star2_O3/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
movq 0x330bba(%rip), %rsi    # 0x340160
movl $0x42, %edi
callq 0x9480
movq 0x330ba9(%rip), %rsi    # 0x340160
movl $0x4d, %edi
callq 0x9480
movl 0x20923d(%rip), %eax    # 0x218804
subl %ebx, %eax
imull 0x209230(%rip), %eax    # 0x218800
movl %eax, %edi
shrl $0x1f, %edi
addl %eax, %edi
sarl %edi
addl $0x76, %edi
callq 0xf536
xorl %r15d, %r15d
xorl %edi, %edi
callq 0xf536
movl $0x76, %edi
callq 0xf536
movl $0x28, %edi
callq 0xf536
movl 0x2091fb(%rip), %edi    # 0x218800
callq 0xf536
movl 0x2091f4(%rip), %edi    # 0x218804
subl %ebx, %edi
callq 0xf536
movq 0x330b42(%rip), %rsi    # 0x340160
movl $0x1, %edi
callq 0x9480
movq 0x330b31(%rip), %rsi    # 0x340160
xorl %edi, %edi
callq 0x9480
movq 0x330b23(%rip), %rsi    # 0x340160
movl $0x4, %edi
callq 0x9480
movq 0x330b12(%rip), %rsi    # 0x340160
xorl %edi, %edi
callq 0x9480
xorl %edi, %edi
callq 0xf536
movl 0x2091a2(%rip), %eax    # 0x218804
movl %ebx, -0x2c(%rbp)
subl %ebx, %eax
imull 0x209192(%rip), %eax    # 0x218800
movl %eax, %edi
shrl $0x1f, %edi
addl %eax, %edi
sarl %edi
callq 0xf536
xorl %edi, %edi
callq 0xf536
xorl %edi, %edi
callq 0xf536
movl $0x10, %edi
callq 0xf536
movl $0x10, %edi
callq 0xf536
leaq 0x3309bb(%rip), %r12    # 0x340060
xorl %r13d, %r13d
movl %r15d, %eax
testl %r14d, %r14d
je 0xf6d6
cmpl $0xf, %r13d
je 0xf6cf
cmpl $0xe, %r13d
je 0xf6c8
testl %r13d, %r13d
jne 0xf6d3
movl $0x3c, %eax
jmp 0xf6d6
movl $0x40, %eax
jmp 0xf6d6
xorl %eax, %eax
jmp 0xf6d6
movl %r15d, %eax
movl %eax, %ebx
movsbl (%rbx,%r12), %edi
movq 0x330a7c(%rip), %rsi    # 0x340160
callq 0x9480
movsbl 0x1(%rbx,%r12), %edi
movq 0x330a6a(%rip), %rsi    # 0x340160
callq 0x9480
movsbl 0x2(%rbx,%r12), %edi
movq 0x330a58(%rip), %rsi    # 0x340160
callq 0x9480
movsbl 0x3(%rbx,%r12), %edi
movq 0x330a46(%rip), %rsi    # 0x340160
callq 0x9480
incl %r13d
addl $0x4, %r15d
cmpl $0x10, %r13d
jne 0xf6a8
movl 0x2090cd(%rip), %r14d   # 0x218804
movl -0x2c(%rbp), %ebx
cmpl %ebx, %r14d
jle 0xf794
decl %r14d
callq 0xd1efe
cmpl $0x0, 0x2090b2(%rip)    # 0x218800
jle 0xf73a
xorl %r15d, %r15d
movl %r15d, %edi
movl %r14d, %esi
callq 0xf11f
movl %eax, %r12d
shlb $0x4, %r12b
leal 0x1(%r15), %edi
movl %r14d, %esi
callq 0xf11f
andb $0xf, %al
orb %r12b, %al
movq 0x3309e3(%rip), %rsi    # 0x340160
movsbl %al, %edi
callq 0x9480
addl $0x2, %r15d
cmpl 0x209070(%rip), %r15d   # 0x218800
jl 0xf753
jmp 0xf73a
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq