// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/util.c
// Function: getRandomHexChars
void getRandomHexChars(char *p, unsigned int len) {
    FILE *fp = fopen("/dev/urandom","r");
    char *charset = "0123456789abcdef";
    unsigned int j;

    if (fp == NULL || fread(p,len,1,fp) == 0) {
        /* If we can't read from /dev/urandom, do some reasonable effort
         * in order to create some entropy, since this function is used to
         * generate run_id and cluster instance IDs */
        char *x = p;
        unsigned int l = len;
        struct timeval tv;
        pid_t pid = getpid();

        /* Use time and PID to fill the initial array. */
        gettimeofday(&tv,NULL);
        if (l >= sizeof(tv.tv_usec)) {
            memcpy(x,&tv.tv_usec,sizeof(tv.tv_usec));
            l -= sizeof(tv.tv_usec);
            x += sizeof(tv.tv_usec);
        }
        if (l >= sizeof(tv.tv_sec)) {
            memcpy(x,&tv.tv_sec,sizeof(tv.tv_sec));
            l -= sizeof(tv.tv_sec);
            x += sizeof(tv.tv_sec);
        }
        if (l >= sizeof(pid)) {
            memcpy(x,&pid,sizeof(pid));
            l -= sizeof(pid);
            x += sizeof(pid);
        }
        /* Finally xor it with rand() output, that was already seeded with
         * time() at startup. */
        for (j = 0; j < len; j++)
            p[j] ^= rand();
    }
    /* Turn it into hex digits taking just 4 bits out of 8 for every byte. */
    for (j = 0; j < len; j++)
        p[j] = charset[p[j] & 0x0F];
    if (fp) fclose(fp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq 0xa7771(%rip), %rdi     # 0xe13d7
leaq 0xa7066(%rip), %rsi     # 0xe0cd3
callq 0x1fa70
movq %rax, -0x18(%rbp)
leaq 0xa7767(%rip), %rax     # 0xe13e4
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x39ca9
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, %esi
movq -0x18(%rbp), %rcx
movl $0x1, %edx
callq 0x1f7d0
cmpq $0x0, %rax
jne 0x39d7b
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x34(%rbp)
callq 0x1f410
movl %eax, -0x4c(%rbp)
leaq -0x48(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f300
movl -0x34(%rbp), %eax
cmpq $0x8, %rax
jb 0x39cf6
movq -0x30(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movl -0x34(%rbp), %eax
subq $0x8, %rax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movl -0x34(%rbp), %eax
cmpq $0x8, %rax
jb 0x39d20
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, (%rax)
movl -0x34(%rbp), %eax
subq $0x8, %rax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movl -0x34(%rbp), %eax
cmpq $0x4, %rax
jb 0x39d48
movq -0x30(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
subq $0x4, %rax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x39d79
callq 0x1fb10
movl %eax, %esi
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x39d4f
jmp 0x39d7b
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x39db7
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movl -0x24(%rbp), %edx
movsbl (%rcx,%rdx), %ecx
andl $0xf, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x39d82
cmpq $0x0, -0x18(%rbp)
je 0x39dc7
movq -0x18(%rbp), %rdi
callq 0x1f9b0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)