// File: /workspace/github_c_makefile_star2_O0/moefh[P]hed/src/editor.c
// Function: draw_file_dump
static void draw_file_dump(struct hed_editor *editor)
{
  struct hed_file *file = editor->file;

  move_cursor(1, EDITOR_HEADER_LINES + 1);

  int clear_space_at_line = -1;
  int num_lines = get_num_displayed_file_lines(editor);
  for (int i = 0; i < num_lines; i++) {
    size_t pos = 16 * (file->top_line + i);
    if (pos >= file->data_len) {
      clear_space_at_line = i;
      break;
    }
    set_bold(false);
    out("%08x ", (unsigned) pos);
    box_draw("| ");
    int len = (file->data_len - pos < 16) ? file->data_len - pos : 16;
    char buf[17];
    set_bold(file->pane == HED_PANE_HEX && ! editor->read_only);
    for (int j = 0; j < len; j++) {
      uint8_t b = file->data[pos+j];

      if (j == 8)
        out(" ");

      if (file->cursor_pos == pos + j) {
        int cur_x = file->cursor_pos % 16;
        int cur_y = file->cursor_pos / 16 - file->top_line;
        move_cursor(11 + 3*cur_x + (j >= 8), 3 + cur_y);
        set_color(FG_BLACK,
                  ((editor->half_byte_edited) ? BG_YELLOW
                    : (file->pane == HED_PANE_HEX && ! editor->read_only) ? BG_GREEN
                    : BG_GRAY));
        set_bold(false);
        out(" ");
      }
      out("%02x ", b);
      if (file->cursor_pos == pos + j) {
        reset_color();
        set_bold(file->pane == HED_PANE_HEX && ! editor->read_only);
      }

      buf[j] = (b < 32 || b >= 0x7f) ? '.' : b;
    }
    for (int j = len; j < 16; j++) {
      out("   ");
      if (j == 8)
        out(" ");
      buf[j] = ' ';
    }
    buf[16] = '\0';
    set_bold(false);
    box_draw("| ");

    set_bold(file->pane == HED_PANE_TEXT && ! editor->read_only);
    if (file->cursor_pos >= pos && file->cursor_pos <= pos + 16) {
      int n_before = file->cursor_pos - pos;
      out("%.*s", n_before, buf);
      set_color(FG_BLACK, (file->pane == HED_PANE_TEXT && ! editor->read_only) ? BG_GREEN : BG_GRAY);
      set_bold(false);
      out("%c", buf[n_before]);
      reset_color();
      set_bold(file->pane == HED_PANE_TEXT && ! editor->read_only);
      if (n_before < 16)
        out("%.*s", 16-n_before-1, buf + n_before + 1);
      out("\r\n");
    } else
      out("%s\r\n", buf);
  }
  //move_cursor(1, 10); out("%d,%d", cur_x, cur_y);

  if (clear_space_at_line >= 0) {
    for (int i = clear_space_at_line; i < num_lines; i++) {
      clear_eol();
      out("\r\n");
    }
  }
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0x628(%rax), %rax
movq %rax, 0x78(%rsp)
movl $0x1, %edi
movl $0x3, %esi
callq 0x3d80
movl $0xffffffff, 0x74(%rsp) # imm = 0xFFFFFFFF
movq 0x80(%rsp), %rdi
callq 0x6610
movl %eax, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0x70(%rsp), %eax
jge 0x7e1b
movq 0x78(%rsp), %rax
movq 0x40(%rax), %rax
movslq 0x6c(%rsp), %rcx
addq %rcx, %rax
shlq $0x4, %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq 0x78(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jb 0x79c8
movl 0x6c(%rsp), %eax
movl %eax, 0x74(%rsp)
jmp 0x7e1b
xorl %edi, %edi
callq 0x3cc0
movq 0x60(%rsp), %rax
movl %eax, %esi
leaq 0x3beb(%rip), %rdi      # 0xb5c8
movb $0x0, %al
callq 0x3850
leaq 0x3be3(%rip), %rdi      # 0xb5ce
callq 0x3990
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rax
subq 0x60(%rsp), %rax
cmpq $0x10, %rax
jae 0x7a19
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rax
subq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x7a25
movl $0x10, %eax
movq %rax, 0x18(%rsp)
jmp 0x7a25
movq 0x18(%rsp), %rax
movl %eax, 0x5c(%rsp)
movq 0x78(%rsp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x34(%rcx)
movb %al, 0x17(%rsp)
jne 0x7a50
movq 0x80(%rsp), %rax
movb 0x2(%rax), %al
xorb $-0x1, %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x3cc0
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x7c35
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x60(%rsp), %rcx
movslq 0x3c(%rsp), %rdx
addq %rdx, %rcx
movb (%rax,%rcx), %al
movb %al, 0x3b(%rsp)
cmpl $0x8, 0x3c(%rsp)
jne 0x7aa7
leaq 0x3b77(%rip), %rdi      # 0xb617
movb $0x0, %al
callq 0x3850
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x60(%rsp), %rcx
movslq 0x3c(%rsp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0x7b8a
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
andq $0xf, %rax
movl %eax, 0x34(%rsp)
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
shrq $0x4, %rax
movq 0x78(%rsp), %rcx
subq 0x40(%rcx), %rax
movl %eax, 0x30(%rsp)
imull $0x3, 0x34(%rsp), %edi
addl $0xb, %edi
cmpl $0x8, 0x3c(%rsp)
setge %al
andb $0x1, %al
movzbl %al, %eax
addl %eax, %edi
movl 0x30(%rsp), %esi
addl $0x3, %esi
callq 0x3d80
movq 0x80(%rsp), %rax
testb $0x1, 0x1(%rax)
je 0x7b2d
movl $0x2b, %eax
movl %eax, 0x10(%rsp)
jmp 0x7b67
movq 0x78(%rsp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x34(%rcx)
movb %al, 0xf(%rsp)
jne 0x7b4f
movq 0x80(%rsp), %rax
movb 0x2(%rax), %al
xorb $-0x1, %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %dl
movl $0x2f, %eax
movl $0x2a, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %esi
movl $0x1e, %edi
callq 0x3c80
xorl %edi, %edi
callq 0x3cc0
leaq 0x3a94(%rip), %rdi      # 0xb617
movb $0x0, %al
callq 0x3850
movzbl 0x3b(%rsp), %esi
leaq 0x3a3b(%rip), %rdi      # 0xb5d1
movb $0x0, %al
callq 0x3850
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x60(%rsp), %rcx
movslq 0x3c(%rsp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0x7bee
callq 0x3d40
movq 0x78(%rsp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x34(%rcx)
movb %al, 0xe(%rsp)
jne 0x7bdf
movq 0x80(%rsp), %rax
movb 0x2(%rax), %al
xorb $-0x1, %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x3cc0
movzbl 0x3b(%rsp), %eax
cmpl $0x20, %eax
jl 0x7c02
movzbl 0x3b(%rsp), %eax
cmpl $0x7f, %eax
jl 0x7c0d
movl $0x2e, %eax
movl %eax, 0x8(%rsp)
jmp 0x7c16
movzbl 0x3b(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movb %al, %cl
movslq 0x3c(%rsp), %rax
movb %cl, 0x40(%rsp,%rax)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x7a67
movl 0x5c(%rsp), %eax
movl %eax, 0x2c(%rsp)
cmpl $0x10, 0x2c(%rsp)
jge 0x7c7e
leaq 0x39ca(%rip), %rdi      # 0xb615
movb $0x0, %al
callq 0x3850
cmpl $0x8, 0x2c(%rsp)
jne 0x7c67
leaq 0x39b7(%rip), %rdi      # 0xb617
movb $0x0, %al
callq 0x3850
movslq 0x2c(%rsp), %rax
movb $0x20, 0x40(%rsp,%rax)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x7c3d
movb $0x0, 0x50(%rsp)
xorl %edi, %edi
callq 0x3cc0
leaq 0x393d(%rip), %rdi      # 0xb5ce
callq 0x3990
movq 0x78(%rsp), %rcx
xorl %eax, %eax
cmpl $0x1, 0x34(%rcx)
movb %al, 0x7(%rsp)
jne 0x7cb8
movq 0x80(%rsp), %rax
movb 0x2(%rax), %al
xorb $-0x1, %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x3cc0
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
cmpq 0x60(%rsp), %rax
jb 0x7df6
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x60(%rsp), %rcx
addq $0x10, %rcx
cmpq %rcx, %rax
ja 0x7df6
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
subq 0x60(%rsp), %rax
movl %eax, 0x28(%rsp)
movl 0x28(%rsp), %esi
leaq 0x40(%rsp), %rdx
leaq 0x37af(%rip), %rdi      # 0xb4c7
movb $0x0, %al
callq 0x3850
movq 0x78(%rsp), %rcx
xorl %eax, %eax
cmpl $0x1, 0x34(%rcx)
movb %al, 0x6(%rsp)
jne 0x7d41
movq 0x80(%rsp), %rax
movb 0x2(%rax), %al
xorb $-0x1, %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %cl
movl $0x2f, %esi
movl $0x2a, %eax
testb $0x1, %cl
cmovnel %eax, %esi
movl $0x1e, %edi
callq 0x3c80
xorl %edi, %edi
callq 0x3cc0
movslq 0x28(%rsp), %rax
movsbl 0x40(%rsp,%rax), %esi
leaq 0x35a9(%rip), %rdi      # 0xb320
movb $0x0, %al
callq 0x3850
callq 0x3d40
movq 0x78(%rsp), %rcx
xorl %eax, %eax
cmpl $0x1, 0x34(%rcx)
movb %al, 0x5(%rsp)
jne 0x7da5
movq 0x80(%rsp), %rax
movb 0x2(%rax), %al
xorb $-0x1, %al
movb %al, 0x5(%rsp)
movb 0x5(%rsp), %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x3cc0
cmpl $0x10, 0x28(%rsp)
jge 0x7de6
movl $0x10, %esi
subl 0x28(%rsp), %esi
subl $0x1, %esi
leaq 0x40(%rsp), %rdx
movslq 0x28(%rsp), %rax
addq %rax, %rdx
addq $0x1, %rdx
leaq 0x36e8(%rip), %rdi      # 0xb4c7
movb $0x0, %al
callq 0x3850
leaq 0x37ec(%rip), %rdi      # 0xb5d9
movb $0x0, %al
callq 0x3850
jmp 0x7e09
leaq 0x40(%rsp), %rsi
leaq 0x37d5(%rip), %rdi      # 0xb5d7
movb $0x0, %al
callq 0x3850
jmp 0x7e0b
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x7983
cmpl $0x0, 0x74(%rsp)
jl 0x7e56
movl 0x74(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x70(%rsp), %eax
jge 0x7e54
callq 0x3d60
leaq 0x3799(%rip), %rdi      # 0xb5d9
movb $0x0, %al
callq 0x3850
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x7e2a
jmp 0x7e56
addq $0x88, %rsp
retq
nop