// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: findCreateFileMode
static int findCreateFileMode(
  const char *zPath,              /* Path of file (possibly) being created */
  int flags,                      /* Flags passed as 4th argument to xOpen() */
  mode_t *pMode,                  /* OUT: Permissions to open file with */
  uid_t *pUid,                    /* OUT: uid to set on the file */
  gid_t *pGid                     /* OUT: gid to set on the file */
){
  int rc = SQLITE_OK;             /* Return Code */
  *pMode = 0;
  *pUid = 0;
  *pGid = 0;
  if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
    char zDb[MAX_PATHNAME+1];     /* Database file path */
    int nDb;                      /* Number of valid bytes in zDb */
    struct stat sStat;            /* Output of stat() on database file */

    /* zPath is a path to a WAL or journal file. The following block derives
    ** the path to the associated database file from zPath. This block handles
    ** the following naming conventions:
    **
    **   "<path to db>-journal"
    **   "<path to db>-wal"
    **   "<path to db>-journalNN"
    **   "<path to db>-walNN"
    **
    ** where NN is a decimal number. The NN naming schemes are 
    ** used by the test_multiplex.c module.
    */
    nDb = sqlite3Strlen30(zPath) - 1; 
#ifdef SQLITE_ENABLE_8_3_NAMES
    while( nDb>0 && sqlite3Isalnum(zPath[nDb]) ) nDb--;
    if( nDb==0 || zPath[nDb]!='-' ) return SQLITE_OK;
#else
    while( zPath[nDb]!='-' ){
      assert( nDb>0 );
      assert( zPath[nDb]!='\n' );
      nDb--;
    }
#endif
    memcpy(zDb, zPath, nDb);
    zDb[nDb] = '\0';

    if( 0==osStat(zDb, &sStat) ){
      *pMode = sStat.st_mode & 0777;
      *pUid = sStat.st_uid;
      *pGid = sStat.st_gid;
    }else{
      rc = SQLITE_IOERR_FSTAT;
    }
  }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
    *pMode = 0600;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl -0xc(%rbp), %eax
andl $0x80800, %eax          # imm = 0x80800
cmpl $0x0, %eax
je 0x1ef85
movq -0x8(%rbp), %rdi
callq 0x92f0
subl $0x1, %eax
movl %eax, -0x234(%rbp)
movq -0x8(%rbp), %rax
movslq -0x234(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
je 0x1ef0b
movl -0x234(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x1eee6
leaq -0x230(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0x234(%rbp), %rdx
callq 0x82f0
movslq -0x234(%rbp), %rax
movb $0x0, -0x230(%rbp,%rax)
movq 0xb1a10(%rip), %rax     # 0xd0948
leaq -0x230(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq *%rax
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1ef7c
movl -0x2b0(%rbp), %ecx
andl $0x1ff, %ecx            # imm = 0x1FF
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x2ac(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x2a8(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1ef83
movl $0x70a, -0x2c(%rbp)     # imm = 0x70A
jmp 0x1ef9c
movl -0xc(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1ef9a
movq -0x18(%rbp), %rax
movl $0x180, (%rax)          # imm = 0x180
jmp 0x1ef9c
movl -0x2c(%rbp), %eax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
nopl (%rax,%rax)