// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/redis-cli.c
// Function: latencyDistMode
static void latencyDistMode(void) {
    redisReply *reply;
    long long start, latency, count = 0;
    long long history_interval =
        config.interval ? config.interval/1000 :
                          LATENCY_DIST_DEFAULT_INTERVAL;
    long long history_start = ustime();
    int j, outputs = 0;

    struct distsamples samples[] = {
        /* We use a mostly logarithmic scale, with certain linear intervals
         * which are more interesting than others, like 1-10 milliseconds
         * range. */
        {10,0,'.'},         /* 0.01 ms */
        {125,0,'-'},        /* 0.125 ms */
        {250,0,'*'},        /* 0.25 ms */
        {500,0,'#'},        /* 0.5 ms */
        {1000,0,'1'},       /* 1 ms */
        {2000,0,'2'},       /* 2 ms */
        {3000,0,'3'},       /* 3 ms */
        {4000,0,'4'},       /* 4 ms */
        {5000,0,'5'},       /* 5 ms */
        {6000,0,'6'},       /* 6 ms */
        {7000,0,'7'},       /* 7 ms */
        {8000,0,'8'},       /* 8 ms */
        {9000,0,'9'},       /* 9 ms */
        {10000,0,'A'},      /* 10 ms */
        {20000,0,'B'},      /* 20 ms */
        {30000,0,'C'},      /* 30 ms */
        {40000,0,'D'},      /* 40 ms */
        {50000,0,'E'},      /* 50 ms */
        {100000,0,'F'},     /* 0.1 s */
        {200000,0,'G'},     /* 0.2 s */
        {300000,0,'H'},     /* 0.3 s */
        {400000,0,'I'},     /* 0.4 s */
        {500000,0,'J'},     /* 0.5 s */
        {1000000,0,'K'},    /* 1 s */
        {2000000,0,'L'},    /* 2 s */
        {4000000,0,'M'},    /* 4 s */
        {8000000,0,'N'},    /* 8 s */
        {16000000,0,'O'},   /* 16 s */
        {30000000,0,'P'},   /* 30 s */
        {60000000,0,'Q'},   /* 1 minute */
        {0,0,'?'},          /* > 1 minute */
    };

    if (!context) exit(1);
    while(1) {
        start = ustime();
        reply = reconnectingRedisCommand(context,"PING");
        if (reply == NULL) {
            fprintf(stderr,"\nI/O error\n");
            exit(1);
        }
        latency = ustime()-start;
        freeReplyObject(reply);
        count++;

        /* Populate the relevant bucket. */
        for (j = 0; ; j++) {
            if (samples[j].max == 0 || latency <= samples[j].max) {
                samples[j].count++;
                break;
            }
        }

        /* From time to time show the spectrum. */
        if (count && (ustime()-history_start)/1000 > history_interval) {
            if ((outputs++ % 20) == 0)
                showLatencyDistLegend();
            showLatencyDistSamples(samples,count);
            history_start = ustime();
            count = 0;
        }
        usleep(LATENCY_SAMPLE_RATE * 1000);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq $0x0, -0x20(%rbp)
cmpq $0x0, 0x8cbed(%rip)     # 0xa14a8
je 0x148d7
movq 0x8cbe4(%rip), %rax     # 0xa14a8
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, -0x328(%rbp)
jmp 0x148e5
movl $0x3e8, %eax            # imm = 0x3E8
movq %rax, -0x328(%rbp)
jmp 0x148e5
movq -0x328(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x17110
movq %rax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
leaq -0x320(%rbp), %rdi
leaq 0x72972(%rip), %rsi     # 0x87280
movl $0x2e8, %edx            # imm = 0x2E8
callq 0x103b0
cmpq $0x0, 0x8ccb8(%rip)     # 0xa15d8
jne 0x1492c
movl $0x1, %edi
callq 0x10600
jmp 0x1492e
callq 0x17110
movq %rax, -0x10(%rbp)
movq 0x8cc9a(%rip), %rdi     # 0xa15d8
leaq 0x74b71(%rip), %rsi     # 0x894b6
movb $0x0, %al
callq 0x16f40
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x14979
movq 0x8a692(%rip), %rax     # 0x9eff0
movq (%rax), %rdi
leaq 0x773f0(%rip), %rsi     # 0x8bd58
movb $0x0, %al
callq 0x10360
movl $0x1, %edi
callq 0x10600
callq 0x17110
subq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1b290
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rcx
leaq -0x320(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x149d5
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rdx
leaq -0x320(%rbp), %rcx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jg 0x149f5
movslq -0x34(%rbp), %rcx
leaq -0x320(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
jmp 0x14a02
jmp 0x149f7
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x149a2
cmpq $0x0, -0x20(%rbp)
je 0x14a60
callq 0x17110
subq -0x30(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
cmpq -0x28(%rbp), %rax
jle 0x14a60
movl -0x38(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x38(%rbp)
movl $0x14, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x14a3f
callq 0x13230
leaq -0x320(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x13130
callq 0x17110
movq %rax, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x2710, %edi           # imm = 0x2710
callq 0x106f0
jmp 0x1492e
nop