// File: /workspace/github_c_makefile_star2_O3/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 0x4466
xorl %edi, %edi
xorl %esi, %esi
callq 0x321c
testq %rax, %rax
je 0x4d8f
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4220
leaq 0x108(%rbx), %rdi
callq 0x2c1c
testl %eax, %eax
js 0x4d88
movl $0x10, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4368
xorl %edi, %edi
callq 0x31e0
callq 0x31fe
movb $0x0, (%rbx)
leaq 0x3(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x40(%rsp), %r14
leaq 0x30f2(%rip), %rbp      # 0x75a0
leaq 0x80(%rsp), %r15
cmpb $0x1, 0x115(%rbx)
jne 0x44c7
movq %rbx, %rdi
callq 0x4d9b
movq 0x628(%rbx), %r13
movl 0x108(%rbx), %edi
movl $0x40, %edx
movq %r14, %rsi
callq 0x2898
movl %eax, %r12d
movb $0x0, 0x118(%rbx)
cmpl $0x110fff, %eax         # imm = 0x110FFF
jg 0x454a
leal -0x1(%r12), %eax
cmpl $0x18, %eax
ja 0x468e
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x4c41
decq %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4c3a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x4539
jmp 0x4a89
cmpl $0x11101a, %r12d        # imm = 0x11101A
jg 0x45b4
leal -0x111000(%r12), %eax
cmpl $0x9, %eax
ja 0x46aa
leaq 0x3099(%rip), %rcx      # 0x7604
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x4c41
decq %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4c3a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x45a3
jmp 0x4a89
cmpl $0x112014, %r12d        # imm = 0x112014
jg 0x45f1
leal -0x112005(%r12), %eax
cmpl $0xa, %eax
ja 0x46ca
leaq 0x3057(%rip), %rcx      # 0x762c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x1, 0x2c(%r13)
setne %al
movl %eax, 0x2c(%r13)
jmp 0x4c3a
cmpl $0x112015, %r12d        # imm = 0x112015
je 0x4ac9
cmpl $0x112017, %r12d        # imm = 0x112017
je 0x4adc
cmpl $0x11201c, %r12d        # imm = 0x11201C
je 0x46b7
jmp 0x4c41
movq %rbx, %rdi
callq 0x5c1f
jmp 0x4c41
movq 0x628(%rbx), %rax
movq 0x18(%rax), %rcx
movq 0x38(%rax), %rdx
orq $0xf, %rdx
movq %rdx, 0x38(%rax)
cmpq %rcx, %rdx
jb 0x4c3a
decq %rcx
movq %rcx, 0x38(%rax)
jmp 0x4c3a
movq %rbx, %rdi
callq 0x5b15
jmp 0x4c41
movq %rbx, %rdi
callq 0x5b9a
jmp 0x4c41
movq 0x628(%rbx), %rax
andq $-0x10, 0x38(%rax)
jmp 0x4c3a
movq %rbx, %rdi
callq 0x5c8d
jmp 0x4c41
cmpl $0x110002, %r12d        # imm = 0x110002
jne 0x4c41
callq 0x318e
callq 0x31fe
jmp 0x4c3a
cmpl $0x11101a, %r12d        # imm = 0x11101A
jne 0x4c41
movq 0x628(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rax)
jmp 0x4c3a
cmpl $0x11101b, %r12d        # imm = 0x11101B
jne 0x4c41
movq 0x628(%rbx), %rax
movzbl 0x29(%rax), %ecx
movslq 0x110(%rbx), %rdx
xorq $0x1, %rcx
leaq (%rcx,%rcx,4), %rcx
addq %rdx, %rcx
addq $-0xa, %rcx
movq 0x18(%rax), %rdx
movq %rdx, %rsi
shrq $0x4, %rsi
movl %edx, %edi
andl $0xf, %edi
cmpq $0x1, %rdi
sbbq $-0x1, %rsi
decq %rdx
movq %rdx, 0x38(%rax)
subq %rcx, %rsi
movl $0x0, %ecx
cmovaeq %rsi, %rcx
movq %rcx, 0x40(%rax)
jmp 0x4c3a
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
cmpq $0x10, %rcx
jb 0x4c41
addq $-0x10, %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4c3a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x475d
jmp 0x4a89
cmpq $0x0, 0x10(%r13)
je 0x4c41
movb $0x0, 0x80(%rsp)
movl $0x2, 0x104(%rbx)
movq %rbx, %rdi
leaq 0x3199(%rip), %rsi      # 0x792e
movq %r15, %rdx
callq 0x5d35
testl %eax, %eax
js 0x4c41
movq $0x0, 0x10(%rsp)
callq 0x2040
movq %rax, %rbp
movl $0x0, (%rax)
movq %r15, %r14
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
movl $0x10, %edx
callq 0x2260
cmpl $0x0, (%rbp)
jne 0x47e5
movq 0x10(%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x4c01
leaq 0x314f(%rip), %rdi      # 0x793b
movq %r14, %rsi
xorl %eax, %eax
callq 0x2ce6
jmp 0x4a06
movq 0x628(%rbx), %rax
movq 0x8(%rax), %r13
jmp 0x4812
movq 0x628(%rbx), %rax
movq (%rax), %r13
movq %r13, 0x628(%rbx)
movb $0x1, 0x115(%rbx)
callq 0x318e
callq 0x31fe
jmp 0x4c41
movq 0x628(%rbx), %rax
cmpb $0x1, 0x28(%rax)
jne 0x4c22
leaq 0x3108(%rip), %rdi      # 0x794f
leaq 0x3072(%rip), %rsi      # 0x78c0
xorl %eax, %eax
callq 0x2ce6
movl $0x3, 0x104(%rbx)
movb $0x1, 0x115(%rbx)
cmpb $0x0, (%rbx)
jne 0x4b51
cmpb $0x1, 0x115(%rbx)
jne 0x4880
movq %rbx, %rdi
callq 0x4d9b
movl 0x110(%rbx), %esi
addl $-0x2, %esi
movl $0x36, %edi
callq 0x31aa
movl $0x1, %edi
callq 0x31e0
callq 0x2de3
movl 0x108(%rbx), %edi
movl $0x40, %edx
movq %r15, %rsi
callq 0x2898
cmpl $0x110002, %eax         # imm = 0x110002
je 0x48e4
movl %eax, %ebp
leal -0x4e(%rbp), %eax
cmpl $0x2b, %eax
ja 0x48da
movabsq $0x80100000801, %rcx    # imm = 0x80100000801
btq %rax, %rcx
jb 0x4b32
cmpl $0x3, %ebp
jne 0x4906
jmp 0x4b32
xorl %edi, %edi
callq 0x31e0
callq 0x318e
callq 0x31fe
movl $0x1, %edi
callq 0x31e0
movb $0x1, 0x115(%rbx)
cmpb $0x1, (%rbx)
jne 0x486f
jmp 0x4b51
testq %r13, %r13
je 0x4aff
cmpq $0x0, 0x10(%r13)
je 0x4c41
movq 0x628(%rbx), %rax
movl 0x34(%rax), %eax
testl %eax, %eax
leaq 0x3538(%rip), %rbp      # 0x7e73
leaq 0x307d(%rip), %rcx      # 0x79bf
cmoveq %rcx, %rbp
cmpb $0x0, 0x3(%rbx)
je 0x4b8b
cmpl $0x1, %eax
movl $0x0, %r14d
adcq $0xb, %r14
movq 0x8(%rsp), %rdi
callq 0x20e0
leaq (%r14,%rax), %rcx
addq $-0x1f, %rcx
cmpq $-0x2a, %rcx
ja 0x4b5d
movl $0x1e, %r8d
subl %r14d, %r8d
movl $0x28, %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x3036(%rip), %rdx      # 0x79cc
movq %rbp, %rcx
jmp 0x4b77
movq %rbx, %rdi
callq 0x603c
jmp 0x4c3a
movb $0x0, 0x80(%rsp)
movl $0x1, 0x104(%rbx)
movq %rbx, %rdi
leaq 0x2f8b(%rip), %rsi      # 0x7952
movq %r15, %r14
movq %r15, %rdx
callq 0x5d35
movb $0x1, 0x115(%rbx)
testl %eax, %eax
js 0x49ff
movq %r14, %rdi
callq 0x3289
testq %rax, %rax
je 0x49ff
movq %rax, %rbp
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4220
movq %rbp, 0x628(%rbx)
movq 0x628(%rbx), %r13
leaq 0x2b93(%rip), %rbp      # 0x75a0
leaq 0x40(%rsp), %r14
jmp 0x4c41
movq 0x628(%rbx), %rax
testq %rax, %rax
je 0x4c41
movq 0x18(%rax), %rcx
movq 0x38(%rax), %rsi
testq %rcx, %rcx
je 0x4b1a
imulq $0x64, %rsi, %rax
decq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
jmp 0x4b1c
movq 0x628(%rbx), %rax
movq 0x38(%rax), %rcx
cmpq $0x10, %rcx
jb 0x4c41
addq $-0x10, %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rsi, %rcx
jae 0x4c3a
decq %rdx
addq $-0x10, %rsi
cmpq %rsi, %rcx
jb 0x4a7d
movq %rdx, 0x40(%rax)
jmp 0x4c3a
movq 0x628(%rbx), %rax
xorb $0x1, 0x29(%rax)
jmp 0x4c3a
cmpq $0x0, 0x10(%r13)
je 0x4b07
movq %rbx, %rdi
callq 0x5921
jmp 0x4c41
xorl %eax, %eax
cmpl $0x0, 0x34(%r13)
sete %al
movl %eax, 0x34(%r13)
jmp 0x4c3a
xorl %eax, %eax
cmpl $0x1, 0x30(%r13)
setne %al
movl %eax, 0x30(%r13)
jmp 0x4c3a
testq %r13, %r13
je 0x4aff
cmpq $0x0, 0x10(%r13)
je 0x4c41
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x4bd1
jmp 0x4c41
xorl %r13d, %r13d
jmp 0x4c41
leaq 0x2e0e(%rip), %rdi      # 0x791c
xorl %eax, %eax
callq 0x2ce6
jmp 0x4c41
xorl %ecx, %ecx
leaq 0x2dd1(%rip), %rdi      # 0x78f4
movq %rsi, %rdx
xorl %eax, %eax
callq 0x2ce6
jmp 0x4c41
movl $0x0, 0x104(%rbx)
xorl %edi, %edi
callq 0x31e0
callq 0x2db2
cmpl $0x3, %ebp
jne 0x4bdb
leaq 0x2a48(%rip), %rbp      # 0x75a0
jmp 0x4c41
movl $0x28, %esi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x2e68(%rip), %rdx      # 0x79d9
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
movq %r15, %rdx
callq 0x5d35
testl %eax, %eax
leaq 0x29ec(%rip), %rbp      # 0x75a0
js 0x4c41
cmpb $0x0, 0x80(%rsp)
je 0x4bd1
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2050
movq %rbx, %rdi
callq 0x599e
jmp 0x4c41
andl $-0x21, %ebp
cmpl $0x4e, %ebp
leaq 0x29b8(%rip), %rbp      # 0x75a0
je 0x4c22
movq 0x628(%rbx), %rdi
movq 0x20(%rdi), %rsi
testq %rsi, %rsi
je 0x4c16
callq 0x3415
jmp 0x4c1e
movl $0x10, %edx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4368
jmp 0x4a06
movq %rbx, %rdi
callq 0x5921
testl %eax, %eax
js 0x4c41
movq %rbx, %rdi
callq 0x4286
movq 0x628(%rbx), %r13
testq %r13, %r13
je 0x4d34
movb $0x1, 0x115(%rbx)
cmpb $0x0, 0x2(%rbx)
jne 0x4d12
movq 0x10(%r13), %rax
testq %rax, %rax
je 0x4c90
movq 0x38(%r13), %rcx
cmpq 0x18(%r13), %rcx
jae 0x4c90
cmpl $0x1, 0x34(%r13)
jne 0x4c9c
leal -0x20(%r12), %edx
cmpl $0x5e, %edx
ja 0x4c90
movb %r12b, (%rax,%rcx)
movq 0x628(%rbx), %rax
movb $0x1, %r12b
movb %r12b, 0x28(%rax)
movq %rbx, %rdi
callq 0x5b15
movb %r12b, 0x115(%rbx)
cmpb $0x1, 0x1(%rbx)
jne 0x4d12
movb $0x0, 0x1(%rbx)
jmp 0x4d0b
leal -0x30(%r12), %edx
cmpl $0xa, %edx
jb 0x4cc7
leal -0x61(%r12), %edx
cmpl $0x5, %edx
ja 0x4cb6
addl $-0x57, %r12d
jmp 0x4cc4
leal -0x47(%r12), %edx
cmpl $-0x6, %edx
jb 0x4c90
addl $-0x37, %r12d
movl %r12d, %edx
cmpb $0x0, 0x1(%rbx)
je 0x4cea
movb $0x0, 0x1(%rbx)
andb $-0x10, (%rax,%rcx)
movq 0x10(%r13), %rax
movq 0x38(%r13), %rcx
orb %dl, (%rax,%rcx)
movq %rbx, %rdi
callq 0x5b15
jmp 0x4d00
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)
movb $0x1, 0x115(%rbx)
cmpb $0x0, 0x118(%rbx)
jne 0x4d29
cmpb $0x0, 0x119(%rbx)
je 0x4d29
callq 0x2db2
cmpb $0x1, (%rbx)
jne 0x44b6
jmp 0x4d39
movb $0x1, (%rbx)
jmp 0x4d29
callq 0x318e
callq 0x31fe
movl $0x1, %edi
callq 0x31e0
callq 0x2de3
movq 0x628(%rbx), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x4d74
movq (%rdi), %r14
callq 0x3260
movq %r14, %rdi
cmpq 0x628(%rbx), %r14
jne 0x4d60
movl %ebp, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2384
jmp 0x4d94
callq 0x23a0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4d74