// File: /workspace/github_c_makefile_star2_O1/moefh[P]hed/src/file_sel.c
// Function: hed_select_file
int hed_select_file(struct hed_editor *editor, char *filename, size_t max_filename_len)
{
  clear_msg();

  struct hed_screen *scr = &editor->screen;
  struct file_sel file_sel;
  init_file_sel(&file_sel, editor);
  change_dir(&file_sel, ".");
  
  reset_color();
  clear_screen();
  scr->redraw_needed = true;
  while (! editor->quit && ! file_sel.quit) {
    if (scr->redraw_needed)
      draw_main_screen(&file_sel);
    process_input(&file_sel);
  }

  if (file_sel.ret >= 0) {
    if (file_sel.sel)
      snprintf(filename, max_filename_len, "%s/%s", file_sel.dir_name, file_sel.sel->filename);
    else
      file_sel.ret = -1;
  }
  
  destroy_file_sel(&file_sel);

  reset_color();
  clear_screen();
  scr->redraw_needed = true;
  return file_sel.ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, %r14
callq 0x2e12
movq %rsp, %rdi
movq %r14, (%rdi)
movb $0x0, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
movl $0xffffffff, 0xc(%rdi)  # imm = 0xFFFFFFFF
movq $0x0, 0x30(%rdi)
leaq 0x3b5d(%rip), %rsi      # 0x7523
callq 0x3e63
callq 0x31ee
callq 0x325e
movb $0x1, 0x115(%r14)
cmpb $0x0, (%r14)
jne 0x3dd6
testb $0x1, 0x8(%rsp)
jne 0x3dd6
leaq 0x3de6(%rip), %r13      # 0x77df
leaq 0x60(%rsp), %r15
movq %r14, 0x50(%rsp)
cmpb $0x1, 0x115(%r14)
jne 0x3c82
movq (%rsp), %rbp
cmpb $0x1, 0x114(%rbp)
jne 0x3a2f
callq 0x31ee
callq 0x325e
movb $0x0, 0x114(%rbp)
callq 0x31ee
movl $0x1e, %edi
movl $0x2f, %esi
callq 0x3184
movl $0x1, %edi
movl $0x1, %esi
callq 0x320a
callq 0x31fc
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
je 0x3a78
movl 0x10c(%rbp), %esi
addl $-0x1e, %esi
leaq 0x3ad5(%rip), %rdi      # 0x7546
xorl %eax, %eax
callq 0x2ebb
movl 0x10c(%rbp), %edi
addl $-0x9, %edi
movl $0x1, %esi
callq 0x320a
leaq 0x3e9b(%rip), %rdi      # 0x792d
leaq 0x3ab8(%rip), %rsi      # 0x7551
xorl %eax, %eax
callq 0x2ebb
callq 0x31ee
callq 0x31ee
movl 0x110(%rbp), %esi
decl %esi
movl $0x1, %edi
callq 0x320a
cmpb $0x0, 0x119(%rbp)
je 0x3aec
leaq 0x119(%rbp), %r14
movl $0x1e, %edi
movl $0x2f, %esi
callq 0x3184
leaq 0x3e4a(%rip), %rdi      # 0x792c
movq %r14, %rsi
xorl %eax, %eax
callq 0x2ebb
callq 0x31fc
movl 0x110(%rbp), %esi
movl $0x1, %edi
leaq 0x3a57(%rip), %rdx      # 0x755a
leaq 0x3a53(%rip), %rcx      # 0x755d
callq 0x43c9
callq 0x31fc
movq 0x30(%rsp), %rax
xorl %ecx, %ecx
leaq 0x18(%rsp), %r15
movq (%r15), %r15
cmpq %rax, %rcx
jae 0x3b30
incq %rcx
testq %r15, %r15
jne 0x3b20
movq 0x20(%rsp), %rax
incq %rax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
cmovaeq %rcx, %rax
movl 0x10c(%rbp), %ecx
addl $-0x14, %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
testq %r15, %r15
je 0x3c44
movl %ecx, 0x3c(%rsp)
movslq %ecx, %r12
xorl %ebx, %ebx
movq %rbp, 0x58(%rsp)
leal 0x6(%rbx), %eax
cmpl 0x110(%rbp), %eax
jge 0x3c46
cmpq 0x28(%rsp), %r15
je 0x3b86
callq 0x31ee
jmp 0x3b95
movl $0x1e, %edi
movl $0x2f, %esi
callq 0x3184
leal 0x3(%rbx), %esi
movl $0x1, %edi
callq 0x320a
leaq 0x28(%r15), %r14
movq %r14, %rdi
callq 0x3925
movq %rax, %rbp
cmpq %rax, %r12
jae 0x3bcd
leaq 0x398f(%rip), %rdi      # 0x754c
movl 0x3c(%rsp), %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2ebb
jmp 0x3bde
leaq 0x3d59(%rip), %rdi      # 0x792d
movq %r14, %rsi
xorl %eax, %eax
callq 0x2ebb
movq %r12, %r14
subq %rbp, %r14
jbe 0x3bf5
movq %r13, %rdi
xorl %eax, %eax
callq 0x2ebb
decq %r14
jne 0x3be6
cmpb $0x0, 0x18(%r15)
movq 0x58(%rsp), %rbp
je 0x3c15
movq 0x20(%r15), %rsi
leaq 0x3919(%rip), %rdi      # 0x7525
xorl %eax, %eax
callq 0x2ebb
jmp 0x3c23
leaq 0x3915(%rip), %rdi      # 0x7531
xorl %eax, %eax
callq 0x2ebb
cmpq 0x28(%rsp), %r15
jne 0x3c2f
callq 0x31ee
incl %ebx
callq 0x31fc
movq (%r15), %r15
testq %r15, %r15
jne 0x3b69
jmp 0x3c46
xorl %ebx, %ebx
addl $0x6, %ebx
cmpl 0x110(%rbp), %ebx
jge 0x3c6c
callq 0x31ee
leal -0x3(%rbx), %esi
movl $0x1, %edi
callq 0x320a
callq 0x31fc
incl %ebx
jmp 0x3c49
callq 0x2e43
movb $0x0, 0x115(%rbp)
movq 0x50(%rsp), %r14
leaq 0x60(%rsp), %r15
movq (%rsp), %rbx
movl 0x108(%rbx), %edi
movl $0x40, %edx
movq %r15, %rsi
callq 0x2890
cmpl $0x110001, %eax         # imm = 0x110001
jg 0x3ce6
leal -0xc(%rax), %ecx
cmpl $0xd, %ecx
ja 0x3d97
leaq 0x37f5(%rip), %rdx      # 0x74a8
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x28(%rsp), %rsi
testq %rsi, %rsi
je 0x3dc5
cmpb $0x1, 0x18(%rsi)
jne 0x3db2
movb $0x1, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
jmp 0x3dc5
leal -0x111002(%rax), %ecx
cmpl $0x7, %ecx
ja 0x3d84
leaq 0x37e4(%rip), %rdx      # 0x74e0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x3dc5
movq %rax, 0x28(%rsp)
movq 0x10(%rax), %rax
movq 0x30(%rsp), %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
jmp 0x3d69
movq 0x28(%rsp), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x3dc5
movslq 0x110(%rbx), %rax
addq $-0x6, %rax
movq %rcx, 0x28(%rsp)
movq 0x30(%rsp), %rdx
addq %rax, %rdx
decq %rdx
movq 0x10(%rcx), %rcx
cmpq %rcx, %rdx
jae 0x3dbe
subq %rax, %rcx
incq %rcx
movq %rcx, 0x30(%rsp)
jmp 0x3dbe
movq %rsp, %rdi
callq 0x42a9
jmp 0x3dc5
movq %rsp, %rdi
callq 0x4258
jmp 0x3dc5
cmpl $0x110002, %eax         # imm = 0x110002
jne 0x3dc5
callq 0x31ee
callq 0x325e
jmp 0x3dbe
cmpl $0x3, %eax
jne 0x3dc5
movb $0x1, %al
movb %al, 0x115(%rbx)
movb %al, 0x8(%rsp)
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
jmp 0x3dc5
addq $0x28, %rsi
movq %rsp, %rdi
callq 0x3e63
movb $0x1, 0x115(%rbx)
cmpb $0x0, (%r14)
jne 0x3dd6
testb $0x1, 0x8(%rsp)
je 0x3a03
cmpl $0x0, 0xc(%rsp)
js 0x3e12
movq 0x28(%rsp), %r8
testq %r8, %r8
je 0x3e0a
movq 0x10(%rsp), %rcx
addq $0x28, %r8
leaq 0x3709(%rip), %rdx      # 0x7500
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
xorl %eax, %eax
callq 0x2100
jmp 0x3e12
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3e21
callq 0x2030
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x3e3b
movq (%rdi), %rbx
callq 0x2030
movq %rbx, %rdi
testq %rbx, %rbx
jne 0x3e2b
callq 0x31ee
callq 0x325e
movb $0x1, 0x115(%r14)
movl 0xc(%rsp), %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq