// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/redis-cli.c
// Function: findBigKeys
static void findBigKeys(void) {
    unsigned long long biggest[5] = {0}, counts[5] = {0}, totalsize[5] = {0};
    unsigned long long sampled = 0, total_keys, totlen=0, *sizes=NULL, it=0;
    sds maxkeys[5] = {0};
    char *typename[] = {"string","list","set","hash","zset"};
    char *typeunit[] = {"bytes","items","members","fields","members"};
    redisReply *reply, *keys;
    unsigned int arrsize=0, i;
    int type, *types=NULL;
    double pct;

    /* Total keys pre scanning */
    total_keys = getDbSize();

    /* Status message */
    printf("\n# Scanning the entire keyspace to find biggest keys as well as\n");
    printf("# average sizes per key type.  You can use -i 0.1 to sleep 0.1 sec\n");
    printf("# per 100 SCAN commands (not usually needed).\n\n");

    /* New up sds strings to keep track of overall biggest per type */
    for(i=0;i<TYPE_NONE; i++) {
        maxkeys[i] = sdsempty();
        if(!maxkeys[i]) {
            fprintf(stderr, "Failed to allocate memory for largest key names!\n");
            exit(1);
        }
    }

    /* SCAN loop */
    do {
        /* Calculate approximate percentage completion */
        pct = 100 * (double)sampled/total_keys;

        /* Grab some keys and point to the keys array */
        reply = sendScan(&it);
        keys  = reply->element[1];

        /* Reallocate our type and size array if we need to */
        if(keys->elements > arrsize) {
            types = zrealloc(types, sizeof(int)*keys->elements);
            sizes = zrealloc(sizes, sizeof(unsigned long long)*keys->elements);

            if(!types || !sizes) {
                fprintf(stderr, "Failed to allocate storage for keys!\n");
                exit(1);
            }

            arrsize = keys->elements;
        }

        /* Retreive types and then sizes */
        getKeyTypes(keys, types);
        getKeySizes(keys, types, sizes);

        /* Now update our stats */
        for(i=0;i<keys->elements;i++) {
            if((type = types[i]) == TYPE_NONE)
                continue;

            totalsize[type] += sizes[i];
            counts[type]++;
            totlen += keys->element[i]->len;
            sampled++;

            if(biggest[type]<sizes[i]) {
                printf(
                   "[%05.2f%%] Biggest %-6s found so far '%s' with %llu %s\n",
                   pct, typename[type], keys->element[i]->str, sizes[i],
                   typeunit[type]);

                /* Keep track of biggest key name for this type */
                maxkeys[type] = sdscpy(maxkeys[type], keys->element[i]->str);
                if(!maxkeys[type]) {
                    fprintf(stderr, "Failed to allocate memory for key!\n");
                    exit(1);
                }

                /* Keep track of the biggest size for this type */
                biggest[type] = sizes[i];
            }

            /* Update overall progress */
            if(sampled % 1000000 == 0) {
                printf("[%05.2f%%] Sampled %llu keys so far\n", pct, sampled);
            }
        }

        /* Sleep if we've been directed to do so */
        if(sampled && (sampled %100) == 0 && config.interval) {
            usleep(config.interval);
        }

        freeReplyObject(reply);
    } while(it != 0);

    if(types) zfree(types);
    if(sizes) zfree(sizes);

    /* We're done */
    printf("\n-------- summary -------\n\n");

    printf("Sampled %llu keys in the keyspace!\n", sampled);
    printf("Total key length in bytes is %llu (avg len %.2f)\n\n",
       totlen, totlen ? (double)totlen/sampled : 0);

    /* Output the biggest keys we found, for types we did find */
    for(i=0;i<TYPE_NONE;i++) {
        if(sdslen(maxkeys[i])>0) {
            printf("Biggest %6s found '%s' has %llu %s\n", typename[i], maxkeys[i],
               biggest[i], typeunit[i]);
        }
    }

    printf("\n");

    for(i=0;i<TYPE_NONE;i++) {
        printf("%llu %ss with %llu %s (%05.2f%% of keys, avg size %.2f)\n",
           counts[i], typename[i], totalsize[i], typeunit[i],
           sampled ? 100 * (double)counts[i]/sampled : 0,
           counts[i] ? (double)totalsize[i]/counts[i] : 0);
    }

    /* Free sds strings containing max keys */
    for(i=0;i<TYPE_NONE;i++) {
        sdsfree(maxkeys[i]);
    }

    /* Success! */
    exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x10250
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x10250
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x10250
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
movq $0x0, -0xb8(%rbp)
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x10250
leaq -0x110(%rbp), %rdi
leaq 0x87f45(%rip), %rsi     # 0x9d3c0
movl $0x28, %edx
callq 0x103b0
leaq -0x140(%rbp), %rdi
leaq 0x87f5d(%rip), %rsi     # 0x9d3f0
movl $0x28, %edx
callq 0x103b0
movl $0x0, -0x154(%rbp)
movq $0x0, -0x168(%rbp)
callq 0x17cb0
cltq
movq %rax, -0xa0(%rbp)
leaq 0x76cd5(%rip), %rdi     # 0x8c19c
movb $0x0, %al
callq 0x101d0
leaq 0x76d08(%rip), %rdi     # 0x8c1dd
movb $0x0, %al
callq 0x101d0
leaq 0x76d3e(%rip), %rdi     # 0x8c221
movb $0x0, %al
callq 0x101d0
movl $0x0, -0x158(%rbp)
cmpl $0x5, -0x158(%rbp)
jae 0x15559
callq 0x1ed50
movq %rax, %rcx
movl -0x158(%rbp), %eax
movq %rcx, -0xe0(%rbp,%rax,8)
movl -0x158(%rbp), %eax
cmpq $0x0, -0xe0(%rbp,%rax,8)
jne 0x15546
movq 0x89ac5(%rip), %rax     # 0x9eff0
movq (%rax), %rdi
leaq 0x76d1c(%rip), %rsi     # 0x8c251
movb $0x0, %al
callq 0x10360
movl $0x1, %edi
callq 0x10600
jmp 0x15548
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0x154f4
jmp 0x1555b
movq -0x98(%rbp), %xmm0
movaps 0x71c86(%rip), %xmm3    # 0x871f0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x71c8a(%rip), %xmm2    # 0x87200
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x71c4b(%rip), %xmm1    # 0x871d8
mulsd %xmm1, %xmm0
movq -0xa0(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x170(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x17d20
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x154(%rbp), %ecx
cmpq %rcx, %rax
jbe 0x15686
movq -0x168(%rbp), %rdi
movq -0x150(%rbp), %rax
movq 0x20(%rax), %rsi
shlq $0x2, %rsi
callq 0x198d0
movq %rax, -0x168(%rbp)
movq -0xb0(%rbp), %rdi
movq -0x150(%rbp), %rax
movq 0x20(%rax), %rsi
shlq $0x3, %rsi
callq 0x198d0
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0x168(%rbp)
je 0x15653
cmpq $0x0, -0xb0(%rbp)
jne 0x15675
movq 0x89996(%rip), %rax     # 0x9eff0
movq (%rax), %rdi
leaq 0x76c1f(%rip), %rsi     # 0x8c283
movb $0x0, %al
callq 0x10360
movl $0x1, %edi
callq 0x10600
movq -0x150(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, -0x154(%rbp)
movq -0x150(%rbp), %rdi
movq -0x168(%rbp), %rsi
callq 0x17ea0
movq -0x150(%rbp), %rdi
movq -0x168(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0x18030
movl $0x0, -0x158(%rbp)
movl -0x158(%rbp), %eax
movq -0x150(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x158c5
movq -0x168(%rbp), %rax
movl -0x158(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x15c(%rbp)
cmpl $0x5, %eax
jne 0x156f4
jmp 0x158b1
movq -0xb0(%rbp), %rax
movl -0x158(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movslq -0x15c(%rbp), %rax
addq -0x90(%rbp,%rax,8), %rcx
movq %rcx, -0x90(%rbp,%rax,8)
movslq -0x15c(%rbp), %rax
movq -0x60(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movq %rcx, -0x60(%rbp,%rax,8)
movq -0x150(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x158(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movslq 0x10(%rax), %rax
addq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movslq -0x15c(%rbp), %rax
movq -0x30(%rbp,%rax,8), %rax
movq -0xb0(%rbp), %rcx
movl -0x158(%rbp), %edx
cmpq (%rcx,%rdx,8), %rax
jae 0x1587b
movsd -0x170(%rbp), %xmm0
movslq -0x15c(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rsi
movq -0x150(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x158(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rdx
movq -0xb0(%rbp), %rax
movl -0x158(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movslq -0x15c(%rbp), %rax
movq -0x140(%rbp,%rax,8), %r8
leaq 0x76ac5(%rip), %rdi     # 0x8c2a9
movb $0x1, %al
callq 0x101d0
movslq -0x15c(%rbp), %rax
movq -0xe0(%rbp,%rax,8), %rdi
movq -0x150(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x158(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rsi
callq 0x1fa50
movq %rax, %rcx
movslq -0x15c(%rbp), %rax
movq %rcx, -0xe0(%rbp,%rax,8)
movslq -0x15c(%rbp), %rax
cmpq $0x0, -0xe0(%rbp,%rax,8)
jne 0x1585e
movq 0x897ad(%rip), %rax     # 0x9eff0
movq (%rax), %rdi
leaq 0x76a94(%rip), %rsi     # 0x8c2e1
movb $0x0, %al
callq 0x10360
movl $0x1, %edi
callq 0x10600
movq -0xb0(%rbp), %rax
movl -0x158(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movslq -0x15c(%rbp), %rax
movq %rcx, -0x30(%rbp,%rax,8)
movq -0x98(%rbp), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x158af
movsd -0x170(%rbp), %xmm0
movq -0x98(%rbp), %rsi
leaq 0x76a5d(%rip), %rdi     # 0x8c305
movb $0x1, %al
callq 0x101d0
jmp 0x158b1
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0x156bd
cmpq $0x0, -0x98(%rbp)
je 0x158fe
movq -0x98(%rbp), %rax
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x158fe
cmpq $0x0, 0x8bbba(%rip)     # 0xa14a8
je 0x158fe
movq 0x8bbb1(%rip), %rax     # 0xa14a8
movl %eax, %edi
callq 0x106f0
movq -0x148(%rbp), %rdi
callq 0x1b290
cmpq $0x0, -0xb8(%rbp)
jne 0x1555b
cmpq $0x0, -0x168(%rbp)
je 0x1592e
movq -0x168(%rbp), %rdi
callq 0x19a30
cmpq $0x0, -0xb0(%rbp)
je 0x15944
movq -0xb0(%rbp), %rdi
callq 0x19a30
leaq 0x769df(%rip), %rdi     # 0x8c32a
movb $0x0, %al
callq 0x101d0
movq -0x98(%rbp), %rsi
leaq 0x769e6(%rip), %rdi     # 0x8c346
movb $0x0, %al
callq 0x101d0
movq -0xa8(%rbp), %rax
movq %rax, -0x178(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x159d2
movq -0xa8(%rbp), %xmm0
movaps 0x71862(%rip), %xmm3    # 0x871f0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x71866(%rip), %xmm2    # 0x87200
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x98(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x180(%rbp)
jmp 0x159df
xorps %xmm0, %xmm0
movsd %xmm0, -0x180(%rbp)
jmp 0x159df
movq -0x178(%rbp), %rsi
movsd -0x180(%rbp), %xmm0
leaq 0x76975(%rip), %rdi     # 0x8c36a
movb $0x1, %al
callq 0x101d0
movl $0x0, -0x158(%rbp)
cmpl $0x5, -0x158(%rbp)
jae 0x15a7e
movl -0x158(%rbp), %eax
movq -0xe0(%rbp,%rax,8), %rdi
callq 0x17c20
cmpq $0x0, %rax
jbe 0x15a6b
movl -0x158(%rbp), %eax
movq -0x110(%rbp,%rax,8), %rsi
movl -0x158(%rbp), %eax
movq -0xe0(%rbp,%rax,8), %rdx
movl -0x158(%rbp), %eax
movq -0x30(%rbp,%rax,8), %rcx
movl -0x158(%rbp), %eax
movq -0x140(%rbp,%rax,8), %r8
leaq 0x76939(%rip), %rdi     # 0x8c39d
movb $0x0, %al
callq 0x101d0
jmp 0x15a6d
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0x15a06
leaq 0x76916(%rip), %rdi     # 0x8c39b
movb $0x0, %al
callq 0x101d0
movl $0x0, -0x158(%rbp)
cmpl $0x5, -0x158(%rbp)
jae 0x15c3f
movl -0x158(%rbp), %eax
movq -0x60(%rbp,%rax,8), %rax
movq %rax, -0x1a0(%rbp)
movl -0x158(%rbp), %eax
movq -0x110(%rbp,%rax,8), %rax
movq %rax, -0x198(%rbp)
movl -0x158(%rbp), %eax
movq -0x90(%rbp,%rax,8), %rax
movq %rax, -0x190(%rbp)
movl -0x158(%rbp), %eax
movq -0x140(%rbp,%rax,8), %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x15b61
movl -0x158(%rbp), %eax
movq -0x60(%rbp,%rax,8), %xmm0
movaps 0x716df(%rip), %xmm3    # 0x871f0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x716e3(%rip), %xmm2    # 0x87200
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x716a4(%rip), %xmm1    # 0x871d8
mulsd %xmm1, %xmm0
movq -0x98(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x1a8(%rbp)
jmp 0x15b6e
xorps %xmm0, %xmm0
movsd %xmm0, -0x1a8(%rbp)
jmp 0x15b6e
movsd -0x1a8(%rbp), %xmm0
movsd %xmm0, -0x1b0(%rbp)
movl -0x158(%rbp), %eax
cmpq $0x0, -0x60(%rbp,%rax,8)
je 0x15be4
movl -0x158(%rbp), %eax
movq -0x90(%rbp,%rax,8), %xmm0
movaps 0x7164e(%rip), %xmm3    # 0x871f0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x71652(%rip), %xmm2    # 0x87200
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x60(%rbp,%rax,8), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x1b8(%rbp)
jmp 0x15bf1
xorps %xmm0, %xmm0
movsd %xmm0, -0x1b8(%rbp)
jmp 0x15bf1
movsd -0x1b0(%rbp), %xmm0
movq -0x188(%rbp), %r8
movq -0x190(%rbp), %rcx
movq -0x198(%rbp), %rdx
movq -0x1a0(%rbp), %rsi
movsd -0x1b8(%rbp), %xmm1
leaq 0x7679d(%rip), %rdi     # 0x8c3c1
movb $0x2, %al
callq 0x101d0
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0x15a96
movl $0x0, -0x158(%rbp)
cmpl $0x5, -0x158(%rbp)
jae 0x15c76
movl -0x158(%rbp), %eax
movq -0xe0(%rbp,%rax,8), %rdi
callq 0x1ee80
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0x15c49
xorl %edi, %edi
callq 0x10600
nopl (%rax)