// File: /workspace/github_c_makefile_star2_O0/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
subq $0x130, %rsp            # imm = 0x130
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpb $0x0, 0xc572f(%rip)     # 0xd1e90
jne 0xc863
movb $0x0, 0xc5724(%rip)     # 0xd1e92
movb $0x0, 0xc571c(%rip)     # 0xd1e91
xorl %eax, %eax
movl %eax, %edi
callq 0x9dd0
movq %rax, %rdi
leaq -0x130(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0xc940
movl $0x0, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jge 0xc7c1
movl -0x24(%rbp), %eax
movb %al, %dl
movslq -0x24(%rbp), %rcx
leaq 0xc56de(%rip), %rax     # 0xd1e90
movb %dl, 0x3(%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc799
movl $0x0, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jge 0xc85c
movslq -0x24(%rbp), %rcx
leaq 0xc56b0(%rip), %rax     # 0xd1e90
movzbl 0x3(%rax,%rcx), %ecx
movslq -0x24(%rbp), %rax
movsbl -0x130(%rbp,%rax), %eax
addl %eax, %ecx
movzbl 0xc5698(%rip), %eax     # 0xd1e92
addl %ecx, %eax
movb %al, 0xc5690(%rip)      # 0xd1e92
movzbl 0xc5689(%rip), %eax     # 0xd1e92
movl %eax, %ecx
leaq 0xc567e(%rip), %rax     # 0xd1e90
movb 0x3(%rax,%rcx), %al
movb %al, -0x11(%rbp)
movslq -0x24(%rbp), %rcx
leaq 0xc566c(%rip), %rax     # 0xd1e90
movb 0x3(%rax,%rcx), %dl
movzbl 0xc5663(%rip), %eax     # 0xd1e92
movl %eax, %ecx
leaq 0xc5658(%rip), %rax     # 0xd1e90
movb %dl, 0x3(%rax,%rcx)
movb -0x11(%rbp), %dl
movslq -0x24(%rbp), %rcx
leaq 0xc5646(%rip), %rax     # 0xd1e90
movb %dl, 0x3(%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc7c8
movb $0x1, 0xc562d(%rip)     # 0xd1e90
jmp 0xc865
movl -0x4(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x4(%rbp)
cmpl $0x0, %eax
je 0xc935
movb 0xc5612(%rip), %al      # 0xd1e91
addb $0x1, %al
movb %al, 0xc560a(%rip)      # 0xd1e91
movzbl 0xc5603(%rip), %eax     # 0xd1e91
movl %eax, %ecx
leaq 0xc55f9(%rip), %rax     # 0xd1e90
movb 0x3(%rax,%rcx), %al
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %ecx
movzbl 0xc55e9(%rip), %eax     # 0xd1e92
addl %ecx, %eax
movb %al, 0xc55e1(%rip)      # 0xd1e92
movzbl 0xc55da(%rip), %eax     # 0xd1e92
movl %eax, %ecx
leaq 0xc55cf(%rip), %rax     # 0xd1e90
movb 0x3(%rax,%rcx), %dl
movzbl 0xc55c5(%rip), %eax     # 0xd1e91
movl %eax, %ecx
leaq 0xc55bb(%rip), %rax     # 0xd1e90
movb %dl, 0x3(%rax,%rcx)
movb -0x11(%rbp), %dl
movzbl 0xc55af(%rip), %eax     # 0xd1e92
movl %eax, %ecx
leaq 0xc55a4(%rip), %rax     # 0xd1e90
movb %dl, 0x3(%rax,%rcx)
movzbl 0xc559a(%rip), %eax     # 0xd1e91
movl %eax, %ecx
leaq 0xc5590(%rip), %rax     # 0xd1e90
movzbl 0x3(%rax,%rcx), %ecx
movzbl -0x11(%rbp), %eax
addl %ecx, %eax
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
movl %eax, %ecx
leaq 0xc5575(%rip), %rax     # 0xd1e90
movb 0x3(%rax,%rcx), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
jmp 0xc865
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nop