// File: /workspace/github_c_makefile_star2_O3/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 $0xb8, %rsp
movq %rcx, %r15
movl %edx, %r12d
movq %rsi, %r14
leal -0x1(%r12), %eax
cltq
movq %rax, 0x18(%rsp)
leal -0x2(%r12), %eax
cltq
movq %rax, 0x20(%rsp)
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq *0x2462af(%rip)         # 0x4bbd60
testl %eax, %eax
je 0x275aca
callq 0x17060
movb $0x1, %bl
cmpl $0x2, (%rax)
je 0x275bc2
jmp 0x275c6b
movl 0x40(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
movb $0x1, %bl
cmpl $0xa000, %eax           # imm = 0xA000
jne 0x275bc2
movq (%rsp), %rax
leal 0x1(%rax), %r13d
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x275afe
cmpl $0x63, %eax
jl 0x275b12
jmp 0x275d78
movl %r12d, %edi
callq 0x272ac7
movq %rax, %rbx
testq %rax, %rax
je 0x275de3
movq %r14, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
callq *0x246225(%rip)         # 0x4bbd48
movq %rax, %rbp
testl %ebp, %ebp
movq %rbx, 0x8(%rsp)
js 0x275d31
cmpb $0x2f, (%rbx)
jne 0x275b3f
movq %rbx, %r12
movl %ebp, %ebx
jmp 0x275baa
testq %r14, %r14
je 0x275b53
movq %r14, %rdi
callq 0x172f0
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x275b55
xorl %eax, %eax
movq %rax, %rcx
subq $0x1, %rcx
jb 0x275b6d
cmpb $0x2f, -0x1(%r14,%rax)
movq %rcx, %rax
jne 0x275b58
incl %ecx
jmp 0x275b6f
xorl %ecx, %ecx
leal (%rcx,%rbp), %ebx
cmpl %r12d, %ebx
jge 0x275da6
movl %r13d, (%rsp)
movl %ecx, %r13d
movq 0x8(%rsp), %r12
leaq (%r12,%r13), %rdi
incl %ebp
movq %r12, %rsi
movq %rbp, %rdx
callq 0x17cd0
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl (%rsp), %r13d
callq 0x17660
movl %ebx, %eax
movb $0x0, (%r12,%rax)
xorl %ebx, %ebx
movq %r12, %r14
movl %r13d, %eax
movq %rax, (%rsp)
movq 0x10(%rsp), %r12
cmpq %r15, %r14
je 0x275c52
xorl %r13d, %r13d
movl $0x0, %ebp
testq %r14, %r14
je 0x275be9
movq %r14, %rdi
callq 0x172f0
movq %rax, %rbp
andl $0x3fffffff, %ebp       # imm = 0x3FFFFFFF
cmpb $0x2f, (%r14)
je 0x275c2d
movq %r15, %rdi
movq 0x20(%rsp), %rsi
callq *0x245f23(%rip)         # 0x4bbb20
testq %rax, %rax
je 0x275ce3
testq %r15, %r15
je 0x275c1f
movq %r15, %rdi
callq 0x172f0
movq %rax, %r13
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
jmp 0x275c22
xorl %r13d, %r13d
movl %r13d, %eax
incl %r13d
movb $0x2f, (%r15,%rax)
addl %r13d, %ebp
cmpl %r12d, %ebp
jge 0x275cad
movl %r12d, %edi
subl %r13d, %edi
movl %r13d, %esi
addq %r15, %rsi
leaq 0x152e61(%rip), %rdx    # 0x3c8aa9
movq %r14, %rcx
xorl %eax, %eax
callq 0x274c41
movq %r15, %r14
testb %bl, %bl
je 0x275aa3
xorl %r15d, %r15d
movb $0x1, %bl
movq (%rsp), %r14
jmp 0x275df7
leaq 0x15ff59(%rip), %rsi    # 0x3d5bcb
leaq 0x15ff41(%rip), %rdx    # 0x3d5bba
leaq 0x15fdb1(%rip), %r8     # 0x3d5a31
movl $0xe, %r15d
movl $0xe, %edi
movl $0x9bef, %ecx           # imm = 0x9BEF
xorl %eax, %eax
callq 0x274d08
leaq 0x15fec6(%rip), %rsi    # 0x3d5b64
movl $0xe, %edi
movq %r14, %rdx
movl $0x9bef, %ecx           # imm = 0x9BEF
jmp 0x275d23
movl %r13d, %eax
movb $0x0, (%r15,%rax)
leaq 0x15ff0f(%rip), %rsi    # 0x3d5bcb
leaq 0x15fef7(%rip), %rdx    # 0x3d5bba
leaq 0x15fd67(%rip), %r8     # 0x3d5a31
movl $0xe, %r15d
movl $0xe, %edi
movl $0x9bbf, %ecx           # imm = 0x9BBF
xorl %eax, %eax
callq 0x274d08
jmp 0x275d28
leaq 0x15fee1(%rip), %rsi    # 0x3d5bcb
leaq 0x15fec9(%rip), %rdx    # 0x3d5bba
leaq 0x15fd39(%rip), %r8     # 0x3d5a31
movl $0xe, %r15d
movl $0xe, %edi
movl $0x9bb6, %ecx           # imm = 0x9BB6
xorl %eax, %eax
callq 0x274d08
leaq 0x15fdc8(%rip), %rsi    # 0x3d5ade
movl $0xe, %edi
movq %r14, %rdx
movl $0x9bb6, %ecx           # imm = 0x9BB6
callq 0x2842dc
movq (%rsp), %r14
jmp 0x275df5
leaq 0x15fe93(%rip), %rsi    # 0x3d5bcb
leaq 0x15fe7b(%rip), %rdx    # 0x3d5bba
leaq 0x15fceb(%rip), %r8     # 0x3d5a31
movl $0xe, %r15d
movl $0xe, %edi
movl $0x9c01, %ecx           # imm = 0x9C01
xorl %eax, %eax
callq 0x274d08
leaq 0x15fdf7(%rip), %rsi    # 0x3d5b5b
movl $0xe, %edi
movq %r14, %rdx
movl $0x9c01, %ecx           # imm = 0x9C01
callq 0x2842dc
jmp 0x275df2
leaq 0x15fe4c(%rip), %rsi    # 0x3d5bcb
leaq 0x15fe34(%rip), %rdx    # 0x3d5bba
leaq 0x15fca4(%rip), %r8     # 0x3d5a31
movl $0xe, %r15d
movl $0xe, %edi
movl $0x9bfb, %ecx           # imm = 0x9BFB
xorl %eax, %eax
callq 0x274d08
jmp 0x275df2
leaq 0x15fe1e(%rip), %rsi    # 0x3d5bcb
leaq 0x15fe06(%rip), %rdx    # 0x3d5bba
leaq 0x15fc76(%rip), %r8     # 0x3d5a31
movl $0xe, %r15d
movl $0xe, %edi
movl $0x9c07, %ecx           # imm = 0x9C07
xorl %eax, %eax
callq 0x274d08
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x8(%rsp), %rax
movb $0x0, (%rax,%rbp)
jmp 0x275df2
movl $0x7, %r15d
movq $0x0, 0x8(%rsp)
movl %r13d, %r14d
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
callq 0x272c00
testl %r14d, %r14d
movl $0x200, %eax            # imm = 0x200
cmovel %r15d, %eax
testb %bl, %bl
cmovel %r15d, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq