// File: /workspace/github_c_makefile_star2_O1/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, %ebp
cmpl $0x2, %edi
jl 0x1036d
movq %rsi, %rbx
movl %edi, %r14d
leal -0x1(%r14), %r12d
movslq %ebp, %r15
movq (%rbx,%r15,8), %r13
movq %r13, %rdi
leaq 0x25240(%rip), %rsi     # 0x35228
callq 0xa2d0
testl %eax, %eax
je 0x1017d
movq %r13, %rdi
leaq 0x2522c(%rip), %rsi     # 0x3522b
callq 0xa2d0
testl %eax, %eax
je 0x1019d
movq %r13, %rdi
leaq 0x25218(%rip), %rsi     # 0x3522e
callq 0xa2d0
testl %eax, %eax
je 0x101bd
movq %r13, %rdi
leaq 0x25204(%rip), %rsi     # 0x35231
callq 0xa2d0
testl %eax, %eax
je 0x101dd
movq %r13, %rdi
leaq 0x251f0(%rip), %rsi     # 0x35234
callq 0xa2d0
testl %eax, %eax
je 0x101fe
movq %r13, %rdi
leaq 0x251dc(%rip), %rsi     # 0x35237
callq 0xa2d0
testl %eax, %eax
je 0x1021e
movq %r13, %rdi
leaq 0x251c8(%rip), %rsi     # 0x3523a
callq 0xa2d0
testl %eax, %eax
je 0x1023f
movq %r13, %rdi
leaq 0x251b4(%rip), %rsi     # 0x3523d
callq 0xa2d0
testl %eax, %eax
je 0x10260
movq %r13, %rdi
leaq 0x251a0(%rip), %rsi     # 0x35240
callq 0xa2d0
testl %eax, %eax
je 0x10295
movq %r13, %rdi
leaq 0x2518c(%rip), %rsi     # 0x35243
callq 0xa2d0
testl %eax, %eax
je 0x102c0
movq %r13, %rdi
leaq 0x25178(%rip), %rsi     # 0x35246
callq 0xa2d0
testl %eax, %eax
je 0x102e7
movq %r13, %rdi
leaq 0x25164(%rip), %rsi     # 0x35249
callq 0xa2d0
testl %eax, %eax
je 0x102f3
movq %r13, %rdi
leaq 0x25153(%rip), %rsi     # 0x3524f
callq 0xa2d0
testl %eax, %eax
je 0x102ff
movq %r13, %rdi
leaq 0x2513f(%rip), %rsi     # 0x35252
callq 0xa2d0
testl %eax, %eax
je 0x1030b
movq %r13, %rdi
leaq 0x2512b(%rip), %rsi     # 0x35255
callq 0xa2d0
testl %eax, %eax
je 0x10317
movq %r13, %rdi
leaq 0x25119(%rip), %rsi     # 0x3525a
callq 0xa2d0
testl %eax, %eax
jne 0x1037e
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa4c0
movl %eax, 0x36307(%rip)     # 0x46470
movslq %eax, %rdi
callq 0x14ab3
movq %rax, 0x36300(%rip)     # 0x46478
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa4c0
movl %eax, 0x36270(%rip)     # 0x46408
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa4c0
movl %eax, 0x36258(%rip)     # 0x46410
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa4c0
movl %eax, 0x36254(%rip)     # 0x4642c
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa540
movq %rax, 0x361f7(%rip)     # 0x463f0
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa4c0
movl %eax, 0x361df(%rip)     # 0x463f8
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa540
movq %rax, 0x361c6(%rip)     # 0x46400
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa540
movq %rax, 0x3622d(%rip)     # 0x46488
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,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, 0x36190(%rip)     # 0x46420
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa4c0
cmpl $0x2, %eax
movl $0x1, %ecx
cmovll %ecx, %eax
movl %eax, 0x36175(%rip)     # 0x46430
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
movl $0x1, 0x36151(%rip)     # 0x46424
incl %ebp
movq 0x8(%rbx,%r15,8), %rdi
callq 0xa4c0
movl %eax, 0x36143(%rip)     # 0x46428
jmp 0x10362
movl $0x1, 0x3616f(%rip)     # 0x46460
jmp 0x10362
movl $0x1, 0x36167(%rip)     # 0x46464
jmp 0x10362
movl $0x1, 0x3615f(%rip)     # 0x46468
jmp 0x10362
movl $0x1, 0x36157(%rip)     # 0x4646c
jmp 0x10362
cmpl %r12d, %ebp
je 0x10398
leaq 0x24f35(%rip), %r13     # 0x35258
movq %r13, %rdi
callq 0x13f5a
movq %rax, 0x3614e(%rip)     # 0x46480
incl %ebp
movq 0x8(%rbx,%r15,8), %rsi
movq %rax, %rdi
callq 0x14835
movq %rax, 0x36138(%rip)     # 0x46480
movq %rax, %rdi
movq %r13, %rsi
callq 0x14835
movq %rax, 0x36126(%rip)     # 0x46480
movq %rax, %rdi
callq 0x1554b
incl %ebp
cmpl %r14d, %ebp
jl 0xffd7
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24edd(%rip), %rsi     # 0x35262
movq %r13, %rdi
callq 0xa2d0
testl %eax, %eax
je 0x103c1
cmpb $0x2d, (%r13)
jne 0x1036d
leaq 0x24eca(%rip), %rdi     # 0x35269
movq %r13, %rsi
xorl %eax, %eax
callq 0xa1b0
movl $0x1, %ebx
leaq 0x2519b(%rip), %rdi     # 0x35550
callq 0xa0d0
movl %ebx, %edi
callq 0xa4f0
xorl %ebx, %ebx
jmp 0x103ae