// File: /workspace/github_c_makefile_star2_O3/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 $0xe8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x10(%rsi)
jne 0x6300
movq 0x8(%r14), %rdi
leaq 0x50(%rsp), %rdx
movl $0x1, %esi
callq 0x3200
testl %eax, %eax
jne 0x6300
movl $0x808, %edi            # imm = 0x808
callq 0x31c0
testq %rax, %rax
je 0x6223
movq %rax, %r15
movq %rbx, 0x8(%rsp)
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
movq %r15, 0x10(%r14)
leaq 0x1680(%rip), %rbp      # 0x776e
movl $0x18, %ebx
leaq 0x10(%rsp), %r12
leaq 0x48f1(%rip), %r15      # 0xa9f0
movq %r12, %rdi
leaq 0x1640(%rip), %rsi      # 0x7749
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3280
movl -0x10(%rbx,%r15), %r13d
movq -0xc(%rbx,%r15), %xmm1
movd %r13d, %xmm0
movdqa %xmm1, 0x30(%rsp)
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
pshufd $0xa1, %xmm1, %xmm0     # xmm0 = xmm1[1,0,2,2]
movdqa %xmm0, 0x50(%rsp)
movq %r14, %rdi
movq %r12, %rsi
leaq 0x50(%rsp), %rdx
callq 0x6592
testb %al, %al
je 0x6196
movq %r12, %rdi
leaq 0x15f9(%rip), %rsi      # 0x7750
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3280
movl %r13d, 0x20(%rsp)
movdqa 0x30(%rsp), %xmm0
movd %xmm0, 0x24(%rsp)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
orl $0x1, %eax
movl %eax, 0x28(%rsp)
movl %eax, 0x2c(%rsp)
movq %r14, %rdi
movq %r12, %rsi
leaq 0x20(%rsp), %rdx
callq 0x6592
movq (%rbx,%r15), %rbp
addq $0x18, %rbx
cmpq $0x3f0, %rbx            # imm = 0x3F0
jne 0x60ff
movl $0x1, %r12d
leaq 0x15a0(%rip), %r15      # 0x7758
leaq 0x47(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq %r13, %rdi
movq %r15, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x3280
movl $0x1, 0x10(%rsp)
movl %r12d, 0x14(%rsp)
movq $0x0, 0x18(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x6592
testb %al, %al
je 0x620b
leal 0x1(%r12), %eax
cmpl $0xfe, %r12d
movl %eax, %r12d
jne 0x61c2
cmpq $0x0, 0x8(%r14)
je 0x622a
leaq 0x1547(%rip), %rdi      # 0x7760
callq 0x3260
movq %rax, %r15
jmp 0x622d
xorl %eax, %eax
jmp 0x62fc
xorl %r15d, %r15d
movq (%r14), %rcx
movq 0x78(%rcx), %rax
testq %rax, %rax
je 0x624f
movq 0x80(%rcx), %rdx
leaq 0x1519(%rip), %rdi      # 0x7760
movq %r15, %rsi
callq *%rax
movq %rax, %r15
testq %r15, %r15
je 0x6298
leaq 0x150f(%rip), %rsi      # 0x776a
movq %r15, %rdi
callq 0x3170
testl %eax, %eax
jne 0x6298
movl $0x14, %edi
callq 0x31c0
testq %rax, %rax
je 0x6289
movq 0x14b2(%rip), %xmm0     # 0x7730
movdqu %xmm0, (%rax)
movl $0x0, 0x10(%rax)
movq 0x10(%r14), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x6631
movq 0x4d31(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq 0x20(%rax), %rbx
movq 0x2c8(%rbx), %rdi
testq %rdi, %rdi
je 0x62b9
callq 0x32b0
jmp 0x62bb
xorl %eax, %eax
movq %rax, 0x18(%r14)
movq 0x2c0(%rbx), %rdi
testq %rdi, %rdi
je 0x62d2
callq 0x32b0
jmp 0x62d4
xorl %eax, %eax
movq 0x8(%rsp), %rbx
movq %rax, 0x20(%r14)
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x62eb
callq 0x3050
movq $0x0, 0x8(%r14)
movq 0x10(%r14), %rdi
callq 0x6738
movq %rax, 0x10(%r14)
movq 0x18(%r14), %r14
movl (%rbx), %edi
cmpl $-0x1, %edi
setne %al
testq %r14, %r14
setne %cl
andb %al, %cl
movl $0x1, %ebp
cmpb $0x1, %cl
jne 0x6368
leaq 0x50(%rsp), %rsi
callq 0x32d0
cmpl $-0x1, %eax
je 0x6366
movl $0xf000, %eax           # imm = 0xF000
andl 0x68(%rsp), %eax
cmpl $0x1000, %eax           # imm = 0x1000
je 0x6368
movq %r14, %rdi
callq 0x30f0
movq %rax, %r15
testq %r15, %r15
je 0x6368
movl (%rbx), %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x30e0
addq %rax, %r14
subq %rax, %r15
cmpq $-0x1, %rax
jne 0x6348
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq