// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/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;
#endif

#ifndef SQLITE_OMIT_AUTOINIT
  if( sqlite3_initialize() ) return;
#endif

#if SQLITE_THREADSAFE
  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);
#endif

  sqlite3_mutex_enter(mutex);
  if( N<=0 || pBuf==0 ){
    wsdPrng.isInit = 0;
    sqlite3_mutex_leave(mutex);
    return;
  }

  /* 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;
  }

  assert( N>0 );
  do{
    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];
  }while( --N );
  sqlite3_mutex_leave(mutex);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movl %edi, %ebp
callq 0x21f2bc
testl %eax, %eax
jne 0x221755
testl %ebp, %ebp
setg %al
testq %rbx, %rbx
setne %cl
testb %cl, %al
jne 0x221652
movb $0x0, 0x21c523(%rip)    # 0x43db70
jmp 0x221755
cmpb $0x0, 0x21c517(%rip)    # 0x43db70
je 0x221666
movb 0x21c511(%rip), %al     # 0x43db72
jmp 0x2216fe
andw $0x0, 0x21c503(%rip)    # 0x43db71
xorl %edi, %edi
callq 0x21f275
movl 0x219130(%rip), %r15d   # 0x43a7ac
testl %r15d, %r15d
je 0x221698
movq %rsp, %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x17380
movl %r15d, (%r14)
jmp 0x2216a6
movq %rsp, %rdx
movq %rax, %rdi
movl $0x100, %esi            # imm = 0x100
callq *0x68(%rax)
xorl %eax, %eax
leaq 0x21c4c1(%rip), %rcx    # 0x43db70
cmpq $0x100, %rax            # imm = 0x100
je 0x2216c0
movb %al, 0x3(%rax,%rcx)
incq %rax
jmp 0x2216af
movb 0x21c4ac(%rip), %al     # 0x43db72
xorl %edx, %edx
cmpq $0x100, %rdx            # imm = 0x100
je 0x2216f7
movb 0x3(%rdx,%rcx), %sil
movb (%rsp,%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 0x2216c8
movb $0x1, 0x21c472(%rip)    # 0x43db70
movb 0x21c46d(%rip), %cl     # 0x43db71
movl %ebp, %edx
xorl %esi, %esi
leaq 0x21c461(%rip), %rdi    # 0x43db70
incb %cl
movzbl %cl, %r8d
movb 0x3(%r8,%rdi), %r9b
addb %r9b, %al
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
cmpl %esi, %edx
jne 0x22170f
movb %cl, 0x21c422(%rip)     # 0x43db71
movb %al, 0x21c41d(%rip)     # 0x43db72
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq