// File: /workspace/github_c_makefile_star2_O1/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 *0x8514a(%rip)          # 0x939f8
movq %rax, %r15
testl %r15d, %r15d
js 0xe944
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%r14,%rax)
cmpb $0x2f, (%r14)
je 0xe9f5
leal -0x4(%r12), %eax
cmpl %eax, %r15d
jge 0xe9f5
movl %r15d, %eax
notl %eax
addl %r12d, %eax
movslq %eax, %r12
leaq (%r14,%r12), %r13
incl %r15d
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xa440
movb $0x0, -0x1(%r14,%r12)
decq %r12
movq %r14, %rdi
movq %r12, %rsi
callq *0x84ebc(%rip)          # 0x937d0
movq %rax, %r12
testq %rax, %rax
je 0xe996
movq %r14, %rdi
callq 0xa190
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
leaq (%r14,%rax), %rdi
incq %rdi
movb $0x2f, -0x1(%rdi)
movq %r13, %rsi
movq %r15, %rdx
callq 0xa440
jmp 0xe9f0
callq 0xa0b0
movq %rax, %r15
movl (%rax), %eax
cmpl $0x2, %eax
je 0xe95c
cmpl $0x16, %eax
jne 0xea12
leaq 0x6ea20(%rip), %rdx     # 0x7d383
xorl %r15d, %r15d
movl %r12d, %edi
movq %r14, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xa340
testq %r14, %r14
je 0xe8c7
movq %r14, %rdi
callq 0xa190
movq %rax, %r15
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
jmp 0xe8c7
leaq 0x6e9e9(%rip), %rsi     # 0x7d386
leaq 0x6e7d9(%rip), %rcx     # 0x7d17d
movl $0xe, %edi
movl $0x810e, %edx           # imm = 0x810E
xorl %eax, %eax
callq 0xa4b0
callq 0xa0b0
movl (%rax), %ecx
testq %rbx, %rbx
leaq 0x716cb(%rip), %rax     # 0x80091
cmoveq %rax, %rbx
movq %rax, (%rsp)
leaq 0x6e992(%rip), %rsi     # 0x7d367
leaq 0x6e8b2(%rip), %r8      # 0x7d28e
movl $0xe, %edi
movl $0x810e, %edx           # imm = 0x810E
movq %rbx, %r9
xorl %eax, %eax
callq 0xa4b0
testq %r12, %r12
je 0xea0a
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xe, %r14d
jmp 0xe9f8
leaq 0x6e96d(%rip), %rsi     # 0x7d386
leaq 0x6e75d(%rip), %rcx     # 0x7d17d
movl $0xe, %r14d
movl $0xe, %edi
movl $0x80ee, %edx           # imm = 0x80EE
xorl %eax, %eax
callq 0xa4b0
movl (%r15), %ecx
testq %rbx, %rbx
leaq 0x7164d(%rip), %rax     # 0x80091
cmoveq %rax, %rbx
movq %rax, (%rsp)
leaq 0x6e914(%rip), %rsi     # 0x7d367
leaq 0x6e8cf(%rip), %r8      # 0x7d329
movl $0xe, %edi
movl $0x80ee, %edx           # imm = 0x80EE
movq %rbx, %r9
xorl %eax, %eax
callq 0xa4b0
jmp 0xe9f8