// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: unixFullPathname
static int unixFullPathname(
  sqlite3_vfs *pVfs,            /* Pointer to vfs object */
  const char *zPath,            /* Possibly relative input path */
  int nOut,                     /* Size of output buffer in bytes */
  char *zOut                    /* Output buffer */
){
#if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT)
  return mkFullPathname(zPath, zOut, nOut);
#else
  int rc = SQLITE_OK;
  int nByte;
  int nLink = 0;                /* Number of symbolic links followed so far */
  const char *zIn = zPath;      /* Input path for each iteration of loop */
  char *zDel = 0;

  assert( pVfs->mxPathname==MAX_PATHNAME );
  UNUSED_PARAMETER(pVfs);

  /* It's odd to simulate an io-error here, but really this is just
  ** using the io-error infrastructure to test that SQLite handles this
  ** function failing. This function could fail if, for example, the
  ** current working directory has been unlinked.
  */
  SimulateIOError( return SQLITE_ERROR );

  do {

    /* Call stat() on path zIn. Set bLink to true if the path is a symbolic
    ** link, or false otherwise.  */
    int bLink = 0;
    struct stat buf;
    if( osLstat(zIn, &buf)!=0 ){
      if( errno!=ENOENT ){
        rc = unixLogError(SQLITE_CANTOPEN_BKPT, "lstat", zIn);
      }
    }else{
      bLink = S_ISLNK(buf.st_mode);
    }

    if( bLink ){
      nLink++;
      if( zDel==0 ){
        zDel = sqlite3_malloc(nOut);
        if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;
      }else if( nLink>=SQLITE_MAX_SYMLINKS ){
        rc = SQLITE_CANTOPEN_BKPT;
      }

      if( rc==SQLITE_OK ){
        nByte = osReadlink(zIn, zDel, nOut-1);
        if( nByte<0 ){
          rc = unixLogError(SQLITE_CANTOPEN_BKPT, "readlink", zIn);
        }else{
          if( zDel[0]!='/' ){
            int n;
            for(n = sqlite3Strlen30(zIn); n>0 && zIn[n-1]!='/'; n--);
            if( nByte+n+1>nOut ){
              rc = SQLITE_CANTOPEN_BKPT;
            }else{
              memmove(&zDel[n], zDel, nByte+1);
              memcpy(zDel, zIn, n);
              nByte += n;
            }
          }
          zDel[nByte] = '\0';
        }
      }

      zIn = zDel;
    }

    assert( rc!=SQLITE_OK || zIn!=zOut || zIn[0]=='/' );
    if( rc==SQLITE_OK && zIn!=zOut ){
      rc = mkFullPathname(zIn, zOut, nOut);
    }
    if( bLink==0 ) break;
    zIn = zOut;
  }while( rc==SQLITE_OK );

  sqlite3_free(zDel);
  if( rc==SQLITE_OK && nLink ) rc = SQLITE_OK_SYMLINK;
  return rc;
#endif   /* HAVE_READLINK && HAVE_LSTAT */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, %r13
movl %edx, %r15d
movq %rsi, %rbp
leal -0x1(%r15), %eax
cltq
movq %rax, 0x30(%rsp)
leal -0x2(%r15), %eax
cltq
movq %rax, 0x28(%rsp)
movl $0x0, 0x14(%rsp)
movq $0x0, 0x8(%rsp)
movq %rcx, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
callq *0x247965(%rip)         # 0x4c6d60
testl %eax, %eax
je 0x27f456
callq 0x17060
movb $0x1, %r12b
xorl %r14d, %r14d
cmpl $0x2, (%rax)
je 0x27f46d
movl $0xe, %r14d
movl $0xe, %edi
leaq 0x15fefe(%rip), %rsi    # 0x3df31f
leaq 0x15fee6(%rip), %rdx    # 0x3df30e
movl $0x9bef, %ecx           # imm = 0x9BEF
leaq 0x15fd51(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movl $0xe, %edi
leaq 0x15fe71(%rip), %rsi    # 0x3df2b8
movq %rbp, %rdx
movl $0x9bef, %ecx           # imm = 0x9BEF
callq 0x28de48
jmp 0x27f46d
movl 0x50(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0xa000, %eax           # imm = 0xA000
setne %r12b
xorl %r14d, %r14d
testb %r12b, %r12b
je 0x27f47a
movq %rbp, %rbx
jmp 0x27f602
cmpq $0x0, 0x8(%rsp)
je 0x27f4bc
cmpl $0x63, 0x14(%rsp)
jl 0x27f4b5
movl $0xe, %r14d
movl $0xe, %edi
leaq 0x15fe84(%rip), %rsi    # 0x3df31f
leaq 0x15fe6c(%rip), %rdx    # 0x3df30e
movl $0x9bfb, %ecx           # imm = 0x9BFB
leaq 0x15fcd7(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movq 0x8(%rsp), %rbx
jmp 0x27f4d3
movl %r15d, %edi
callq 0x27c362
movq %rax, %rbx
testq %rax, %rax
movl $0x7, %eax
cmovel %eax, %r14d
incl 0x14(%rsp)
testl %r14d, %r14d
je 0x27f4e9
movq %r13, %rbp
movq %rbx, 0x8(%rsp)
jmp 0x27f602
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x30(%rsp), %rdx
callq *0x24784e(%rip)         # 0x4c6d48
movq %rax, %r15
testl %r15d, %r15d
js 0x27f522
xorl %r14d, %r14d
cmpb $0x2f, (%rbx)
je 0x27f5ee
testq %rbp, %rbp
je 0x27f56c
movq %rbp, %rdi
callq 0x172f0
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x27f56e
movl $0xe, %r14d
movl $0xe, %edi
leaq 0x15fdeb(%rip), %rsi    # 0x3df31f
leaq 0x15fdd3(%rip), %rdx    # 0x3df30e
movl $0x9c01, %ecx           # imm = 0x9C01
leaq 0x15fc3e(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movl $0xe, %edi
leaq 0x15fd55(%rip), %rsi    # 0x3df2af
movq %rbp, %rdx
movl $0x9c01, %ecx           # imm = 0x9C01
callq 0x28de48
jmp 0x27f5f5
xorl %eax, %eax
testq %rax, %rax
jle 0x27f585
leaq -0x1(%rax), %rcx
cmpb $0x2f, -0x1(%rbp,%rax)
movq %rcx, %rax
jne 0x27f56e
incl %ecx
jmp 0x27f587
xorl %ecx, %ecx
leal (%rcx,%r15), %r13d
cmpl 0x18(%rsp), %r13d
jge 0x27f5bd
movl %ecx, %r14d
leaq (%rbx,%r14), %rdi
incl %r15d
movq %rbx, %rsi
movq %r15, %rdx
callq 0x17cd0
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x17660
xorl %r14d, %r14d
movl %r13d, %r15d
jmp 0x27f5e9
movl $0xe, %r14d
movl $0xe, %edi
leaq 0x15fd50(%rip), %rsi    # 0x3df31f
leaq 0x15fd38(%rip), %rdx    # 0x3df30e
movl $0x9c07, %ecx           # imm = 0x9C07
leaq 0x15fba3(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movq 0x20(%rsp), %r13
movl %r15d, %eax
movb $0x0, (%rbx,%rax)
movq %r13, %rbp
movq %rbx, 0x8(%rsp)
movq 0x18(%rsp), %r15
testl %r14d, %r14d
je 0x27f61f
testl %r14d, %r14d
jne 0x27f756
xorb $0x1, %r12b
jne 0x27f3ed
jmp 0x27f756
cmpq %r13, %rbx
je 0x27f67e
xorl %r14d, %r14d
movl $0x0, %r13d
testq %rbx, %rbx
je 0x27f644
movq %rbx, %rdi
callq 0x172f0
movq %rax, %r13
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
cmpb $0x2f, (%rbx)
je 0x27f6e8
movq 0x20(%rsp), %r15
movq %r15, %rdi
movq 0x28(%rsp), %rsi
callq *0x2474c0(%rip)         # 0x4c6b20
testq %rax, %rax
je 0x27f683
testq %r15, %r15
je 0x27f6d5
movq %r15, %rdi
callq 0x172f0
movq %rax, %r14
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
jmp 0x27f6d8
xorl %r14d, %r14d
jmp 0x27f607
movl $0xe, %r14d
movl $0xe, %edi
leaq 0x15fc8a(%rip), %rsi    # 0x3df31f
leaq 0x15fc72(%rip), %rdx    # 0x3df30e
movl $0x9bb6, %ecx           # imm = 0x9BB6
leaq 0x15fadd(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movl $0xe, %edi
leaq 0x15fb77(%rip), %rsi    # 0x3df232
movq %rbx, %rdx
movl $0x9bb6, %ecx           # imm = 0x9BB6
callq 0x28de48
movq %r15, %r13
movq 0x18(%rsp), %r15
jmp 0x27f607
xorl %r14d, %r14d
movl %r14d, %eax
incl %r14d
movb $0x2f, (%r15,%rax)
movq 0x18(%rsp), %r15
addl %r14d, %r13d
movl %r14d, %esi
cmpl %r15d, %r13d
jge 0x27f71a
movl %r15d, %edi
subl %r14d, %edi
movq 0x20(%rsp), %r13
addq %r13, %rsi
xorl %r14d, %r14d
leaq 0x152ac6(%rip), %rdx    # 0x3d21d1
movq %rbx, %rcx
xorl %eax, %eax
callq 0x27e570
jmp 0x27f607
movq 0x20(%rsp), %r13
movb $0x0, (%r13,%rsi)
movl $0xe, %r14d
movl $0xe, %edi
leaq 0x15fbe8(%rip), %rsi    # 0x3df31f
leaq 0x15fbd0(%rip), %rdx    # 0x3df30e
movl $0x9bbf, %ecx           # imm = 0x9BBF
leaq 0x15fa3b(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
jmp 0x27f607
movq 0x8(%rsp), %rdi
callq 0x27c490
cmpl $0x0, 0x14(%rsp)
movl $0x200, %eax            # imm = 0x200
cmovel %r14d, %eax
testl %r14d, %r14d
cmovnel %r14d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq