// File: /workspace/github_c_makefile_star2_O3/erikdubbelboer[P]discnt/src/discnt-benchmark.c
// Function: main
int main(int argc, const char **argv) {
    int i;
    char *data, *cmd;
    int len;

    client c;

    srandom(time(NULL));
    signal(SIGHUP, SIG_IGN);
    signal(SIGPIPE, SIG_IGN);

    config.numclients = 50;
    config.requests = 100000;
    config.liveclients = 0;
    config.el = aeCreateEventLoop(1024*10);
    aeCreateTimeEvent(config.el,1,showThroughput,NULL,NULL);
    config.keepalive = 1;
    config.datasize = 3;
    config.pipeline = 1;
    config.randomkeys = 0;
    config.randomkeys_keyspacelen = 0;
    config.quiet = 0;
    config.csv = 0;
    config.loop = 0;
    config.idlemode = 0;
    config.latency = NULL;
    config.clients = listCreate();
    config.hostip = "127.0.0.1";
    config.hostport = 5262;
    config.hostsocket = NULL;
    config.tests = NULL;
    config.dbnum = 0;
    config.auth = NULL;

    i = parseOptions(argc,argv);
    argc -= i;
    argv += i;

    config.latency = zmalloc(sizeof(long long)*config.requests);

    if (config.keepalive == 0) {
        printf("WARNING: keepalive disabled, you probably need 'echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse' for Linux and 'sudo sysctl -w net.inet.tcp.msl=1000' for Mac OS X in order to use a lot of clients/requests\n");
    }

    if (config.idlemode) {
        printf("Creating %d idle connections and waiting forever (Ctrl+C when done)\n", config.numclients);
        c = createClient("",0,NULL); /* will never receive a reply */
        createMissingClients(c);
        aeMain(config.el);
        /* and will wait for every */
    }

    /* Run benchmark with command in the remainder of the arguments. */
    if (argc) {
        sds title = sdsnew(argv[0]);
        for (i = 1; i < argc; i++) {
            title = sdscatlen(title, " ", 1);
            title = sdscatlen(title, (char*)argv[i], strlen(argv[i]));
        }

        do {
            len = redisFormatCommandArgv(&cmd,argc,argv,NULL);
            benchmark(title,cmd,len);
            free(cmd);
        } while(config.loop);

        return 0;
    }

    /* Run default benchmark suite. */
    data = zmalloc(config.datasize+1);
    do {
        memset(data,'x',config.datasize);
        data[config.datasize] = '\0';

        if (test_is_selected("ping_inline") || test_is_selected("ping"))
            benchmark("PING_INLINE","PING\r\n",6);

        if (test_is_selected("ping_mbulk") || test_is_selected("ping")) {
            len = redisFormatCommand(&cmd,"PING");
            benchmark("PING_BULK",cmd,len);
            free(cmd);
        }

        if (test_is_selected("get")) {
            len = redisFormatCommand(&cmd,"GET key:__rand_int__");
            benchmark("GET",cmd,len);
            free(cmd);
        }

        if (test_is_selected("incr")) {
            len = redisFormatCommand(&cmd,"INCR counter:__rand_int__");
            benchmark("INCR",cmd,len);
            free(cmd);
        }

        if (!config.csv) printf("\n");
    } while(config.loop);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
xorl %r15d, %r15d
xorl %edi, %edi
callq 0xa340
movl %eax, %edi
callq 0xa090
movl $0x1, %esi
movl $0x1, %edi
callq 0xa2e0
movl $0x1, %esi
movl $0xd, %edi
callq 0xa2e0
movq $0x32, 0x35227(%rip) # 0x45408
movl $0x186a0, 0x35225(%rip) # imm = 0x186A0
movl $0x2800, %edi           # imm = 0x2800
callq 0xe0fc
movq %rax, 0x351ec(%rip)     # 0x453e8
leaq -0x1c7(%rip), %rdx      # 0x1003c
movl $0x1, %esi
movq %rax, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xe6af
movl $0x1, 0x35211(%rip)     # 0x45430
movaps 0x23fca(%rip), %xmm0    # 0x341f0
movups %xmm0, 0x351f3(%rip)    # 0x45420
movq %r15, 0x35214(%rip)     # 0x45448
xorps %xmm0, %xmm0
movups %xmm0, 0x35222(%rip)    # 0x45460
callq 0x11030
movq %rax, 0x3520e(%rip)     # 0x45458
leaq 0x240bd(%rip), %rax     # 0x3430e
movq %rax, 0x35198(%rip)     # 0x453f0
movl $0x148e, 0x35196(%rip)  # imm = 0x148E
movq %r15, 0x35197(%rip)     # 0x45400
movl $0x0, 0x351fd(%rip)     # 0x45470
xorps %xmm0, %xmm0
movups %xmm0, 0x35203(%rip)    # 0x45480
movl %ebx, %edi
movq %r14, %rsi
callq 0xfc04
movl %eax, %ebp
movslq 0x35180(%rip), %rdi     # 0x45410
shlq $0x3, %rdi
callq 0x11459
movq %rax, 0x351a8(%rip)     # 0x45448
cmpl $0x0, 0x35185(%rip)     # 0x4542c
jne 0x102b5
leaq 0x24b2f(%rip), %rdi     # 0x34ddf
callq 0xa0d0
cmpl $0x0, 0x351b0(%rip)     # 0x4546c
je 0x102f6
movl 0x35144(%rip), %esi     # 0x45408
leaq 0x2404d(%rip), %rdi     # 0x34318
xorl %eax, %eax
callq 0xa1b0
leaq 0x24281(%rip), %rdi     # 0x3455a
xorl %esi, %esi
xorl %edx, %edx
callq 0x104f9
movq %rax, %rdi
callq 0x10878
movq 0x350f7(%rip), %rdi     # 0x453e8
callq 0xec26
cmpl %ebp, %ebx
jne 0x10459
movslq 0x3511b(%rip), %rdi     # 0x45420
incq %rdi
callq 0x11459
movq %rax, %rbx
leaq 0x2406a(%rip), %r12     # 0x34381
leaq 0x2407d(%rip), %r13     # 0x3439b
leaq 0x24093(%rip), %rbp     # 0x343b8
movq %rsp, %r15
movslq 0x350f1(%rip), %r14     # 0x45420
movq %rbx, %rdi
movl $0x78, %esi
movq %r14, %rdx
callq 0xa220
movb $0x0, (%rbx,%r14)
leaq 0x24012(%rip), %rdi     # 0x3435d
callq 0x10103
testl %eax, %eax
jne 0x10364
leaq 0x2400e(%rip), %rdi     # 0x34369
callq 0x10103
testl %eax, %eax
je 0x1037c
leaq 0x24003(%rip), %rdi     # 0x3436e
leaq 0x24008(%rip), %rsi     # 0x3437a
movl $0x6, %edx
callq 0x108ca
movq %r12, %rdi
callq 0x10103
testl %eax, %eax
jne 0x10398
leaq 0x23fda(%rip), %rdi     # 0x34369
callq 0x10103
testl %eax, %eax
je 0x103c4
movq %r15, %rdi
leaq 0x23fea(%rip), %rsi     # 0x3438c
xorl %eax, %eax
callq 0x12905
movq (%rsp), %rsi
leaq 0x23fdd(%rip), %rdi     # 0x34391
movl %eax, %edx
callq 0x108ca
movq (%rsp), %rdi
callq 0xa050
movq %r13, %rdi
callq 0x10103
testl %eax, %eax
je 0x103fc
movq %r15, %rdi
leaq 0x23fc5(%rip), %rsi     # 0x3439f
xorl %eax, %eax
callq 0x12905
movq (%rsp), %rsi
leaq 0x23fc8(%rip), %rdi     # 0x343b4
movl %eax, %edx
callq 0x108ca
movq (%rsp), %rdi
callq 0xa050
movq %rbp, %rdi
callq 0x10103
testl %eax, %eax
je 0x10434
movq %r15, %rdi
leaq 0x23fab(%rip), %rsi     # 0x343bd
xorl %eax, %eax
callq 0x12905
movq (%rsp), %rsi
leaq 0x23fb3(%rip), %rdi     # 0x343d7
movl %eax, %edx
callq 0x108ca
movq (%rsp), %rdi
callq 0xa050
cmpl $0x0, 0x35029(%rip)     # 0x45464
jne 0x10447
movl $0xa, %edi
callq 0xa060
cmpl $0x0, 0x3501a(%rip)     # 0x45468
jne 0x10328
jmp 0x104e8
movslq %ebp, %rax
subl %eax, %ebx
leaq (%r14,%rax,8), %r14
movq (%r14), %rdi
callq 0x13b35
movq %rax, %r15
cmpl $0x2, %ebx
jl 0x104b6
movl %ebx, %ebp
movl $0x1, %r12d
movl $0x1, %edx
movq %r15, %rdi
leaq 0x255cf(%rip), %rsi     # 0x35a58
callq 0x1435a
movq %rax, %r15
movq (%r14,%r12,8), %r13
movq %r13, %rdi
callq 0xa180
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x1435a
movq %rax, %r15
incq %r12
cmpq %r12, %rbp
jne 0x1047a
movq %rsp, %r12
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x12989
movq (%rsp), %rsi
movq %r15, %rdi
movl %eax, %edx
callq 0x108ca
movq (%rsp), %rdi
callq 0xa050
cmpl $0x0, 0x34f82(%rip)     # 0x45468
jne 0x104b9
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq