// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/redis-cli.c
// Function: LRUTestMode
static void LRUTestMode(void) {
    redisReply *reply;
    char key[128];
    long long start_cycle;
    int j;

    srand(time(NULL)^getpid());
    while(1) {
        /* Perform cycles of 1 second with 50% writes and 50% reads.
         * We use pipelining batching writes / reads N times per cycle in order
         * to fill the target instance easily. */
        start_cycle = mstime();
        long long hits = 0, misses = 0;
        while(mstime() - start_cycle < 1000) {
            /* Write cycle. */
            for (j = 0; j < LRU_CYCLE_PIPELINE_SIZE; j++) {
                LRUTestGenKey(key,sizeof(key));
                redisAppendCommand(context, "SET %s val",key);
            }
            for (j = 0; j < LRU_CYCLE_PIPELINE_SIZE; j++)
                redisGetReply(context, (void**)&reply);

            /* Read cycle. */
            for (j = 0; j < LRU_CYCLE_PIPELINE_SIZE; j++) {
                LRUTestGenKey(key,sizeof(key));
                redisAppendCommand(context, "GET %s",key);
            }
            for (j = 0; j < LRU_CYCLE_PIPELINE_SIZE; j++) {
                if (redisGetReply(context, (void**)&reply) == REDIS_OK) {
                    switch(reply->type) {
                        case REDIS_REPLY_ERROR:
                            printf("%s\n", reply->str);
                            break;
                        case REDIS_REPLY_NIL:
                            misses++;
                            break;
                        default:
                            hits++;
                            break;
                    }
                }
            }

            if (context->err) {
                fprintf(stderr,"I/O error during LRU test\n");
                exit(1);
            }
        }
        /* Print stats. */
        printf(
            "%lld Gets/sec | Hits: %lld (%.2f%%) | Misses: %lld (%.2f%%)\n",
            hits+misses,
            hits, (double)hits/(hits+misses)*100,
            misses, (double)misses/(hits+misses)*100);
    }
    exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
xorl %eax, %eax
movl %eax, %edi
callq 0x103c0
movq %rax, -0xb8(%rbp)
callq 0x10160
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movslq %ecx, %rcx
xorq %rcx, %rax
movl %eax, %edi
callq 0x102c0
callq 0x16f20
movq %rax, -0x98(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
callq 0x16f20
subq -0x98(%rbp), %rax
cmpq $0x3e8, %rax            # imm = 0x3E8
jge 0x16387
movl $0x0, -0x9c(%rbp)
cmpl $0xfa, -0x9c(%rbp)
jge 0x16224
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
callq 0x13660
movq 0x8b3da(%rip), %rdi     # 0xa15d8
leaq -0x90(%rbp), %rdx
leaq 0x7657d(%rip), %rsi     # 0x8c789
movb $0x0, %al
callq 0x1d600
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x161da
movl $0x0, -0x9c(%rbp)
cmpl $0xfa, -0x9c(%rbp)
jge 0x1625b
movq 0x8b397(%rip), %rdi     # 0xa15d8
leaq -0x8(%rbp), %rsi
callq 0x1d3b0
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x1622e
movl $0x0, -0x9c(%rbp)
cmpl $0xfa, -0x9c(%rbp)
jge 0x162af
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
callq 0x13660
movq 0x8b34f(%rip), %rdi     # 0xa15d8
leaq -0x90(%rbp), %rdx
leaq 0x764fd(%rip), %rsi     # 0x8c794
movb $0x0, %al
callq 0x1d600
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x16265
movl $0x0, -0x9c(%rbp)
cmpl $0xfa, -0x9c(%rbp)
jge 0x16354
movq 0x8b308(%rip), %rdi     # 0xa15d8
leaq -0x8(%rbp), %rsi
callq 0x1d3b0
cmpl $0x0, %eax
jne 0x1633e
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xbc(%rbp)
subl $0x4, %eax
je 0x16316
jmp 0x162f1
movl -0xbc(%rbp), %eax
subl $0x6, %eax
jne 0x1632a
jmp 0x162fe
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
leaq 0x75c2e(%rip), %rdi     # 0x8bf3b
movb $0x0, %al
callq 0x101d0
jmp 0x1633c
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x1633c
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x1633e
jmp 0x16340
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x162b9
movq 0x8b27d(%rip), %rax     # 0xa15d8
cmpl $0x0, (%rax)
je 0x16382
movq 0x88c89(%rip), %rax     # 0x9eff0
movq (%rax), %rdi
leaq 0x7642a(%rip), %rsi     # 0x8c79b
movb $0x0, %al
callq 0x10360
movl $0x1, %edi
callq 0x10600
jmp 0x161b8
movq -0xa8(%rbp), %rsi
addq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
cvtsi2sdq -0xa8(%rbp), %xmm0
movq -0xa8(%rbp), %rax
addq -0xb0(%rbp), %rax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd 0x70e14(%rip), %xmm1    # 0x871d8
mulsd %xmm1, %xmm0
movq -0xb0(%rbp), %rcx
cvtsi2sdq -0xb0(%rbp), %xmm1
movq -0xa8(%rbp), %rax
addq -0xb0(%rbp), %rax
cvtsi2sd %rax, %xmm2
divsd %xmm2, %xmm1
movsd 0x70de1(%rip), %xmm2    # 0x871d8
mulsd %xmm2, %xmm1
leaq 0x763b4(%rip), %rdi     # 0x8c7b6
movb $0x2, %al
callq 0x101d0
jmp 0x16196
nop