// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: hed_run_editor
int hed_run_editor(struct hed_editor *editor, size_t start_cursor_pos)
{
  if (! editor->file) {
    struct hed_file *file = hed_new_file_from_data(NULL, 0);
    if (! file) {
      fprintf(stderr, "ERROR: out of memory\n");
      return -1;
    }
    hed_add_file(editor, file);
  }
  
  if (hed_init_screen(&editor->screen) < 0) {
    fprintf(stderr, "ERROR setting up terminal\n");
    return -1;
  }
  hed_set_cursor_pos(editor, start_cursor_pos, 16);
  
  show_cursor(false);
  clear_screen();
    
  editor->quit = false;
  while (! editor->quit) {
    if (editor->screen.redraw_needed)
      draw_main_screen(editor);
    process_input(editor);
  }

  reset_color();
  clear_screen();
  show_cursor(true);
  hed_scr_flush();
  destroy_editor(editor);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x628(%rdi)
jne 0x4252
xorl %edi, %edi
xorl %esi, %esi
callq 0x30e8
testq %rax, %rax
je 0x49db
movq %rbx, %rdi
movq %rax, %rsi
callq 0x401d
leaq 0x108(%rbx), %rdi
callq 0x2af0
testl %eax, %eax
js 0x49c6
pushq $0x10
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4154
xorl %edi, %edi
callq 0x30ac
callq 0x30ca
movb $0x0, (%rbx)
leaq 0x3(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x40(%rsp), %r14
pushq $0x40
popq %r12
leaq 0x80(%rsp), %r13
xorl %eax, %eax
testb $0x1, %al
jne 0x4979
cmpb $0x1, 0x115(%rbx)
jne 0x42b8
movq %rbx, %rdi
callq 0x49fc
movq 0x628(%rbx), %rbp
movl 0x108(%rbx), %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x278c
movl %eax, %r15d
movb $0x0, 0x118(%rbx)
leal -0x1(%r15), %eax
cmpl $0x18, %eax
jbe 0x435b
leal -0x111000(%r15), %eax
cmpl $0x9, %eax
jbe 0x43a0
leal -0x112005(%r15), %eax
cmpl $0xa, %eax
jbe 0x43bd
cmpl $0x11201c, %r15d        # imm = 0x11201C
je 0x4454
cmpl $0x11101a, %r15d        # imm = 0x11101A
je 0x4454
cmpl $0x11101b, %r15d        # imm = 0x11101B
je 0x4447
cmpl $0x112015, %r15d        # imm = 0x112015
je 0x472d
cmpl $0x112017, %r15d        # imm = 0x112017
je 0x473e
cmpl $0x110002, %r15d        # imm = 0x110002
jne 0x488a
callq 0x305c
jmp 0x443d
leaq 0x323e(%rip), %rcx      # 0x75a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x628(%rbx), %rax
testq %rax, %rax
je 0x488a
movq 0x18(%rax), %rcx
movq 0x38(%rax), %rsi
testq %rcx, %rcx
je 0x47c9
imulq $0x64, %rsi, %rax
decq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
jmp 0x47cb
leaq 0x325d(%rip), %rcx      # 0x7604
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x5756
jmp 0x488a
leaq 0x3268(%rip), %rcx      # 0x762c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x1, 0x2c(%rbp)
setne %al
movl %eax, 0x2c(%rbp)
jmp 0x4883
movq 0x628(%rbx), %rax
andq $-0x10, 0x38(%rax)
jmp 0x4883
movq %rbx, %rdi
callq 0x582d
jmp 0x488a
movq %rbx, %rdi
callq 0x572b
jmp 0x488a
movq %rbx, %rdi
callq 0x57ee
jmp 0x488a
movq %rbx, %rdi
callq 0x5889
jmp 0x488a
movq %rbx, %rdi
callq 0x5793
jmp 0x488a
movq %rbx, %rdi
callq 0x58f0
jmp 0x488a
callq 0x30ca
jmp 0x4883
movq %rbx, %rdi
callq 0x56d4
jmp 0x488a
movq 0x628(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rax)
jmp 0x4883
movq 0x628(%rbx), %rax
xorb $0x1, 0x29(%rax)
jmp 0x4883
cmpq $0x0, 0x10(%rbp)
je 0x47b6
movq %rbx, %rdi
callq 0x5501
jmp 0x488a
movq 0x628(%rbx), %rax
cmpb $0x1, 0x28(%rax)
jne 0x486b
leaq 0x34a8(%rip), %rdi      # 0x794f
leaq 0x3412(%rip), %rsi      # 0x78c0
xorl %eax, %eax
callq 0x2bb0
movl $0x3, 0x104(%rbx)
movb $0x1, 0x115(%rbx)
cmpb $0x1, (%rbx)
je 0x488a
cmpb $0x1, 0x115(%rbx)
jne 0x44e0
movq %rbx, %rdi
callq 0x49fc
movl 0x110(%rbx), %esi
addl $-0x2, %esi
pushq $0x36
popq %rdi
callq 0x3078
pushq $0x1
popq %rdi
callq 0x30ac
callq 0x2cbb
movl 0x108(%rbx), %edi
movq %r13, %rsi
movq %r12, %rdx
callq 0x278c
movl %eax, %r14d
leal -0x4e(%r14), %eax
cmpl $0x2b, %eax
ja 0x452f
movabsq $0x80100000801, %rcx    # imm = 0x80100000801
btq %rax, %rcx
jb 0x4768
cmpl $0x3, %r14d
je 0x4768
cmpl $0x110002, %r14d        # imm = 0x110002
leaq 0x40(%rsp), %r14
jne 0x44c6
xorl %edi, %edi
callq 0x30ac
callq 0x305c
callq 0x30ca
pushq $0x1
popq %rdi
callq 0x30ac
jmp 0x44bf
movb $0x0, 0x80(%rsp)
movq %rbx, %rdi
leaq 0x33d7(%rip), %rsi      # 0x7952
movq %r13, %r14
movq %r13, %rdx
callq 0x5995
movb $0x1, 0x115(%rbx)
testl %eax, %eax
js 0x45b3
movq %r14, %rdi
callq 0x3153
testq %rax, %rax
je 0x45b3
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x401d
movq %r14, 0x628(%rbx)
movq 0x628(%rbx), %rbp
leaq 0x40(%rsp), %r14
jmp 0x488a
testq %rbp, %rbp
je 0x4761
cmpq $0x0, 0x10(%rbp)
je 0x488a
movq 0x628(%rbx), %rax
movl 0x34(%rax), %eax
testl %eax, %eax
leaq 0x3888(%rip), %r14      # 0x7e73
leaq 0x33cd(%rip), %rcx      # 0x79bf
cmoveq %rcx, %r14
cmpb $0x0, 0x3(%rbx)
je 0x480c
cmpl $0x1, %eax
movl $0x0, %r12d
adcq $0xb, %r12
movq 0x8(%rsp), %rdi
callq 0x20e0
leaq (%r12,%rax), %rcx
addq $-0x1f, %rcx
cmpq $-0x2a, %rcx
ja 0x47e1
pushq $0x1e
popq %r8
subl %r12d, %r8d
leaq 0x10(%rsp), %r12
movq %r12, %rdi
pushq $0x28
popq %rsi
leaq 0x338a(%rip), %rdx      # 0x79cc
movq %r14, %rcx
jmp 0x47f9
xorl %eax, %eax
cmpl $0x0, 0x34(%rbp)
sete %al
movl %eax, 0x34(%rbp)
jmp 0x4883
movq %rbx, %rdi
callq 0x5d00
jmp 0x4883
movq 0x628(%rbx), %rax
movq 0x8(%rax), %rbp
jmp 0x4710
cmpq $0x0, 0x10(%rbp)
je 0x488a
movb $0x0, 0x80(%rsp)
movl $0x2, 0x104(%rbx)
movq %rbx, %rdi
leaq 0x328f(%rip), %rsi      # 0x792e
movq %r13, %rdx
callq 0x59a1
testl %eax, %eax
js 0x488a
andq $0x0, 0x10(%rsp)
callq 0x2040
movq %rax, %r14
andl $0x0, (%rax)
movq %r13, %r12
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x2260
cmpl $0x0, (%r14)
jne 0x46e7
movq 0x10(%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x484c
leaq 0x324d(%rip), %rdi      # 0x793b
movq %r12, %rsi
xorl %eax, %eax
callq 0x2bb0
leaq 0x40(%rsp), %r14
pushq $0x40
popq %r12
jmp 0x488a
movq 0x628(%rbx), %rax
movq (%rax), %rbp
movq %rbp, 0x628(%rbx)
movb $0x1, 0x115(%rbx)
callq 0x305c
callq 0x30ca
jmp 0x488a
xorl %eax, %eax
cmpl $0x1, 0x30(%rbp)
setne %al
movl %eax, 0x30(%rbp)
jmp 0x4883
testq %rbp, %rbp
movq 0x8(%rsp), %rax
je 0x4761
cmpq $0x0, 0x10(%rbp)
je 0x488a
cmpb $0x0, (%rax)
jne 0x4842
jmp 0x488a
xorl %ebp, %ebp
jmp 0x488a
andl $0x0, 0x104(%rbx)
xorl %edi, %edi
callq 0x30ac
callq 0x2c91
cmpl $0x3, %r14d
je 0x45ba
andl $-0x21, %r14d
cmpl $0x4e, %r14d
leaq 0x40(%rsp), %r14
je 0x486b
movq 0x628(%rbx), %rdi
movq 0x20(%rdi), %rsi
testq %rsi, %rsi
je 0x485f
callq 0x32bb
jmp 0x4867
leaq 0x315f(%rip), %rdi      # 0x791c
xorl %eax, %eax
callq 0x2bb0
jmp 0x488a
xorl %ecx, %ecx
leaq 0x3122(%rip), %rdi      # 0x78f4
movq %rsi, %rdx
xorl %eax, %eax
callq 0x2bb0
jmp 0x488a
leaq 0x10(%rsp), %r12
movq %r12, %rdi
pushq $0x28
popq %rsi
leaq 0x31e6(%rip), %rdx      # 0x79d9
movq %r14, %rcx
movl %eax, %r8d
movq 0x8(%rsp), %r9
xorl %eax, %eax
callq 0x2100
movq %r12, %r14
pushq $0x40
popq %r12
movb $0x0, 0x80(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x5995
testl %eax, %eax
leaq 0x40(%rsp), %r14
js 0x488a
cmpb $0x0, 0x80(%rsp)
je 0x4842
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x2050
movq %rbx, %rdi
callq 0x5572
jmp 0x488a
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x10
popq %rdx
callq 0x4154
jmp 0x46f8
movq %rbx, %rdi
callq 0x5501
testl %eax, %eax
js 0x488a
movq %rbx, %rdi
callq 0x4083
movq 0x628(%rbx), %rbp
testq %rbp, %rbp
je 0x4974
movb $0x1, 0x115(%rbx)
cmpb $0x0, 0x2(%rbx)
jne 0x4956
movq 0x10(%rbp), %rax
testq %rax, %rax
je 0x48d7
movq 0x38(%rbp), %rcx
cmpq 0x18(%rbp), %rcx
jae 0x48d7
cmpl $0x1, 0x34(%rbp)
jne 0x48e3
leal -0x20(%r15), %edx
cmpl $0x5e, %edx
ja 0x48d7
movb %r15b, (%rax,%rcx)
movq 0x628(%rbx), %rax
movb $0x1, %bpl
movb %bpl, 0x28(%rax)
movq %rbx, %rdi
callq 0x5793
movb %bpl, 0x115(%rbx)
cmpb $0x1, 0x1(%rbx)
jne 0x4956
movb $0x0, 0x1(%rbx)
jmp 0x494f
leal -0x30(%r15), %edx
cmpl $0xa, %edx
jb 0x490b
leal -0x61(%r15), %edx
cmpl $0x5, %edx
ja 0x48fb
addl $-0x57, %r15d
jmp 0x4908
leal -0x47(%r15), %edx
cmpl $-0x6, %edx
jb 0x48d7
addl $-0x37, %r15d
movl %r15d, %edx
cmpb $0x0, 0x1(%rbx)
je 0x492e
movb $0x0, 0x1(%rbx)
andb $-0x10, (%rax,%rcx)
movq 0x10(%rbp), %rax
movq 0x38(%rbp), %rcx
orb %dl, (%rax,%rcx)
movq %rbx, %rdi
callq 0x5793
jmp 0x4944
movb $0x1, 0x1(%rbx)
andb $0xf, (%rax,%rcx)
movq 0x10(%rbp), %rax
movq 0x38(%rbp), %rcx
shlb $0x4, %dl
orb %dl, (%rax,%rcx)
movq 0x628(%rbx), %rax
movb $0x1, 0x28(%rax)
movb $0x1, 0x115(%rbx)
cmpb $0x0, 0x118(%rbx)
jne 0x496d
cmpb $0x0, 0x119(%rbx)
je 0x496d
callq 0x2c91
movb (%rbx), %al
jmp 0x429f
movb $0x1, (%rbx)
jmp 0x496d
callq 0x305c
callq 0x30ca
pushq $0x1
popq %rdi
callq 0x30ac
callq 0x2cbb
movq 0x628(%rbx), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x49b2
movq (%rdi), %r14
callq 0x3134
movq %r14, %rdi
cmpq 0x628(%rbx), %r14
jne 0x499e
movl %ebp, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x662b(%rip), %rax      # 0xaff8
movq (%rax), %rcx
leaq 0x2d01(%rip), %rdi      # 0x76d8
pushq $0x1a
jmp 0x49ee
movq 0x6616(%rip), %rax      # 0xaff8
movq (%rax), %rcx
leaq 0x2682(%rip), %rdi      # 0x706e
pushq $0x15
popq %rsi
pushq $0x1
popq %rdx
callq 0x22a0
pushq $-0x1
popq %rbp
jmp 0x49b2