// File: /workspace/github_c_makefile_star2_O1/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 0x4570
xorl %edi, %edi
xorl %esi, %esi
callq 0x327c
movq %rax, %r15
testq %rax, %rax
je 0x4eae
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4324
testq %r15, %r15
je 0x4e95
leaq 0x108(%rbx), %rdi
callq 0x2c7c
testl %eax, %eax
js 0x4e90
movl $0x10, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4466
xorl %edi, %edi
callq 0x3240
callq 0x325e
movb $0x0, (%rbx)
leaq 0x3(%rbx), %r15
leaq 0x40(%rsp), %r14
leaq 0x80(%rsp), %rbp
cmpb $0x1, 0x115(%rbx)
jne 0x45c5
movq %rbx, %rdi
callq 0x4eb8
movq 0x628(%rbx), %r13
movl 0x108(%rbx), %edi
movl $0x40, %edx
movq %r14, %rsi
callq 0x2890
movl %eax, %r12d
movb $0x0, 0x118(%rbx)
cmpl $0x110fff, %eax         # imm = 0x110FFF
jg 0x464e
leal -0x1(%r12), %eax
cmpl $0x18, %eax
ja 0x4792
leaq 0x2f7b(%rip), %rcx      # 0x7580
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x4d31
decq %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4d2a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x463d
jmp 0x4ba5
cmpl $0x11101a, %r12d        # imm = 0x11101A
jg 0x46b8
leal -0x111000(%r12), %eax
cmpl $0x9, %eax
ja 0x47ae
leaq 0x2f75(%rip), %rcx      # 0x75e4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x4d31
decq %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4d2a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x46a7
jmp 0x4ba5
cmpl $0x112014, %r12d        # imm = 0x112014
jg 0x46f5
leal -0x112005(%r12), %eax
cmpl $0xa, %eax
ja 0x47ce
leaq 0x2f33(%rip), %rcx      # 0x760c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x1, 0x2c(%r13)
setne %al
movl %eax, 0x2c(%r13)
jmp 0x4d2a
cmpl $0x112015, %r12d        # imm = 0x112015
je 0x4be5
cmpl $0x112017, %r12d        # imm = 0x112017
je 0x4bf8
cmpl $0x11201c, %r12d        # imm = 0x11201C
je 0x47bb
jmp 0x4d31
movq %rbx, %rdi
callq 0x5d6a
jmp 0x4d31
movq 0x628(%rbx), %rax
movq 0x18(%rax), %rcx
movq 0x38(%rax), %rdx
orq $0xf, %rdx
movq %rdx, 0x38(%rax)
cmpq %rcx, %rdx
jb 0x4d2a
decq %rcx
movq %rcx, 0x38(%rax)
jmp 0x4d2a
movq %rbx, %rdi
callq 0x5c6c
jmp 0x4d31
movq %rbx, %rdi
callq 0x5ceb
jmp 0x4d31
movq 0x628(%rbx), %rax
andq $-0x10, 0x38(%rax)
jmp 0x4d2a
movq %rbx, %rdi
callq 0x5dda
jmp 0x4d31
cmpl $0x110002, %r12d        # imm = 0x110002
jne 0x4d31
callq 0x31ee
callq 0x325e
jmp 0x4d2a
cmpl $0x11101a, %r12d        # imm = 0x11101A
jne 0x4d31
movq 0x628(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rax)
jmp 0x4d2a
cmpl $0x11101b, %r12d        # imm = 0x11101B
jne 0x4d31
movq %rbx, %rdi
callq 0x5c15
jmp 0x4d31
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
cmpq $0x10, %rcx
jb 0x4d31
addq $-0x10, %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4d2a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x4819
jmp 0x4ba5
cmpq $0x0, 0x10(%r13)
je 0x4d31
movb $0x0, 0x80(%rsp)
movl $0x2, 0x104(%rbx)
movq %rbx, %rdi
leaq 0x30bb(%rip), %rsi      # 0x790c
movq %rbp, %rdx
callq 0x5e83
testl %eax, %eax
js 0x4d31
movq $0x0, 0x10(%rsp)
callq 0x2040
movq %rbp, %rdi
movq %rax, %rbp
movl $0x0, (%rax)
leaq 0x10(%rsp), %rsi
movl $0x10, %edx
callq 0x2260
cmpl $0x0, (%rbp)
jne 0x489e
movq 0x10(%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x4e3e
leaq 0x3074(%rip), %rdi      # 0x7919
leaq 0x80(%rsp), %rbp
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2d46
jmp 0x4d31
movq 0x628(%rbx), %rax
movq 0x8(%rax), %r13
jmp 0x48d3
movq 0x628(%rbx), %rax
movq (%rax), %r13
movq %r13, 0x628(%rbx)
movb $0x1, 0x115(%rbx)
callq 0x31ee
callq 0x325e
jmp 0x4d31
movq 0x628(%rbx), %rax
cmpb $0x1, 0x28(%rax)
jne 0x4d12
movq %r15, 0x8(%rsp)
leaq 0x3020(%rip), %rdi      # 0x792d
leaq 0x2f8a(%rip), %rsi      # 0x789e
xorl %eax, %eax
callq 0x2d46
movl $0x3, 0x104(%rbx)
movb $0x1, 0x115(%rbx)
movb $0x1, %al
movl %eax, 0x4(%rsp)
cmpb $0x0, (%rbx)
jne 0x4c32
cmpb $0x1, 0x115(%rbx)
jne 0x494c
movq %rbx, %rdi
callq 0x4eb8
movl 0x110(%rbx), %esi
addl $-0x2, %esi
movl $0x36, %edi
callq 0x320a
movl $0x1, %edi
callq 0x3240
callq 0x2e43
movl 0x108(%rbx), %edi
movl $0x40, %edx
movq %rbp, %rsi
callq 0x2890
movl %eax, %ebp
leal -0x4e(%rbp), %eax
cmpl $0x2b, %eax
ja 0x49b2
movabsq $0x80100000801, %rcx    # imm = 0x80100000801
btq %rax, %rcx
jae 0x49b2
movl %ebp, %eax
andl $-0x21, %eax
cmpl $0x4e, %eax
je 0x49e6
cmpl $0x59, %eax
jne 0x49ee
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x49ee
cmpl $0x3, %ebp
je 0x499b
movb $0x1, %r14b
cmpl $0x110002, %ebp         # imm = 0x110002
jne 0x4a14
xorl %edi, %edi
callq 0x3240
callq 0x31ee
callq 0x325e
movl $0x1, %edi
callq 0x3240
movb $0x1, 0x115(%rbx)
jmp 0x4a14
movl $0x0, 0x4(%rsp)
movl $0x0, 0x104(%rbx)
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x3240
callq 0x2e12
xorl %r15d, %r15d
cmpl $0x3, %ebp
sete %r15b
negl %r15d
leaq 0x80(%rsp), %rbp
testb %r14b, %r14b
leaq 0x40(%rsp), %r14
jne 0x4932
jmp 0x4c38
testq %r13, %r13
je 0x4c17
cmpq $0x0, 0x10(%r13)
je 0x4d31
movq 0x628(%rbx), %rax
movl 0x34(%rax), %eax
testl %eax, %eax
leaq 0x33fd(%rip), %rbp      # 0x7e53
leaq 0x2f40(%rip), %rcx      # 0x799d
cmoveq %rcx, %rbp
cmpb $0x0, 0x3(%rbx)
je 0x4cbb
cmpl $0x1, %eax
movl $0x0, %r14d
adcq $0xb, %r14
movq %r15, %rdi
movq %r15, 0x8(%rsp)
callq 0x20e0
leaq (%r14,%rax), %rcx
addq $-0x1f, %rcx
cmpq $-0x2a, %rcx
ja 0x4c8d
movl $0x1e, %r8d
subl %r14d, %r8d
movl $0x28, %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x2ef6(%rip), %rdx      # 0x79aa
movq %rbp, %rcx
jmp 0x4ca7
movq %rbx, %rdi
callq 0x6200
jmp 0x4d2a
movb $0x0, 0x80(%rsp)
movl $0x1, 0x104(%rbx)
movq %rbx, %rdi
leaq 0x2e4b(%rip), %rsi      # 0x7930
movq %rbp, %rdx
callq 0x5e83
movb $0x1, 0x115(%rbx)
testl %eax, %eax
js 0x4b1f
leaq 0x80(%rsp), %rdi
callq 0x32f2
testq %rax, %rax
je 0x4b1f
movq %rax, %rbp
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4324
movq %rbp, 0x628(%rbx)
movq 0x628(%rbx), %r13
leaq 0x80(%rsp), %rbp
jmp 0x4d31
movq 0x628(%rbx), %rax
testq %rax, %rax
je 0x4d31
movq 0x18(%rax), %rcx
movq 0x38(%rax), %rsi
testq %rcx, %rcx
je 0x4c6b
imulq $0x64, %rsi, %rax
decq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
jmp 0x4c6d
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
cmpq $0x10, %rcx
jb 0x4d31
addq $-0x10, %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4d2a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x4b99
movq %rdx, 0x40(%rax)
jmp 0x4d2a
movq 0x628(%rbx), %rax
xorb $0x1, 0x29(%rax)
jmp 0x4d2a
cmpq $0x0, 0x10(%r13)
je 0x4c1f
movq %rbx, %rdi
callq 0x5a29
jmp 0x4d31
xorl %eax, %eax
cmpl $0x0, 0x34(%r13)
sete %al
movl %eax, 0x34(%r13)
jmp 0x4d2a
xorl %eax, %eax
cmpl $0x1, 0x30(%r13)
setne %al
movl %eax, 0x30(%r13)
jmp 0x4d2a
testq %r13, %r13
je 0x4c17
cmpq $0x0, 0x10(%r13)
je 0x4d31
cmpb $0x0, 0x3(%rbx)
jne 0x4cfc
jmp 0x4d31
xorl %r13d, %r13d
jmp 0x4d31
leaq 0x2cd4(%rip), %rdi      # 0x78fa
xorl %eax, %eax
callq 0x2d46
jmp 0x4d31
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testl %r15d, %r15d
js 0x4c83
testb $0x1, 0x4(%rsp)
movq 0x8(%rsp), %r15
je 0x4d12
movq 0x628(%rbx), %rdi
movq 0x20(%rdi), %rsi
testq %rsi, %rsi
je 0x4d06
callq 0x3486
jmp 0x4d0e
xorl %ecx, %ecx
leaq 0x2c5e(%rip), %rdi      # 0x78d2
movq %rsi, %rdx
xorl %eax, %eax
callq 0x2d46
jmp 0x4d31
movq 0x8(%rsp), %r15
jmp 0x4d31
movl $0x28, %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x2d16(%rip), %rdx      # 0x79b7
movq %rbp, %rcx
movl %eax, %r8d
movq 0x8(%rsp), %r9
xorl %eax, %eax
callq 0x2100
movq %r14, %rbp
leaq 0x40(%rsp), %r14
movb $0x0, 0x80(%rsp)
movl $0x1, 0x104(%rbx)
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x80(%rsp), %rbp
movq %rbp, %rdx
callq 0x5e83
testl %eax, %eax
js 0x4d31
cmpb $0x0, 0x80(%rsp)
je 0x4cfc
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2050
movq %rbx, %rdi
callq 0x5aa6
jmp 0x4d31
movq %rbx, %rdi
callq 0x5a29
testl %eax, %eax
js 0x4d31
movq %rbx, %rdi
callq 0x4380
movq 0x628(%rbx), %r13
testq %r13, %r13
je 0x4e39
movb $0x1, 0x115(%rbx)
cmpb $0x0, 0x2(%rbx)
jne 0x4df4
movq 0x10(%r13), %rax
testq %rax, %rax
je 0x4de3
movq 0x38(%r13), %rcx
cmpq 0x18(%r13), %rcx
jae 0x4de3
cmpl $0x1, 0x34(%r13)
jne 0x4d8a
leal -0x20(%r12), %edx
cmpl $0x5e, %edx
ja 0x4de3
movb %r12b, (%rax,%rcx)
movq 0x628(%rbx), %rax
movb $0x1, %r12b
movb %r12b, 0x28(%rax)
movq %rbx, %rdi
callq 0x5c6c
movb %r12b, 0x115(%rbx)
jmp 0x4de3
leal -0x30(%r12), %edx
cmpl $0xa, %edx
jb 0x4dbc
leal -0x61(%r12), %edx
cmpl $0x5, %edx
ja 0x4da4
addl $-0x57, %r12d
jmp 0x4db9
leal -0x41(%r12), %edx
addl $-0x37, %r12d
cmpl $0x6, %edx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmovael %edx, %r12d
movl %r12d, %edx
testl %edx, %edx
js 0x4de3
cmpb $0x0, 0x1(%rbx)
je 0x4e16
movb $0x0, 0x1(%rbx)
andb $-0x10, (%rax,%rcx)
movq 0x10(%r13), %rax
movq 0x38(%r13), %rcx
orb %dl, (%rax,%rcx)
movq %rbx, %rdi
callq 0x5c6c
jmp 0x4e2c
cmpb $0x1, 0x1(%rbx)
jne 0x4df4
movb $0x0, 0x1(%rbx)
movb $0x1, 0x115(%rbx)
cmpb $0x0, 0x118(%rbx)
jne 0x4e0b
cmpb $0x0, 0x119(%rbx)
je 0x4e0b
callq 0x2e12
cmpb $0x1, (%rbx)
jne 0x45b4
jmp 0x4e53
movb $0x1, 0x1(%rbx)
andb $0xf, (%rax,%rcx)
movq 0x10(%r13), %rax
movq 0x38(%r13), %rcx
shlb $0x4, %dl
orb %dl, (%rax,%rcx)
movq 0x628(%rbx), %rax
movb $0x1, 0x28(%rax)
jmp 0x4ded
movb $0x1, (%rbx)
jmp 0x4e0b
movl $0x10, %edx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4466
jmp 0x4b26
callq 0x31ee
callq 0x325e
movl $0x1, %edi
callq 0x3240
callq 0x2e43
movq 0x628(%rbx), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x4e9a
movq (%rdi), %r14
callq 0x32c9
movq %r14, %rdi
cmpq 0x628(%rbx), %r14
jne 0x4e7a
jmp 0x4e9a
callq 0x23a0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2384
jmp 0x4567