// File: /workspace/github_c_makefile_star2_O2/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, 0x7dcb4(%rip)     # 0x88d70
je 0xb0c9
movb 0x7dcae(%rip), %al      # 0x88d72
jmp 0xb14f
andw $0x0, 0x7dca0(%rip)     # 0x88d71
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x96f9
leaq -0x120(%rbp), %rdx
movq %rax, %rdi
movl $0x100, %esi            # imm = 0x100
callq *0x68(%rax)
leaq 0x7dc7c(%rip), %rcx     # 0x88d70
cmpq $0x100, %r15            # imm = 0x100
je 0xb107
movb %r15b, 0x3(%r15,%rcx)
incq %r15
jmp 0xb0f4
movb 0x7dc65(%rip), %al      # 0x88d72
xorl %edx, %edx
cmpq $0x100, %rdx            # imm = 0x100
je 0xb142
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
jmp 0xb10f
movb %al, 0x7dc2a(%rip)      # 0x88d72
movb $0x1, 0x7dc21(%rip)     # 0x88d70
movb 0x7dc1c(%rip), %cl      # 0x88d71
incb %cl
movzbl %cl, %ecx
movl %r14d, %edx
xorl %esi, %esi
leaq 0x7dc0a(%rip), %rdi     # 0x88d70
cmpl %esi, %edx
je 0xb1b1
leal (%rcx,%rsi), %r8d
movb %r8b, 0x7dbfc(%rip)     # 0x88d71
movzbl %r8b, %r8d
movb 0x3(%r8,%rdi), %r9b
addb %r9b, %al
movb %al, 0x7dbeb(%rip)      # 0x88d72
movzbl %al, %r10d
movb 0x3(%r10,%rdi), %r11b
movb %r11b, 0x3(%r8,%rdi)
movb %r9b, 0x3(%r10,%rdi)
addb 0x3(%r8,%rdi), %r9b
movzbl %r9b, %r8d
movb 0x3(%r8,%rdi), %r8b
movb %r8b, (%rbx,%rsi)
incq %rsi
jmp 0xb166
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq