// File: /workspace/github_c_makefile_star2_O3/erikdubbelboer[P]discnt/src/discnt-benchmark.c
// Function: parseOptions
int parseOptions(int argc, const char **argv) {
    int i;
    int lastarg;
    int exit_status = 1;

    for (i = 1; i < argc; i++) {
        lastarg = (i == (argc-1));

        if (!strcmp(argv[i],"-c")) {
            if (lastarg) goto invalid;
            config.numclients = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-n")) {
            if (lastarg) goto invalid;
            config.requests = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-k")) {
            if (lastarg) goto invalid;
            config.keepalive = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-h")) {
            if (lastarg) goto invalid;
            config.hostip = strdup(argv[++i]);
        } else if (!strcmp(argv[i],"-p")) {
            if (lastarg) goto invalid;
            config.hostport = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-s")) {
            if (lastarg) goto invalid;
            config.hostsocket = strdup(argv[++i]);
        } else if (!strcmp(argv[i],"-a") ) {
            if (lastarg) goto invalid;
            config.auth = strdup(argv[++i]);
        } else if (!strcmp(argv[i],"-d")) {
            if (lastarg) goto invalid;
            config.datasize = atoi(argv[++i]);
            if (config.datasize < 1) config.datasize=1;
            if (config.datasize > 1024*1024*1024) config.datasize = 1024*1024*1024;
        } else if (!strcmp(argv[i],"-P")) {
            if (lastarg) goto invalid;
            config.pipeline = atoi(argv[++i]);
            if (config.pipeline <= 0) config.pipeline=1;
        } else if (!strcmp(argv[i],"-r")) {
            if (lastarg) goto invalid;
            config.randomkeys = 1;
            config.randomkeys_keyspacelen = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-q")) {
            config.quiet = 1;
        } else if (!strcmp(argv[i],"--csv")) {
            config.csv = 1;
        } else if (!strcmp(argv[i],"-l")) {
            config.loop = 1;
        } else if (!strcmp(argv[i],"-I")) {
            config.idlemode = 1;
        } else if (!strcmp(argv[i],"-t")) {
            if (lastarg) goto invalid;
            /* We get the list of tests to run as a string in the form
             * get,set,lrange,...,test_N. Then we add a comma before and
             * after the string in order to make sure that searching
             * for ",testname," will always get a match if the test is
             * enabled. */
            config.tests = sdsnew(",");
            config.tests = sdscat(config.tests,(char*)argv[++i]);
            config.tests = sdscat(config.tests,",");
            sdstolower(config.tests);
        } else if (!strcmp(argv[i],"--dbnum")) {
            if (lastarg) goto invalid;
            config.dbnum = atoi(argv[++i]);
            config.dbnumstr = sdsfromlonglong(config.dbnum);
        } else if (!strcmp(argv[i],"--help")) {
            exit_status = 0;
            goto usage;
        } else {
            /* Assume the user meant to provide an option when the arg starts
             * with a dash. We're done otherwise and should use the remainder
             * as the command and arguments for running the benchmark. */
            if (argv[i][0] == '-') goto invalid;
            return i;
        }
    }

    return i;

invalid:
    printf("Invalid option \"%s\" or option argument missing\n\n",argv[i]);

usage:
    printf(
"Usage: discnt-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]\n\n"
" -h <hostname>      Server hostname (default 127.0.0.1)\n"
" -p <port>          Server port (default 5262)\n"
" -s <socket>        Server socket (overrides host and port)\n"
" -a <password>      Password for Discnt Auth\n"
" -c <clients>       Number of parallel connections (default 50)\n"
" -n <requests>      Total number of requests (default 100000)\n"
" -d <size>          Data size of GET value in bytes (default 2)\n"
" -dbnum <db>        SELECT the specified db number (default 0)\n"
" -k <boolean>       1=keep alive 0=reconnect (default 1)\n"
" -r <keyspacelen>   Use random keys for GET/INCR, random values for SADD\n"
"  Using this option the benchmark will expand the string __rand_int__\n"
"  inside an argument with a 12 digits number in the specified range\n"
"  from 0 to keyspacelen-1. The substitution changes every time a command\n"
"  is executed. Default tests use this to hit random keys in the\n"
"  specified range.\n"
" -P <numreq>        Pipeline <numreq> requests. Default 1 (no pipeline).\n"
" -q                 Quiet. Just show query/sec values\n"
" --csv              Output in CSV format\n"
" -l                 Loop. Run the tests forever\n"
" -t <tests>         Only run the comma separated list of tests. The test\n"
"                    names are the same as the ones produced as output.\n"
" -I                 Idle mode. Just open N idle connections and wait.\n\n"
"Examples:\n\n"
" Run the benchmark with the default configuration against 127.0.0.1:5262:\n"
"   $ discnt-benchmark\n\n"
" Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:\n"
"   $ discnt-benchmark -h 192.168.1.1 -p 5262 -n 100000 -c 20\n\n"
" Fill 127.0.0.1:5262 with about 1 million keys only using the INCR test:\n"
"   $ discnt-benchmark -t incr -n 1000000 -r 100000000\n\n"
" Benchmark 127.0.0.1:5262 for a few commands producing CSV output:\n"
"   $ discnt-benchmark -t ping,incr,get -n 100000 --csv\n\n"
" Increment 10000 random elements:\n"
"   $ discnt-benchmark -r 10000 -n 10000 incr __rand_int__ 1.0\n\n"
" On user specified command lines __rand_int__ is replaced with a random integer\n"
" with a range of values selected by the -r option.\n"
    );
    exit(exit_status);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x1, %ebx
cmpl $0x2, %edi
jl 0xfffe
movq %rsi, %r14
movl %edi, %r15d
leal -0x1(%r15), %eax
movl %eax, 0x4(%rsp)
movslq %ebx, %r12
movq (%r14,%r12,8), %r13
movb (%r13), %bpl
cmpb $0x2d, %bpl
jne 0xfd26
cmpb $0x63, 0x1(%r13)
jne 0xfc52
cmpb $0x0, 0x2(%r13)
je 0xfd84
cmpb $0x6e, 0x1(%r13)
jne 0xfc64
cmpb $0x0, 0x2(%r13)
je 0xfda5
cmpb $0x6b, 0x1(%r13)
jne 0xfc76
cmpb $0x0, 0x2(%r13)
je 0xfdc6
cmpb $0x68, 0x1(%r13)
jne 0xfc88
cmpb $0x0, 0x2(%r13)
je 0xfde7
cmpb $0x70, 0x1(%r13)
jne 0xfc9a
cmpb $0x0, 0x2(%r13)
je 0xfe09
cmpb $0x73, 0x1(%r13)
jne 0xfcac
cmpb $0x0, 0x2(%r13)
je 0xfe2a
cmpb $0x61, 0x1(%r13)
jne 0xfcbe
cmpb $0x0, 0x2(%r13)
je 0xff13
cmpb $0x64, 0x1(%r13)
jne 0xfcd0
cmpb $0x0, 0x2(%r13)
je 0xff32
cmpb $0x50, 0x1(%r13)
jne 0xfce2
cmpb $0x0, 0x2(%r13)
je 0xff65
cmpb $0x72, 0x1(%r13)
jne 0xfcf4
cmpb $0x0, 0x2(%r13)
je 0xff91
cmpb $0x71, 0x1(%r13)
jne 0xfe4c
cmpb $0x0, 0x2(%r13)
je 0xffb8
movq %r13, %rdi
leaq 0x24574(%rip), %rsi     # 0x34288
callq 0xa2d0
testl %eax, %eax
jne 0xfe6d
jmp 0xfef9
movq %r13, %rdi
leaq 0x24558(%rip), %rsi     # 0x34288
callq 0xa2d0
testl %eax, %eax
je 0xfef9
movq %r13, %rdi
leaq 0x24549(%rip), %rsi     # 0x34290
callq 0xa2d0
testl %eax, %eax
jne 0xffe5
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x35700(%rip)     # 0x45470
movslq %eax, %rdi
callq 0x146a3
movq %rax, 0x356f9(%rip)     # 0x45478
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x35668(%rip)     # 0x45408
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x3564f(%rip)     # 0x45410
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x3564a(%rip)     # 0x4542c
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa540
movq %rax, 0x355ec(%rip)     # 0x453f0
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x355d3(%rip)     # 0x453f8
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa540
movq %rax, 0x355b9(%rip)     # 0x45400
jmp 0xff03
movq %r13, %rdi
leaq 0x24432(%rip), %rsi     # 0x34288
callq 0xa2d0
testl %eax, %eax
je 0xfef9
cmpb $0x2d, %bpl
jne 0xfd3d
cmpb $0x6c, 0x1(%r13)
jne 0xfe7f
cmpb $0x0, 0x2(%r13)
je 0xffc7
cmpb $0x49, 0x1(%r13)
jne 0xfe91
cmpb $0x0, 0x2(%r13)
je 0xffd6
cmpb $0x74, 0x1(%r13)
jne 0xfd3d
cmpb $0x0, 0x2(%r13)
jne 0xfd3d
cmpl 0x4(%rsp), %ebx
je 0x1000f
leaq 0x243d6(%rip), %r13     # 0x3428e
movq %r13, %rdi
callq 0x13b35
movq %rax, 0x355b9(%rip)     # 0x45480
incl %ebx
movq 0x8(%r14,%r12,8), %rsi
movq %rax, %rdi
callq 0x14425
movq %rax, 0x355a3(%rip)     # 0x45480
movq %rax, %rdi
movq %r13, %rsi
callq 0x14425
movq %rax, 0x35591(%rip)     # 0x45480
movq %rax, %rdi
callq 0x15133
jmp 0xff03
movl $0x1, 0x35561(%rip)     # 0x45464
incl %ebx
cmpl %r15d, %ebx
jl 0xfc2b
jmp 0xfffe
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa540
movq %rax, 0x35558(%rip)     # 0x45488
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
cmpl $0x2, %eax
movl $0x1, %ecx
cmovll %ecx, %eax
movl $0x40000000, %ecx       # imm = 0x40000000
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %eax, 0x354bd(%rip)     # 0x45420
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
cmpl $0x2, %eax
movl $0x1, %ecx
cmovll %ecx, %eax
movl %eax, 0x354a4(%rip)     # 0x45430
jmp 0xff03
cmpl 0x4(%rsp), %ebx
je 0x1000f
movl $0x1, 0x35483(%rip)     # 0x45424
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x35475(%rip)     # 0x45428
jmp 0xff03
movl $0x1, 0x3549e(%rip)     # 0x45460
jmp 0xff03
movl $0x1, 0x35497(%rip)     # 0x45468
jmp 0xff03
movl $0x1, 0x3548c(%rip)     # 0x4546c
jmp 0xff03
leaq 0x242ac(%rip), %rsi     # 0x34298
movq %r13, %rdi
callq 0xa2d0
testl %eax, %eax
je 0x10038
cmpb $0x2d, %bpl
je 0x1000f
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24289(%rip), %rdi     # 0x3429f
movq %r13, %rsi
xorl %eax, %eax
callq 0xa1b0
movl $0x1, %ebx
leaq 0x2455a(%rip), %rdi     # 0x34586
callq 0xa0d0
movl %ebx, %edi
callq 0xa4f0
xorl %ebx, %ebx
jmp 0x10025