// File: /workspace/github_c_makefile_star2_O1/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, 0x35e9e(%rip) # 0x46408
movl $0x186a0, 0x35e9c(%rip) # imm = 0x186A0
movl $0x2800, %edi           # imm = 0x2800
callq 0xe66c
movq %rax, 0x35e63(%rip)     # 0x463e8
leaq -0x1c7(%rip), %rdx      # 0x103c5
movl $0x1, %esi
movq %rax, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xea1b
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x35e7d(%rip)     # 0x4642c
movl $0x3, 0x35e67(%rip)     # 0x46420
movq %r15, 0x35e64(%rip)     # 0x46424
movq %r15, 0x35e81(%rip)     # 0x46448
xorps %xmm0, %xmm0
movups %xmm0, 0x35e8f(%rip)    # 0x46460
callq 0x113b0
movq %rax, 0x35e7b(%rip)     # 0x46458
leaq 0x24cf4(%rip), %rax     # 0x352d8
movq %rax, 0x35e05(%rip)     # 0x463f0
movl $0x148e, 0x35e03(%rip)  # imm = 0x148E
movq %r15, 0x35e04(%rip)     # 0x46400
movl $0x0, 0x35e6a(%rip)     # 0x46470
xorps %xmm0, %xmm0
movups %xmm0, 0x35e70(%rip)    # 0x46480
movl %ebx, %edi
movq %r14, %rsi
callq 0xffb4
movl %eax, %ebp
movslq 0x35ded(%rip), %rdi     # 0x46410
shlq $0x3, %rdi
callq 0x117e9
movq %rax, 0x35e15(%rip)     # 0x46448
cmpl $0x0, 0x35df2(%rip)     # 0x4642c
jne 0x10648
leaq 0x25766(%rip), %rdi     # 0x35da9
callq 0xa0d0
cmpl $0x0, 0x35e1d(%rip)     # 0x4646c
je 0x10689
movl 0x35db1(%rip), %esi     # 0x46408
leaq 0x24c84(%rip), %rdi     # 0x352e2
xorl %eax, %eax
callq 0xa1b0
leaq 0x24eb8(%rip), %rdi     # 0x35524
xorl %esi, %esi
xorl %edx, %edx
callq 0x1088c
movq %rax, %rdi
callq 0x10bfb
movq 0x35d64(%rip), %rdi     # 0x463e8
callq 0xef9c
cmpl %ebp, %ebx
jne 0x107ec
movslq 0x35d88(%rip), %rdi     # 0x46420
incq %rdi
callq 0x117e9
movq %rax, %rbx
leaq 0x24ca1(%rip), %r12     # 0x3534b
leaq 0x24cb4(%rip), %r13     # 0x35365
leaq 0x24cca(%rip), %rbp     # 0x35382
movq %rsp, %r15
movslq 0x35d5e(%rip), %r14     # 0x46420
movq %rbx, %rdi
movl $0x78, %esi
movq %r14, %rdx
callq 0xa220
movb $0x0, (%rbx,%r14)
leaq 0x24c49(%rip), %rdi     # 0x35327
callq 0x1048c
testl %eax, %eax
jne 0x106f7
leaq 0x24c45(%rip), %rdi     # 0x35333
callq 0x1048c
testl %eax, %eax
je 0x1070f
leaq 0x24c3a(%rip), %rdi     # 0x35338
leaq 0x24c3f(%rip), %rsi     # 0x35344
movl $0x6, %edx
callq 0x10c4d
movq %r12, %rdi
callq 0x1048c
testl %eax, %eax
jne 0x1072b
leaq 0x24c11(%rip), %rdi     # 0x35333
callq 0x1048c
testl %eax, %eax
je 0x10757
movq %r15, %rdi
leaq 0x24c21(%rip), %rsi     # 0x35356
xorl %eax, %eax
callq 0x12ccb
movq (%rsp), %rsi
leaq 0x24c14(%rip), %rdi     # 0x3535b
movl %eax, %edx
callq 0x10c4d
movq (%rsp), %rdi
callq 0xa050
movq %r13, %rdi
callq 0x1048c
testl %eax, %eax
je 0x1078f
movq %r15, %rdi
leaq 0x24bfc(%rip), %rsi     # 0x35369
xorl %eax, %eax
callq 0x12ccb
movq (%rsp), %rsi
leaq 0x24bff(%rip), %rdi     # 0x3537e
movl %eax, %edx
callq 0x10c4d
movq (%rsp), %rdi
callq 0xa050
movq %rbp, %rdi
callq 0x1048c
testl %eax, %eax
je 0x107c7
movq %r15, %rdi
leaq 0x24be2(%rip), %rsi     # 0x35387
xorl %eax, %eax
callq 0x12ccb
movq (%rsp), %rsi
leaq 0x24bea(%rip), %rdi     # 0x353a1
movl %eax, %edx
callq 0x10c4d
movq (%rsp), %rdi
callq 0xa050
cmpl $0x0, 0x35c96(%rip)     # 0x46464
jne 0x107da
movl $0xa, %edi
callq 0xa060
cmpl $0x0, 0x35c87(%rip)     # 0x46468
jne 0x106bb
jmp 0x1087b
movslq %ebp, %rax
subl %eax, %ebx
leaq (%r14,%rax,8), %r14
movq (%r14), %rdi
callq 0x13f5a
movq %rax, %r15
cmpl $0x2, %ebx
jl 0x10849
movl %ebx, %ebp
movl $0x1, %r12d
movl $0x1, %edx
movq %r15, %rdi
leaq 0x2620c(%rip), %rsi     # 0x36a28
callq 0x14765
movq %rax, %r15
movq (%r14,%r12,8), %r13
movq %r13, %rdi
callq 0xa180
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x14765
movq %rax, %r15
incq %r12
cmpq %r12, %rbp
jne 0x1080d
movq %rsp, %r12
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x12d4f
movq (%rsp), %rsi
movq %r15, %rdi
movl %eax, %edx
callq 0x10c4d
movq (%rsp), %rdi
callq 0xa050
cmpl $0x0, 0x35bef(%rip)     # 0x46468
jne 0x1084c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq