// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3_randomness
SQLITE_API void sqlite3_randomness(int N, void *pBuf){
  unsigned char t;
  unsigned char *zBuf = pBuf;

  /* The "wsdPrng" macro will resolve to the pseudo-random number generator
  ** state vector.  If writable static data is unsupported on the target,
  ** we have to locate the state vector at run-time.  In the more common
  ** case where writable static data is supported, wsdPrng can refer directly
  ** to the "sqlite3Prng" state vector declared above.
  */
#ifdef SQLITE_OMIT_WSD
  struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng);
# define wsdPrng p[0]
#else
# define wsdPrng sqlite3Prng
#endif

#if SQLITE_THREADSAFE
  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);
  sqlite3_mutex_enter(mutex);
#endif

  /* Initialize the state of the random number generator once,
  ** the first time this routine is called.  The seed value does
  ** not need to contain a lot of randomness since we are not
  ** trying to do secure encryption or anything like that...
  **
  ** Nothing in this file or anywhere else in SQLite does any kind of
  ** encryption.  The RC4 algorithm is being used as a PRNG (pseudo-random
  ** number generator) not as an encryption device.
  */
  if( !wsdPrng.isInit ){
    int i;
    char k[256];
    wsdPrng.j = 0;
    wsdPrng.i = 0;
    sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);
    for(i=0; i<256; i++){
      wsdPrng.s[i] = (u8)i;
    }
    for(i=0; i<256; i++){
      wsdPrng.j += wsdPrng.s[i] + k[i];
      t = wsdPrng.s[wsdPrng.j];
      wsdPrng.s[wsdPrng.j] = wsdPrng.s[i];
      wsdPrng.s[i] = t;
    }
    wsdPrng.isInit = 1;
  }

  while( N-- ){
    wsdPrng.i++;
    t = wsdPrng.s[wsdPrng.i];
    wsdPrng.j += t;
    wsdPrng.s[wsdPrng.i] = wsdPrng.s[wsdPrng.j];
    wsdPrng.s[wsdPrng.j] = t;
    t += wsdPrng.s[wsdPrng.i];
    *(zBuf++) = wsdPrng.s[t];
  }
  sqlite3_mutex_leave(mutex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movl %edi, %r14d
cmpb $0x0, 0x8a27f(%rip)     # 0x95d70
je 0xbafe
movb 0x8a279(%rip), %al      # 0x95d72
jmp 0xbb8c
movw $0x0, 0x8a26a(%rip)     # 0x95d71
callq 0x9d86
xorl %r15d, %r15d
movl $0x0, %edi
testl %eax, %eax
jne 0xbb1f
movq 0x8a211(%rip), %rdi     # 0x95d30
leaq -0x120(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq *0x68(%rdi)
leaq 0x8a23b(%rip), %rcx     # 0x95d70
movb %r15b, 0x3(%r15,%rcx)
incq %r15
cmpq $0x100, %r15            # imm = 0x100
jne 0xbb35
movb 0x8a226(%rip), %al      # 0x95d72
xorl %edx, %edx
movb 0x3(%rdx,%rcx), %sil
movb -0x120(%rbp,%rdx), %dil
addb %sil, %dil
addb %dil, %al
movzbl %al, %edi
movb 0x3(%rdi,%rcx), %r8b
movb %sil, 0x3(%rdi,%rcx)
movb %r8b, 0x3(%rdx,%rcx)
incq %rdx
cmpq $0x100, %rdx            # imm = 0x100
jne 0xbb4e
movb %al, 0x8a1ed(%rip)      # 0x95d72
movb $0x1, 0x8a1e4(%rip)     # 0x95d70
testl %r14d, %r14d
je 0xbbf1
movb 0x8a1da(%rip), %cl      # 0x95d71
negl %r14d
movl $0x1, %edx
leaq 0x8a1ca(%rip), %rsi     # 0x95d70
incb %cl
movzbl %cl, %edi
movb 0x3(%rdi,%rsi), %r8b
addb %r8b, %al
movzbl %al, %r9d
movb 0x3(%r9,%rsi), %r10b
movb %r10b, 0x3(%rdi,%rsi)
movb %r8b, 0x3(%r9,%rsi)
addb 0x3(%rdi,%rsi), %r8b
movzbl %r8b, %edi
movb 0x3(%rdi,%rsi), %dil
movb %dil, -0x1(%rbx,%rdx)
incq %rdx
leal (%r14,%rdx), %edi
cmpl $0x1, %edi
jne 0xbba6
movb %cl, 0x8a186(%rip)      # 0x95d71
movb %al, 0x8a181(%rip)      # 0x95d72
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq