// File: /workspace/github_c_makefile_star2_O2/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
movq %rsi, %r14
movl %edi, %r15d
leal -0x1(%r15), %eax
movl %eax, 0x4(%rsp)
pushq $0x1
popq %rbx
cmpl %r15d, %ebx
jge 0xc1ac
movslq %ebx, %r12
movq (%r14,%r12,8), %r13
movb (%r13), %bpl
cmpb $0x2d, %bpl
jne 0xbf04
cmpb $0x63, 0x1(%r13)
jne 0xbe50
cmpb $0x0, 0x2(%r13)
je 0xbfad
cmpb $0x6e, 0x1(%r13)
jne 0xbe62
cmpb $0x0, 0x2(%r13)
je 0xbfce
cmpb $0x6b, 0x1(%r13)
jne 0xbe74
cmpb $0x0, 0x2(%r13)
je 0xbfef
cmpb $0x68, 0x1(%r13)
jne 0xbe86
cmpb $0x0, 0x2(%r13)
je 0xc010
cmpb $0x70, 0x1(%r13)
jne 0xbe98
cmpb $0x0, 0x2(%r13)
je 0xc032
cmpb $0x73, 0x1(%r13)
jne 0xbeaa
cmpb $0x0, 0x2(%r13)
je 0xc053
cmpb $0x61, 0x1(%r13)
jne 0xbebc
cmpb $0x0, 0x2(%r13)
je 0xc084
cmpb $0x64, 0x1(%r13)
jne 0xbece
cmpb $0x0, 0x2(%r13)
je 0xc0b5
cmpb $0x50, 0x1(%r13)
jne 0xbee0
cmpb $0x0, 0x2(%r13)
je 0xc13b
cmpb $0x72, 0x1(%r13)
jne 0xbef2
cmpb $0x0, 0x2(%r13)
je 0xc15e
cmpb $0x71, 0x1(%r13)
jne 0xbf04
cmpb $0x0, 0x2(%r13)
je 0xc182
movq %r13, %rdi
leaq 0x252c6(%rip), %rsi     # 0x311d4
callq 0xa2d0
testl %eax, %eax
je 0xbf9e
cmpb $0x2d, %bpl
jne 0xbf57
cmpb $0x6c, 0x1(%r13)
jne 0xbf33
cmpb $0x0, 0x2(%r13)
je 0xc075
cmpb $0x49, 0x1(%r13)
jne 0xbf45
cmpb $0x0, 0x2(%r13)
je 0xc0a6
cmpb $0x74, 0x1(%r13)
jne 0xbf57
cmpb $0x0, 0x2(%r13)
je 0xc0e9
movq %r13, %rdi
leaq 0x2527b(%rip), %rsi     # 0x311dc
callq 0xa2d0
testl %eax, %eax
jne 0xc193
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x374e6(%rip)     # 0x43470
movslq %eax, %rdi
callq 0xfe04
movq %rax, 0x374df(%rip)     # 0x43478
jmp 0xc18c
movl $0x1, 0x374bc(%rip)     # 0x43464
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x3743f(%rip)     # 0x43408
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x37426(%rip)     # 0x43410
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x37421(%rip)     # 0x4342c
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa540
movq %rax, 0x373c3(%rip)     # 0x433f0
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x373aa(%rip)     # 0x433f8
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa540
movq %rax, 0x37390(%rip)     # 0x43400
jmp 0xc18c
movl $0x1, 0x373e9(%rip)     # 0x43468
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa540
movq %rax, 0x373e7(%rip)     # 0x43488
jmp 0xc18c
movl $0x1, 0x373bc(%rip)     # 0x4346c
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovll %ecx, %eax
movl $0x40000000, %ecx       # imm = 0x40000000
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %eax, 0x3733c(%rip)     # 0x43420
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
leaq 0x250e0(%rip), %r13     # 0x311da
movq %r13, %rdi
callq 0xf62e
movq %rax, 0x37377(%rip)     # 0x43480
incl %ebx
movq 0x8(%r14,%r12,8), %rsi
movq %rax, %rdi
callq 0xfc8b
movq %rax, 0x37361(%rip)     # 0x43480
movq %rax, %rdi
movq %r13, %rsi
callq 0xfc8b
movq %rax, 0x3734f(%rip)     # 0x43480
movq %rax, %rdi
callq 0x10410
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovll %ecx, %eax
movl %eax, 0x372d4(%rip)     # 0x43430
jmp 0xc18c
cmpl 0x4(%rsp), %ebx
je 0xc1bd
movl $0x1, 0x372b6(%rip)     # 0x43424
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xa4c0
movl %eax, 0x372a8(%rip)     # 0x43428
jmp 0xc18c
movl $0x1, 0x372d4(%rip)     # 0x43460
incl %ebx
jmp 0xbe20
leaq 0x2504a(%rip), %rsi     # 0x311e4
movq %r13, %rdi
callq 0xa2d0
testl %eax, %eax
je 0xc1e4
cmpb $0x2d, %bpl
je 0xc1bd
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x25027(%rip), %rdi     # 0x311eb
movq %r13, %rsi
xorl %eax, %eax
callq 0xa1b0
pushq $0x1
popq %rbx
leaq 0x252fa(%rip), %rdi     # 0x314d2
callq 0xa0d0
movl %ebx, %edi
callq 0xa4f0
xorl %ebx, %ebx
jmp 0xc1d1