// File: /workspace/github_c_makefile_star2_O1/neovim[P]libtermkey/driver-ti.c
// Function: start_driver
static int start_driver(TermKey *tk, void *info)
{
  TermKeyTI *ti = info;
  struct stat statbuf;
  char *start_string;
  size_t len;

  if(!ti->root)
    load_terminfo(ti);

  start_string = ti->start_string;

  if(tk->fd == -1 || !start_string)
    return 1;

  /* The terminfo database will contain keys in application cursor key mode.
   * We may need to enable that mode
   */

  /* There's no point trying to write() to a pipe */
  if(fstat(tk->fd, &statbuf) == -1)
    return 0;

#ifndef _WIN32
  if(S_ISFIFO(statbuf.st_mode))
    return 1;
#endif

  // Can't call putp or tputs because they suck and don't give us fd control
  len = strlen(start_string);
  while(len) {
    size_t written = write(tk->fd, start_string, len);
    if(written == -1)
      return 0;
    start_string += written;
    len -= written;
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x10(%rsi)
jne 0x663f
movq 0x8(%r14), %rdi
leaq 0x48(%rsp), %rdx
movl $0x1, %esi
callq 0x3200
testl %eax, %eax
jne 0x663f
movl $0x808, %edi            # imm = 0x808
callq 0x31c0
testq %rax, %rax
je 0x640c
movq %rax, %r15
movl $0x1, (%rax)
movw $0xff00, 0x4(%rax)      # imm = 0xFF00
movq %rax, %rdi
addq $0x8, %rdi
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x3130
jmp 0x640f
xorl %r15d, %r15d
movq %r15, 0x10(%r14)
testq %r15, %r15
je 0x663f
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
leaq 0xfc1(%rip), %rbp       # 0x73ee
movl $0x18, %ebx
leaq 0x35b7(%rip), %r13      # 0x99f0
leaq 0x1c(%rsp), %r15
movq %r15, %rdi
leaq 0xf81(%rip), %rsi       # 0x73c9
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3280
movl -0x10(%rbx,%r13), %r14d
movl -0xc(%rbx,%r13), %r12d
movl %r14d, 0x48(%rsp)
movl %r12d, 0x4c(%rsp)
movl -0x8(%rbx,%r13), %r13d
movl %r13d, 0x50(%rsp)
movl %r13d, 0x54(%rsp)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0x48(%rsp), %rdx
callq 0x68ef
testb %al, %al
je 0x64ce
leaq 0x1c(%rsp), %r15
movq %r15, %rdi
leaq 0xf36(%rip), %rsi       # 0x73d0
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3280
movl %r14d, 0x2c(%rsp)
movl %r12d, 0x30(%rsp)
orl $0x1, %r13d
movl %r13d, 0x34(%rsp)
movl %r13d, 0x38(%rsp)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0x2c(%rsp), %rdx
callq 0x68ef
leaq 0x351b(%rip), %r13      # 0x99f0
movq (%rbx,%r13), %rbp
addq $0x18, %rbx
cmpq $0x3f0, %rbx            # imm = 0x3F0
jne 0x6439
movl $0x1, %r12d
leaq 0xee1(%rip), %r15       # 0x73d8
leaq 0x3f(%rsp), %r13
leaq 0x1c(%rsp), %rbp
movq 0x8(%rsp), %r14
movq %r13, %rdi
movq %r15, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x3280
movl $0x1, 0x1c(%rsp)
movl %r12d, 0x20(%rsp)
movq $0x0, 0x24(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x68ef
testb %al, %al
je 0x654f
leal 0x1(%r12), %eax
cmpl $0xfe, %r12d
movl %eax, %r12d
jne 0x6506
cmpq $0x0, 0x8(%r14)
je 0x6567
leaq 0xe83(%rip), %rdi       # 0x73e0
callq 0x3260
movq %rax, %r15
jmp 0x656a
xorl %r15d, %r15d
movq (%r14), %rcx
movq 0x78(%rcx), %rax
testq %rax, %rax
je 0x658c
movq 0x80(%rcx), %rdx
leaq 0xe5c(%rip), %rdi       # 0x73e0
movq %r15, %rsi
callq *%rax
movq %rax, %r15
testq %r15, %r15
je 0x65d7
leaq 0xe52(%rip), %rsi       # 0x73ea
movq %r15, %rdi
callq 0x3170
testl %eax, %eax
jne 0x65d7
movl $0x14, %edi
callq 0x31c0
testq %rax, %rax
je 0x65c7
movsd 0xdf5(%rip), %xmm0      # 0x73b0
movups %xmm0, (%rax)
movl $0x0, 0x10(%rax)
jmp 0x65c9
xorl %eax, %eax
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x69a2
movq 0x39f2(%rip), %rax      # 0x9fd0
movq (%rax), %rax
movq 0x20(%rax), %rbx
movq 0x2c8(%rbx), %rdi
testq %rdi, %rdi
je 0x65f8
callq 0x32b0
jmp 0x65fa
xorl %eax, %eax
movq %rax, 0x18(%r14)
movq 0x2c0(%rbx), %rdi
testq %rdi, %rdi
je 0x6611
callq 0x32b0
jmp 0x6613
xorl %eax, %eax
movq 0x10(%rsp), %rbx
movq %rax, 0x20(%r14)
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x662a
callq 0x3050
movq $0x0, 0x8(%r14)
movq 0x10(%r14), %rdi
callq 0x6aab
movq %rax, 0x10(%r14)
movq 0x18(%r14), %r14
movl (%rbx), %edi
cmpl $-0x1, %edi
setne %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6677
leaq 0x48(%rsp), %rsi
callq 0x32d0
cmpl $-0x1, %eax
je 0x667e
movl $0xf000, %eax           # imm = 0xF000
andl 0x60(%rsp), %eax
cmpl $0x1000, %eax           # imm = 0x1000
jne 0x6682
movl $0x1, %eax
jmp 0x66bd
xorl %eax, %eax
jmp 0x66bd
movq %r14, %rdi
callq 0x30f0
movq %rax, %r15
testq %r15, %r15
je 0x6677
movl (%rbx), %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x30e0
movq %rax, %rcx
xorl %eax, %eax
cmpq $-0x1, %rcx
movl $0x0, %edx
cmovneq %rcx, %rdx
addq %rdx, %r14
subq %rdx, %r15
cmpq $-0x1, %rcx
jne 0x668d
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq