// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/src/redis-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]);
            if (config.randomkeys_keyspacelen < 0)
                config.randomkeys_keyspacelen = 0;
        } 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],"-e")) {
            config.showerrors = 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: redis-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 6379)\n"
" -s <socket>        Server socket (overrides host and port)\n"
" -a <password>      Password for Redis 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 SET/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 SET/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"
" -e                 If server replies with errors, show them on stdout.\n"
"                    (no more than 1 error per second is displayed)\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:6379:\n"
"   $ redis-benchmark\n\n"
" Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:\n"
"   $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20\n\n"
" Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:\n"
"   $ redis-benchmark -t set -n 1000000 -r 100000000\n\n"
" Benchmark 127.0.0.1:6379 for a few commands producing CSV output:\n"
"   $ redis-benchmark -t ping,set,get -n 100000 --csv\n\n"
" Benchmark a specific command line:\n"
"   $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call(\"ping\")' 0\n\n"
" Fill a list with 10000 random elements:\n"
"   $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__\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 0xd24a
movslq %ebx, %r12
movq (%r14,%r12,8), %r13
movb (%r13), %bpl
cmpb $0x2d, %bpl
jne 0xcf70
cmpb $0x63, 0x1(%r13)
jne 0xcebc
cmpb $0x0, 0x2(%r13)
je 0xd02b
cmpb $0x6e, 0x1(%r13)
jne 0xcece
cmpb $0x0, 0x2(%r13)
je 0xd04c
cmpb $0x6b, 0x1(%r13)
jne 0xcee0
cmpb $0x0, 0x2(%r13)
je 0xd06d
cmpb $0x68, 0x1(%r13)
jne 0xcef2
cmpb $0x0, 0x2(%r13)
je 0xd08e
cmpb $0x70, 0x1(%r13)
jne 0xcf04
cmpb $0x0, 0x2(%r13)
je 0xd0b0
cmpb $0x73, 0x1(%r13)
jne 0xcf16
cmpb $0x0, 0x2(%r13)
je 0xd0d1
cmpb $0x61, 0x1(%r13)
jne 0xcf28
cmpb $0x0, 0x2(%r13)
je 0xd102
cmpb $0x64, 0x1(%r13)
jne 0xcf3a
cmpb $0x0, 0x2(%r13)
je 0xd133
cmpb $0x50, 0x1(%r13)
jne 0xcf4c
cmpb $0x0, 0x2(%r13)
je 0xd176
cmpb $0x72, 0x1(%r13)
jne 0xcf5e
cmpb $0x0, 0x2(%r13)
je 0xd1f2
cmpb $0x71, 0x1(%r13)
jne 0xcf70
cmpb $0x0, 0x2(%r13)
je 0xd220
movq %r13, %rdi
leaq 0x2726a(%rip), %rsi     # 0x341e4
callq 0xb2e0
testl %eax, %eax
je 0xd01c
cmpb $0x2d, %bpl
jne 0xcfd5
cmpb $0x6c, 0x1(%r13)
jne 0xcf9f
cmpb $0x0, 0x2(%r13)
je 0xd0f3
cmpb $0x49, 0x1(%r13)
jne 0xcfb1
cmpb $0x0, 0x2(%r13)
je 0xd124
cmpb $0x65, 0x1(%r13)
jne 0xcfc3
cmpb $0x0, 0x2(%r13)
je 0xd167
cmpb $0x74, 0x1(%r13)
jne 0xcfd5
cmpb $0x0, 0x2(%r13)
je 0xd1a0
movq %r13, %rdi
leaq 0x2720d(%rip), %rsi     # 0x341ec
callq 0xb2e0
testl %eax, %eax
jne 0xd231
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
movl %eax, 0x3b4b8(%rip)     # 0x484c0
movslq %eax, %rdi
callq 0x11254
movq %rax, 0x3b4b1(%rip)     # 0x484c8
jmp 0xd22a
movl $0x1, 0x3b48e(%rip)     # 0x484b4
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
movl %eax, 0x3b411(%rip)     # 0x48458
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
movl %eax, 0x3b3f8(%rip)     # 0x48460
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
movl %eax, 0x3b3f3(%rip)     # 0x4847c
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb550
movq %rax, 0x3b395(%rip)     # 0x48440
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
movl %eax, 0x3b37c(%rip)     # 0x48448
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb550
movq %rax, 0x3b362(%rip)     # 0x48450
jmp 0xd22a
movl $0x1, 0x3b3bb(%rip)     # 0x484b8
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb550
movq %rax, 0x3b3b9(%rip)     # 0x484d8
jmp 0xd22a
movl $0x1, 0x3b38e(%rip)     # 0x484bc
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovll %ecx, %eax
movl $0x40000000, %ecx       # imm = 0x40000000
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %eax, 0x3b30e(%rip)     # 0x48470
jmp 0xd22a
movl $0x1, 0x3b313(%rip)     # 0x48484
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovll %ecx, %eax
movl %eax, 0x3b2e5(%rip)     # 0x48480
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
leaq 0x27039(%rip), %r13     # 0x341ea
movq %r13, %rdi
callq 0x10a7e
movq %rax, 0x3b310(%rip)     # 0x484d0
incl %ebx
movq 0x8(%r14,%r12,8), %rsi
movq %rax, %rdi
callq 0x110db
movq %rax, 0x3b2fa(%rip)     # 0x484d0
movq %rax, %rdi
movq %r13, %rsi
callq 0x110db
movq %rax, 0x3b2e8(%rip)     # 0x484d0
movq %rax, %rdi
callq 0x11860
jmp 0xd22a
cmpl 0x4(%rsp), %ebx
je 0xd25b
movl $0x1, 0x3b272(%rip)     # 0x48474
incl %ebx
movq 0x8(%r14,%r12,8), %rdi
callq 0xb4d0
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movl %eax, 0x3b25a(%rip)     # 0x48478
jmp 0xd22a
movl $0x1, 0x3b286(%rip)     # 0x484b0
incl %ebx
jmp 0xce8c
leaq 0x26fbc(%rip), %rsi     # 0x341f4
movq %r13, %rdi
callq 0xb2e0
testl %eax, %eax
je 0xd282
cmpb $0x2d, %bpl
je 0xd25b
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x26f99(%rip), %rdi     # 0x341fb
movq %r13, %rsi
xorl %eax, %eax
callq 0xb1c0
pushq $0x1
popq %rbx
leaq 0x2747a(%rip), %rdi     # 0x346f0
callq 0xb0d0
movl %ebx, %edi
callq 0xb500
xorl %ebx, %ebx
jmp 0xd26f