// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movq 0x27b87a(%rip), %rax    # 0x63ff50
movq -0x38(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
je 0x3c4718
callq 0x19060
cmpl $0x2, (%rax)
je 0x3c4716
movl $0x9bef, %edi           # imm = 0x9BEF
callq 0x3d80e0
movl %eax, %edi
movq -0x38(%rbp), %rdx
leaq 0x1e68da(%rip), %rsi    # 0x5aafe3
movl $0x9bef, %ecx           # imm = 0x9BEF
callq 0x3d8070
movl %eax, -0x24(%rbp)
jmp 0x3c4733
movl -0xc0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xa000, %eax           # imm = 0xA000
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x3c48bb
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x3c4769
movl -0x14(%rbp), %edi
callq 0x3c0710
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x3c4767
movl $0x7, -0x24(%rbp)
jmp 0x3c477e
cmpl $0x64, -0x2c(%rbp)
jl 0x3c477c
movl $0x9bfb, %edi           # imm = 0x9BFB
callq 0x3d80e0
movl %eax, -0x24(%rbp)
jmp 0x3c477e
cmpl $0x0, -0x24(%rbp)
jne 0x3c48b3
movq 0x27b7a9(%rip), %rax    # 0x63ff38
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rdx
callq *%rax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jge 0x3c47d4
movl $0x9c01, %edi           # imm = 0x9C01
callq 0x3d80e0
movl %eax, %edi
movq -0x38(%rbp), %rdx
leaq 0x1e6818(%rip), %rsi    # 0x5aafda
movl $0x9c01, %ecx           # imm = 0x9C01
callq 0x3d8070
movl %eax, -0x24(%rbp)
jmp 0x3c48b1
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x3c48a5
movq -0x38(%rbp), %rdi
callq 0x3c3400
movl %eax, -0xdc(%rbp)
xorl %eax, %eax
cmpl $0x0, -0xdc(%rbp)
movb %al, -0xdd(%rbp)
jle 0x3c4824
movq -0x38(%rbp), %rax
movl -0xdc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
setne %al
movb %al, -0xdd(%rbp)
movb -0xdd(%rbp), %al
testb $0x1, %al
jne 0x3c4830
jmp 0x3c4843
jmp 0x3c4832
movl -0xdc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0x3c47f3
movl -0x28(%rbp), %eax
addl -0xdc(%rbp), %eax
addl $0x1, %eax
cmpl -0x14(%rbp), %eax
jle 0x3c4863
movl $0x9c07, %edi           # imm = 0x9C07
callq 0x3d80e0
movl %eax, -0x24(%rbp)
jmp 0x3c48a3
movq -0x40(%rbp), %rdi
movslq -0xdc(%rbp), %rax
addq %rax, %rdi
movq -0x40(%rbp), %rsi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
callq 0x19bf0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movslq -0xdc(%rbp), %rdx
callq 0x19610
movl -0xdc(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x3c48a5
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x3c48b3
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x3c48de
movq -0x38(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x3c48de
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x3da010
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x3c48e6
jmp 0x3c48f8
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x3c46c8
movq -0x40(%rbp), %rdi
callq 0x3c0800
cmpl $0x0, -0x24(%rbp)
jne 0x3c4914
cmpl $0x0, -0x2c(%rbp)
je 0x3c4914
movl $0x200, -0x24(%rbp)     # imm = 0x200
movl -0x24(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq