// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x1c(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0xd81b
movl -0x14(%rbp), %eax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6eeda(%rip), %rsi     # 0x7c1bc
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd31b
cmpl $0x0, -0x18(%rbp)
je 0xd2f7
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x810e2(%rip)     # 0x8e3f8
jmp 0xd80b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ee91(%rip), %rsi     # 0x7c1bf
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd367
cmpl $0x0, -0x18(%rbp)
je 0xd343
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x8109e(%rip)     # 0x8e400
jmp 0xd809
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ee48(%rip), %rsi     # 0x7c1c2
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd3b3
cmpl $0x0, -0x18(%rbp)
je 0xd38f
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x8106e(%rip)     # 0x8e41c
jmp 0xd807
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6edff(%rip), %rsi     # 0x7c1c5
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd400
cmpl $0x0, -0x18(%rbp)
je 0xd3db
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa520
movq %rax, 0x80fe5(%rip)     # 0x8e3e0
jmp 0xd805
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6edb5(%rip), %rsi     # 0x7c1c8
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd44c
cmpl $0x0, -0x18(%rbp)
je 0xd428
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x80fa1(%rip)     # 0x8e3e8
jmp 0xd803
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ed6c(%rip), %rsi     # 0x7c1cb
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd499
cmpl $0x0, -0x18(%rbp)
je 0xd474
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa520
movq %rax, 0x80f5c(%rip)     # 0x8e3f0
jmp 0xd801
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ed22(%rip), %rsi     # 0x7c1ce
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd4e6
cmpl $0x0, -0x18(%rbp)
je 0xd4c1
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa520
movq %rax, 0x80f97(%rip)     # 0x8e478
jmp 0xd7ff
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ecd8(%rip), %rsi     # 0x7c1d1
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd55b
cmpl $0x0, -0x18(%rbp)
je 0xd50e
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x80ee3(%rip)     # 0x8e410
cmpl $0x1, 0x80edc(%rip)     # 0x8e410
jge 0xd540
movl $0x1, 0x80ed0(%rip)     # 0x8e410
cmpl $0x40000000, 0x80ec6(%rip) # imm = 0x40000000
jle 0xd556
movl $0x40000000, 0x80eba(%rip) # imm = 0x40000000
jmp 0xd7fd
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ec66(%rip), %rsi     # 0x7c1d4
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd5ba
cmpl $0x0, -0x18(%rbp)
je 0xd583
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x80e7e(%rip)     # 0x8e420
cmpl $0x0, 0x80e77(%rip)     # 0x8e420
jg 0xd5b5
movl $0x1, 0x80e6b(%rip)     # 0x8e420
jmp 0xd7fb
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ec0a(%rip), %rsi     # 0x7c1d7
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd610
cmpl $0x0, -0x18(%rbp)
je 0xd5e2
jmp 0xd823
movl $0x1, 0x80e28(%rip)     # 0x8e414
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x80e0d(%rip)     # 0x8e418
jmp 0xd7f9
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ebb7(%rip), %rsi     # 0x7c1da
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd63c
movl $0x1, 0x80e19(%rip)     # 0x8e450
jmp 0xd7f7
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6eb8e(%rip), %rsi     # 0x7c1dd
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd668
movl $0x1, 0x80df1(%rip)     # 0x8e454
jmp 0xd7f5
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6eb68(%rip), %rsi     # 0x7c1e3
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd694
movl $0x1, 0x80dc9(%rip)     # 0x8e458
jmp 0xd7f3
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6eb3f(%rip), %rsi     # 0x7c1e6
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd6c0
movl $0x1, 0x80da1(%rip)     # 0x8e45c
jmp 0xd7f1
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6eb16(%rip), %rsi     # 0x7c1e9
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd74d
cmpl $0x0, -0x18(%rbp)
je 0xd6e8
jmp 0xd823
leaq 0x6eafd(%rip), %rdi     # 0x7c1ec
callq 0x13ad0
movq %rax, 0x80d75(%rip)     # 0x8e470
movq 0x80d6e(%rip), %rdi     # 0x8e470
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x14690
movq %rax, 0x80d4e(%rip)     # 0x8e470
movq 0x80d47(%rip), %rdi     # 0x8e470
leaq 0x6eabc(%rip), %rsi     # 0x7c1ec
callq 0x14690
movq %rax, 0x80d34(%rip)     # 0x8e470
movq 0x80d2d(%rip), %rdi     # 0x8e470
callq 0x154b0
jmp 0xd7ef
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ea8e(%rip), %rsi     # 0x7c1ee
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd7a9
cmpl $0x0, -0x18(%rbp)
je 0xd775
jmp 0xd823
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa4a0
movl %eax, 0x80ccc(%rip)     # 0x8e460
movslq 0x80cc5(%rip), %rdi     # 0x8e460
callq 0x149b0
movq %rax, 0x80cc1(%rip)     # 0x8e468
jmp 0xd7ed
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6ea3a(%rip), %rsi     # 0x7c1f6
callq 0xa2a0
cmpl $0x0, %eax
jne 0xd7cf
movl $0x0, -0x1c(%rbp)
jmp 0xd83d
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xd7e5
jmp 0xd823
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd853
jmp 0xd7ef
jmp 0xd7f1
jmp 0xd7f3
jmp 0xd7f5
jmp 0xd7f7
jmp 0xd7f9
jmp 0xd7fb
jmp 0xd7fd
jmp 0xd7ff
jmp 0xd801
jmp 0xd803
jmp 0xd805
jmp 0xd807
jmp 0xd809
jmp 0xd80b
jmp 0xd80d
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xd2ad
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd853
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x6e9c7(%rip), %rdi     # 0x7c1fd
movb $0x0, %al
callq 0xa190
leaq 0x6e9ea(%rip), %rdi     # 0x7c22e
movb $0x0, %al
callq 0xa190
movl -0x1c(%rbp), %edi
callq 0xa4e0
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)