// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heather.cpp
// Function: dump_screen(int, int, char*)
int dump_screen(int invert, int top_line, char *fn)
{
int x, y;
int redraw;
int do_gif;

   strcpy(out, fn);
   if(strstr(out, ".") == 0) {
      #ifdef GIF_FILES
         strcat(out, ".gif");
      #else
         strcat(out, ".bmp");
      #endif
   }

   bmp_file = topen(out, "wb");
   if(bmp_file == 0) return 0;

   strlwr(out);
   if(strstr(out, ".gif") || strstr(out, ".GIF")) do_gif = 1;
   else do_gif = 0;

   redraw = 0;
   if(mouse_plot_valid && (last_mouse_x >= 0)) {
      if(0) {
         x = PLOT_COL+last_mouse_x;
         y = PLOT_ROW+8;
         line(x-1,PLOT_ROW, x-1,y, WHITE);
         line(x+0,PLOT_ROW, x+0,y, WHITE);
         line(x+1,PLOT_ROW, x+1,y, WHITE);
         line(x-3,y+1,  x+3,y+1, WHITE);
         line(x-2,y+2,  x+2,y+2, WHITE);
         line(x-1,y+3,  x+1,y+3, WHITE);
         line(x-0,y+4,  x+0,y+4, WHITE);
      }
      else {
         x = PLOT_COL+last_mouse_x;
         y = last_mouse_y;
         thick_line(x-5,y-5, x+5,y+5, WHITE, 2);
         thick_line(x+5,y-5, x-5,y+5, WHITE, 2);

//       line(x-5,y-5, x+5,y-5, WHITE);
//       line(x-5,y+5, x+5,y+5, WHITE);
//       line(x-5,y-5, x-5,y+5, WHITE);
//       line(x+5,y-5, x+5,y+5, WHITE);
      }
      redraw = 1;
   }

   if(do_screen_dump == 0) {  // keyboard commanded dump
      BEEP(5);                // beep because this can take a while to do
   }

#ifdef USE_X11   // capture the screen image into a buffer
   if(display == 0) return 0;
   if(capture_image) XDestroyImage(capture_image);
   SWAP(SCREEN_WIDTH, SCREEN_HEIGHT);
   capture_image = XGetImage(display,win, 0,0, SCREEN_WIDTH,SCREEN_HEIGHT, AllPlanes,XYPixmap);
   SWAP(SCREEN_WIDTH, SCREEN_HEIGHT);
#endif

   #ifdef GIF_FILES
      if(do_gif) {
         dump_gif_file(invert, top_line, bmp_file);
      }
      else
   #endif
   {
      dump_bmp_file(invert, top_line);
   }

   fclose(bmp_file);
   bmp_file = 0;

#ifdef USE_X11  // free uo the image capture buffer
   if(capture_image) XDestroyImage(capture_image);
   capture_image = 0;
#endif

   if(do_screen_dump == 0) {
      BEEP(6);
   }

   if(redraw) redraw_screen();
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movl %edi, %r14d
leaq 0x32ca5b(%rip), %r15    # 0x33c220
movq %r15, %rdi
movq %rdx, %rsi
callq 0x9340
movq %r15, %rdi
movl $0x2e, %esi
callq 0x9100
testq %rax, %rax
jne 0xf7f8
movq %r15, %rdi
callq 0x9120
movl $0x6669672e, (%rax,%r15) # imm = 0x6669672E
movb $0x0, 0x4(%rax,%r15)
leaq 0x32ca21(%rip), %rdi    # 0x33c220
leaq 0xfa768(%rip), %rsi     # 0x109f6e
callq 0x9a47
movq %rax, 0x33094e(%rip)    # 0x340160
testq %rax, %rax
je 0xf9b5
movl %ebx, -0x3c(%rbp)
movb 0x32c9fc(%rip), %al     # 0x33c220
testb %al, %al
je 0xf843
leaq 0x32c9f2(%rip), %rbx    # 0x33c221
movsbl %al, %edi
callq 0x9580
movb %al, -0x1(%rbx)
movb (%rbx), %al
incq %rbx
testb %al, %al
jne 0xf82f
leaq 0x32c9d6(%rip), %rdi    # 0x33c220
leaq 0xfb39f(%rip), %rsi     # 0x10abf0
callq 0x9090
testq %rax, %rax
movl %r14d, -0x38(%rbp)
je 0xf868
movl $0x0, -0x30(%rbp)
jmp 0xf884
leaq 0x32c9b1(%rip), %rdi    # 0x33c220
leaq 0xfa6fb(%rip), %rsi     # 0x109f71
callq 0x9090
testq %rax, %rax
sete %al
movl %eax, -0x30(%rbp)
cmpb $0x0, 0x20b9cd(%rip)    # 0x21b258
sete %cl
movl 0x20b9fc(%rip), %eax    # 0x21b290
testl %eax, %eax
sets %dl
orb %cl, %dl
movb %dl, -0x29(%rbp)
jne 0xf953
movl 0x208fd6(%rip), %ecx    # 0x218880
movl 0x20b9e4(%rip), %edx    # 0x21b294
leal (%rcx,%rax), %esi
addl $-0x5, %esi
movq %rsi, -0x50(%rbp)
addl %ecx, %eax
addl $0x5, %eax
movq %rax, -0x48(%rbp)
addl $0x5, %edx
movl %edx, -0x34(%rbp)
xorl %ebx, %ebx
movq -0x50(%rbp), %rax
leal (%rbx,%rax), %r15d
movq -0x48(%rbp), %rax
leal (%rbx,%rax), %r12d
movl $0x2, %r14d
movl -0x34(%rbp), %eax
movl %eax, %r13d
leal -0xa(%r13), %esi
movl %r15d, %edi
movl %r12d, %edx
movl %r13d, %ecx
movl $0xf, %r8d
callq 0xe38a
incl %r13d
decl %r14d
jne 0xf8e7
incl %ebx
cmpl $0x2, %ebx
jne 0xf8cb
xorl %ebx, %ebx
movq -0x48(%rbp), %rax
leal (%rbx,%rax), %r15d
movq -0x50(%rbp), %rax
leal (%rbx,%rax), %r12d
movl $0x2, %r14d
movl -0x34(%rbp), %eax
movl %eax, %r13d
leal -0xa(%r13), %esi
movl %r15d, %edi
movl %r12d, %edx
movl %r13d, %ecx
movl $0xf, %r8d
callq 0xe38a
incl %r13d
decl %r14d
jne 0xf92c
incl %ebx
cmpl $0x2, %ebx
jne 0xf910
cmpb $0x0, 0x2fe640(%rip)    # 0x30df9a
jne 0xf966
movl $0x5, %edi
callq 0x9d78
cmpq $0x0, 0x161552(%rip)    # 0x170ec0
movl -0x3c(%rbp), %ebx
movl -0x38(%rbp), %r14d
je 0xf9b5
movq 0x3305d2(%rip), %rdi    # 0x33ff50
testq %rdi, %rdi
je 0xf986
callq *0x60(%rdi)
cmpl $0x0, 0x208e9b(%rip)    # 0x218828
movl 0x208e6d(%rip), %eax    # 0x218800
movl 0x208e6a(%rip), %r8d    # 0x218804
je 0xf9bc
movl %r8d, 0x208e89(%rip)    # 0x21882c
movl %eax, 0x208e5b(%rip)    # 0x218804
movl %r8d, 0x208e50(%rip)    # 0x218800
movl %eax, %r9d
jmp 0xf9c2
xorl %ebx, %ebx
jmp 0xfa86
movl %r8d, %r9d
movl %eax, %r8d
movq 0x1614f7(%rip), %rdi    # 0x170ec0
movq 0x161500(%rip), %rsi    # 0x170ed0
xorl %edx, %edx
xorl %ecx, %ecx
pushq $0x1
pushq $-0x1
callq 0x9040
addq $0x10, %rsp
movq %rax, 0x330568(%rip)    # 0x33ff50
cmpl $0x0, 0x208e39(%rip)    # 0x218828
je 0xfa0f
movl 0x208e0d(%rip), %eax    # 0x218804
movl %eax, 0x208e2f(%rip)    # 0x21882c
movl 0x208dfd(%rip), %ecx    # 0x218800
movl %ecx, 0x208dfb(%rip)    # 0x218804
movl %eax, 0x208df1(%rip)    # 0x218800
cmpb $0x0, -0x30(%rbp)
je 0xfa21
movl %r14d, %edi
movl %ebx, %esi
callq 0xf58c
jmp 0xfa32
movq 0x330738(%rip), %rdx    # 0x340160
movl %r14d, %edi
movl %ebx, %esi
callq 0x104a90
movq 0x330727(%rip), %rdi    # 0x340160
callq 0x9370
movq $0x0, 0x330717(%rip) # 0x340160
movq 0x330500(%rip), %rdi    # 0x33ff50
testq %rdi, %rdi
je 0xfa58
callq *0x60(%rdi)
movq $0x0, 0x3304ed(%rip) # 0x33ff50
cmpb $0x0, 0x2fe530(%rip)    # 0x30df9a
jne 0xfa76
movl $0x6, %edi
callq 0x9d78
movl $0x1, %ebx
cmpb $0x0, -0x29(%rbp)
jne 0xfa86
callq 0xfa97
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq