// File: /workspace/github_c_makefile_star2_O2/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 $0xb8, %rsp
movq %rdx, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdi, %r14
callq 0x2c91
leaq 0x10(%rsp), %rdi
movq %r14, (%rdi)
movb $0x0, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
orl $-0x1, 0xc(%rdi)
andq $0x0, 0x30(%rdi)
leaq 0x436b(%rip), %rsi      # 0x7a71
callq 0x3b60
callq 0x305c
callq 0x30ca
movb $0x1, 0x115(%r14)
pushq $0x1
popq %r15
leaq 0x70(%rsp), %rbx
pushq $0x40
popq %r12
movq %r14, 0x50(%rsp)
cmpb $0x0, (%r14)
jne 0x3ae9
testb $0x1, 0x18(%rsp)
jne 0x3ae9
movq 0x10(%rsp), %rbp
cmpb $0x1, 0x115(%r14)
jne 0x39d7
cmpb $0x1, 0x114(%rbp)
jne 0x3771
callq 0x305c
callq 0x30ca
movb $0x0, 0x114(%rbp)
callq 0x305c
pushq $0x1e
popq %rdi
pushq $0x2f
popq %rsi
callq 0x2ff2
movl %r15d, %edi
movl %r15d, %esi
callq 0x3078
callq 0x306a
movq 0x20(%rsp), %rdx
testq %rdx, %rdx
je 0x37b2
movl 0x10c(%rbp), %esi
addl $-0x1e, %esi
leaq 0x3dbe(%rip), %rdi      # 0x7569
xorl %eax, %eax
callq 0x2d2c
movl 0x10c(%rbp), %edi
addl $-0x9, %edi
movl %r15d, %esi
callq 0x3078
leaq 0x4185(%rip), %rdi      # 0x794f
leaq 0x3da3(%rip), %rsi      # 0x7574
xorl %eax, %eax
callq 0x2d2c
callq 0x305c
callq 0x305c
movl 0x110(%rbp), %esi
decl %esi
movl %r15d, %edi
callq 0x3078
cmpb $0x0, 0x119(%rbp)
je 0x381e
leaq 0x119(%rbp), %rbx
pushq $0x1e
popq %rdi
pushq $0x2f
popq %rsi
callq 0x2ff2
leaq 0x413a(%rip), %rdi      # 0x794e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2d2c
callq 0x306a
movl 0x110(%rbp), %esi
movl %r15d, %edi
leaq 0x3d4a(%rip), %rdx      # 0x757d
leaq 0x3d46(%rip), %rcx      # 0x7580
callq 0x40c5
callq 0x306a
movq 0x40(%rsp), %rax
xorl %ecx, %ecx
leaq 0x28(%rsp), %r13
movq (%r13), %r13
cmpq %rax, %rcx
jae 0x3861
incq %rcx
testq %r13, %r13
jne 0x3850
movq 0x30(%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
movl %ecx, 0x4c(%rsp)
movslq %ecx, %r14
xorl %ebx, %ebx
pushq $0x3
popq %rax
movl %eax, %r12d
movq %rbp, 0x58(%rsp)
testq %r13, %r13
je 0x3991
leal 0x6(%rbx), %eax
cmpl 0x110(%rbp), %eax
jge 0x3991
cmpq 0x38(%rsp), %r13
je 0x38bd
callq 0x305c
jmp 0x38c8
pushq $0x1e
popq %rdi
pushq $0x2f
popq %rsi
callq 0x2ff2
movq %rbx, 0x8(%rsp)
leal 0x3(%rbx), %esi
movl %r15d, %ebp
movl %r15d, %edi
callq 0x3078
leaq 0x28(%r13), %r15
movq %r15, %rdi
callq 0x3671
movq %rax, %rbx
cmpq %r14, %rax
jbe 0x3906
leaq 0x3c79(%rip), %rdi      # 0x756f
movl 0x4c(%rsp), %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2d2c
jmp 0x3917
leaq 0x4042(%rip), %rdi      # 0x794f
movq %r15, %rsi
xorl %eax, %eax
callq 0x2d2c
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
movl %ebp, %r15d
leaq 0x3ed4(%rip), %rbp      # 0x7801
cmpq %r14, %rbx
jae 0x3941
movq %rbp, %rdi
xorl %eax, %eax
callq 0x2d2c
incq %rbx
jmp 0x392d
cmpb $0x0, 0x18(%r13)
je 0x395c
movq 0x20(%r13), %rsi
leaq 0x3bf5(%rip), %rdi      # 0x7548
xorl %eax, %eax
callq 0x2d2c
jmp 0x396a
leaq 0x3bf1(%rip), %rdi      # 0x7554
xorl %eax, %eax
callq 0x2d2c
movq 0x58(%rsp), %rbp
movq 0x8(%rsp), %rbx
cmpq 0x38(%rsp), %r13
jne 0x3980
callq 0x305c
callq 0x306a
movq (%r13), %r13
incl %r12d
jmp 0x3897
movq 0x50(%rsp), %r14
leal 0x3(%r12), %eax
cmpl 0x110(%rbp), %eax
jge 0x39bd
callq 0x305c
movl %r15d, %edi
movl %r12d, %esi
callq 0x3078
callq 0x306a
incl %r12d
jmp 0x3996
callq 0x2cbb
movb $0x0, 0x115(%rbp)
movq 0x10(%rsp), %rbp
leaq 0x70(%rsp), %rbx
pushq $0x40
popq %r12
movl 0x108(%rbp), %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x278c
leal -0xc(%rax), %ecx
cmpl $0xd, %ecx
ja 0x3a27
leaq 0x3ad9(%rip), %rdx      # 0x74d0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x38(%rsp), %rsi
testq %rsi, %rsi
je 0x372f
cmpb $0x1, 0x18(%rsi)
jne 0x3acf
movb $0x1, 0x18(%rsp)
andl $0x0, 0x1c(%rsp)
jmp 0x372f
leal -0x111002(%rax), %ecx
cmpl $0x7, %ecx
ja 0x3a70
leaq 0x3acf(%rip), %rdx      # 0x7508
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x372f
movq %rax, 0x38(%rsp)
movq 0x10(%rax), %rax
movq 0x40(%rsp), %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rcx, 0x40(%rsp)
jmp 0x3add
cmpl $0x3, %eax
je 0x3ab9
cmpl $0x110002, %eax         # imm = 0x110002
jne 0x372f
callq 0x305c
callq 0x30ca
jmp 0x3add
leaq 0x10(%rsp), %rdi
callq 0x3fad
jmp 0x372f
leaq 0x10(%rsp), %rdi
callq 0x3f5e
jmp 0x372f
leaq 0x10(%rsp), %rdi
callq 0x3f1b
jmp 0x372f
movb $0x1, %al
movb %al, 0x115(%rbp)
movb %al, 0x18(%rsp)
orl $-0x1, 0x1c(%rsp)
jmp 0x372f
addq $0x28, %rsi
leaq 0x10(%rsp), %rdi
callq 0x3b60
movb $0x1, 0x115(%rbp)
jmp 0x372f
movl 0x1c(%rsp), %ebx
testl %ebx, %ebx
js 0x3b21
movq 0x38(%rsp), %r8
testq %r8, %r8
je 0x3b1e
movq 0x20(%rsp), %rcx
addq $0x28, %r8
leaq 0x3a1d(%rip), %rdx      # 0x7528
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
xorl %eax, %eax
callq 0x2100
jmp 0x3b21
pushq $-0x1
popq %rbx
movq 0x20(%rsp), %rdi
callq 0x2030
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3b3a
callq 0x3ee2
callq 0x305c
callq 0x30ca
movb $0x1, 0x115(%r14)
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq