// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/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 */
){
  int nByte;

  /* 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 );

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

  /* Attempt to resolve the path as if it were a symbolic link. If it is
  ** a symbolic link, the resolved path is stored in buffer zOut[]. Or, if
  ** the identified file is not a symbolic link or does not exist, then
  ** zPath is copied directly into zOut. Either way, nByte is left set to
  ** the size of the string copied into zOut[] in bytes.  */
  nByte = osReadlink(zPath, zOut, nOut-1);
  if( nByte<0 ){
    if( errno!=EINVAL && errno!=ENOENT ){
      return unixLogError(SQLITE_CANTOPEN_BKPT, "readlink", zPath);
    }
    sqlite3_snprintf(nOut, zOut, "%s", zPath);
    nByte = sqlite3Strlen30(zOut);
  }else{
    zOut[nByte] = '\0';
  }

  /* If buffer zOut[] now contains an absolute path there is nothing more
  ** to do. If it contains a relative path, do the following:
  **
  **   * move the relative path string so that it is at the end of th
  **     zOut[] buffer.
  **   * Call getcwd() to read the path of the current working directory 
  **     into the start of the zOut[] buffer.
  **   * Append a '/' character to the cwd string and move the 
  **     relative path back within the buffer so that it immediately 
  **     follows the '/'.
  **
  ** This code is written so that if the combination of the CWD and relative
  ** path are larger than the allocated size of zOut[] the CWD is silently
  ** truncated to make it fit. This is Ok, as SQLite refuses to open any
  ** file for which this function returns a full path larger than (nOut-8)
  ** bytes in size.  */
  testcase( nByte==nOut-5 );
  testcase( nByte==nOut-4 );
  if( zOut[0]!='/' && nByte<nOut-4 ){
    int nCwd;
    int nRem = nOut-nByte-1;
    memmove(&zOut[nRem], zOut, nByte+1);
    zOut[nRem-1] = '\0';
    if( osGetcwd(zOut, nRem-1)==0 ){
      return unixLogError(SQLITE_CANTOPEN_BKPT, "getcwd", zPath);
    }
    nCwd = sqlite3Strlen30(zOut);
    assert( nCwd<=nRem-1 );
    zOut[nCwd] = '/';
    memmove(&zOut[nCwd+1], &zOut[nRem], nByte+1);
  }

  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movl %edx, %r12d
movq %rsi, %rbx
leal -0x1(%r12), %eax
movslq %eax, %rdx
movq %rsi, %rdi
movq %rcx, %rsi
callq *0x757c2(%rip)          # 0x83af8
movq %rax, %r13
testl %r13d, %r13d
js 0xe34d
movl %r13d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%r14,%rax)
jmp 0xe384
callq 0xa0b0
movl (%rax), %eax
cmpl $0x2, %eax
je 0xe362
cmpl $0x16, %eax
jne 0xe422
leaq 0x5e01a(%rip), %rdx     # 0x6c383
movl %r12d, %edi
movq %r14, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xa400
movq %r14, %rdi
callq 0xb080
movl %eax, %r13d
xorl %r15d, %r15d
cmpb $0x2f, (%r14)
je 0xe447
leal -0x4(%r12), %eax
cmpl %eax, %r13d
jge 0xe447
movq %rbx, -0x30(%rbp)
movl %r13d, %eax
notl %eax
addl %r12d, %eax
movslq %eax, %rbx
leaq (%r14,%rbx), %r12
incl %r13d
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xa560
movb $0x0, -0x1(%r14,%rbx)
decq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x754f8(%rip)          # 0x838d0
testq %rax, %rax
je 0xe3ff
movq %r14, %rdi
callq 0xb080
movl %eax, %eax
leaq (%r14,%rax), %rdi
incq %rdi
movb $0x2f, -0x1(%rdi)
movq %r12, %rsi
movq %r13, %rdx
callq 0xa560
jmp 0xe447
movl $0x810e, %edi           # imm = 0x810E
callq 0x1b492
leaq 0x5de7e(%rip), %rsi     # 0x6c28e
pushq $0xe
popq %r15
movl %r15d, %edi
movq -0x30(%rbp), %rdx
movl $0x810e, %ecx           # imm = 0x810E
jmp 0xe442
movl $0x80ee, %edi           # imm = 0x80EE
callq 0x1b492
leaq 0x5def6(%rip), %rsi     # 0x6c329
pushq $0xe
popq %r15
movl %r15d, %edi
movq %rbx, %rdx
movl $0x80ee, %ecx           # imm = 0x80EE
callq 0x1b436
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq