// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0xa310
movl %eax, %edi
callq 0xa070
movl $0x1, %edi
movl $0x1, %esi
callq 0xa2b0
movl $0xd, %edi
movl $0x1, %esi
callq 0xa2b0
movl $0x32, 0x8093a(%rip)    # 0x8e3f8
movl $0x186a0, 0x80938(%rip) # imm = 0x186A0
movl $0x0, 0x8092a(%rip)     # 0x8e3fc
movl $0x2800, %edi           # imm = 0x2800
callq 0xa6d0
movq %rax, 0x808f5(%rip)     # 0x8e3d8
movq 0x808ee(%rip), %rdi     # 0x8e3d8
movl $0x1, %esi
leaq -0x296(%rip), %rdx      # 0xd860
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rcx
callq 0xae80
movl $0x1, 0x8090f(%rip)     # 0x8e41c
movl $0x3, 0x808f9(%rip)     # 0x8e410
movl $0x1, 0x808ff(%rip)     # 0x8e420
movl $0x0, 0x808e9(%rip)     # 0x8e414
movl $0x0, 0x808e3(%rip)     # 0x8e418
movl $0x0, 0x80911(%rip)     # 0x8e450
movl $0x0, 0x8090b(%rip)     # 0x8e454
movl $0x0, 0x80905(%rip)     # 0x8e458
movl $0x0, 0x808ff(%rip)     # 0x8e45c
movq $0x0, 0x808d0(%rip) # 0x8e438
callq 0xee90
movq %rax, 0x808d4(%rip)     # 0x8e448
leaq 0x6ef4b(%rip), %rax     # 0x7cac6
movq %rax, 0x8085e(%rip)     # 0x8e3e0
movl $0x148e, 0x8085c(%rip)  # imm = 0x148E
movq $0x0, 0x80859(%rip) # 0x8e3f0
movq $0x0, 0x808ce(%rip) # 0x8e470
movl $0x0, 0x808b4(%rip)     # 0x8e460
movq $0x0, 0x808c1(%rip) # 0x8e478
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xd290
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movslq 0x80813(%rip), %rdi     # 0x8e400
shlq $0x3, %rdi
callq 0xf770
movq %rax, 0x8083b(%rip)     # 0x8e438
cmpl $0x0, 0x80818(%rip)     # 0x8e41c
jne 0xdc14
leaq 0x6eec3(%rip), %rdi     # 0x7cad0
movb $0x0, %al
callq 0xa190
cmpl $0x0, 0x80841(%rip)     # 0x8e45c
je 0xdc5d
movl 0x807d5(%rip), %esi     # 0x8e3f8
leaq 0x6ef6d(%rip), %rdi     # 0x7cb97
movb $0x0, %al
callq 0xa190
leaq 0x6f1a1(%rip), %rdi     # 0x7cdd9
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0xdeb0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0xe3a0
movq 0x80780(%rip), %rdi     # 0x8e3d8
callq 0xb830
cmpl $0x0, -0x8(%rbp)
je 0xdd2e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x13ad0
movq %rax, -0x40(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0xdce7
movq -0x40(%rbp), %rdi
leaq 0x6fa5c(%rip), %rsi     # 0x7d6ed
movl $0x1, %edx
callq 0x14600
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa160
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %rax, %rdx
callq 0x14600
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xdc7e
jmp 0xdce9
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %ecx
callq 0x11630
movl %eax, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0xe400
movq -0x28(%rbp), %rdi
callq 0xa040
cmpl $0x0, 0x80738(%rip)     # 0x8e458
jne 0xdce9
movl $0x0, -0x4(%rbp)
jmp 0xdea5
movl 0x806dc(%rip), %eax     # 0x8e410
addl $0x1, %eax
movslq %eax, %rdi
callq 0xf770
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movslq 0x806c2(%rip), %rdx     # 0x8e410
movl $0x78, %esi
callq 0xa200
movq -0x20(%rbp), %rax
movslq 0x806ad(%rip), %rcx     # 0x8e410
movb $0x0, (%rax,%rcx)
leaq 0x6ee6e(%rip), %rdi     # 0x7cbdc
callq 0xd9c0
cmpl $0x0, %eax
jne 0xdd89
leaq 0x6ee69(%rip), %rdi     # 0x7cbe8
callq 0xd9c0
cmpl $0x0, %eax
je 0xdda1
leaq 0x6ee5d(%rip), %rdi     # 0x7cbed
leaq 0x6ee62(%rip), %rsi     # 0x7cbf9
movl $0x6, %edx
callq 0xe400
leaq 0x6ee58(%rip), %rdi     # 0x7cc00
callq 0xd9c0
cmpl $0x0, %eax
jne 0xddc3
leaq 0x6ee2f(%rip), %rdi     # 0x7cbe8
callq 0xd9c0
cmpl $0x0, %eax
je 0xddf4
leaq -0x28(%rbp), %rdi
leaq 0x6ee3d(%rip), %rsi     # 0x7cc0b
movb $0x0, %al
callq 0x11590
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
leaq 0x6ee2a(%rip), %rdi     # 0x7cc10
callq 0xe400
movq -0x28(%rbp), %rdi
callq 0xa040
leaq 0x6ee1f(%rip), %rdi     # 0x7cc1a
callq 0xd9c0
cmpl $0x0, %eax
je 0xde36
leaq -0x28(%rbp), %rdi
leaq 0x6ee0e(%rip), %rsi     # 0x7cc1e
movb $0x0, %al
callq 0x11590
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
leaq 0x6ee0b(%rip), %rdi     # 0x7cc33
callq 0xe400
movq -0x28(%rbp), %rdi
callq 0xa040
leaq 0x6edfa(%rip), %rdi     # 0x7cc37
callq 0xd9c0
cmpl $0x0, %eax
je 0xde78
leaq -0x28(%rbp), %rdi
leaq 0x6edea(%rip), %rsi     # 0x7cc3c
movb $0x0, %al
callq 0x11590
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
leaq 0x6edec(%rip), %rdi     # 0x7cc56
callq 0xe400
movq -0x28(%rbp), %rdi
callq 0xa040
cmpl $0x0, 0x805d5(%rip)     # 0x8e454
jne 0xde8f
leaq 0x6ef50(%rip), %rdi     # 0x7cdd8
movb $0x0, %al
callq 0xa190
jmp 0xde91
cmpl $0x0, 0x805c0(%rip)     # 0x8e458
jne 0xdd43
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop