// File: /workspace/github_c_makefile_star2_O0/adsr[P]phpspy/phpspy.c
// Function: parse_opts
static void parse_opts(int argc, char **argv) {
    int c;
    size_t i;
    struct option long_opts[] = {
        { "help",                  no_argument,       NULL, 'h' },
        { "pid",                   required_argument, NULL, 'p' },
        { "pgrep",                 required_argument, NULL, 'P' },
        { "threads",               required_argument, NULL, 'T' },
        { "sleep-ns",              required_argument, NULL, 's' },
        { "rate-hz",               required_argument, NULL, 'H' },
        { "php-version",           required_argument, NULL, 'V' },
        { "limit",                 required_argument, NULL, 'l' },
        { "time-limit-ms",         required_argument, NULL, 'i' },
        { "max-depth",             required_argument, NULL, 'n' },
        { "request-info",          required_argument, NULL, 'r' },
        { "memory-usage",          no_argument,       NULL, 'm' },
        { "output",                required_argument, NULL, 'o' },
        { "child-stdout",          required_argument, NULL, 'O' },
        { "child-stderr",          required_argument, NULL, 'E' },
        { "addr-executor-globals", required_argument, NULL, 'x' },
        { "addr-sapi-globals",     required_argument, NULL, 'a' },
        { "single-line",           no_argument,       NULL, '1' },
        { "buffer-size",           required_argument, NULL, 'b' },
        { "filter",                required_argument, NULL, 'f' },
        { "filter-negate",         required_argument, NULL, 'F' },
        { "verbose-fields",        required_argument, NULL, 'd' },
        { "continue-on-error",     no_argument,       NULL, 'c' },
        { "event-handler",         required_argument, NULL, 'j' },
        { "event-handler-opts",    required_argument, NULL, 'J' },
        { "comment",               required_argument, NULL, '#' },
        { "nothing",               no_argument,       NULL, '@' },
        { "version",               no_argument,       NULL, 'v' },
        { "pause-process",         no_argument,       NULL, 'S' },
        { "peek-var",              required_argument, NULL, 'e' },
        { "peek-global",           required_argument, NULL, 'g' },
        { "top",                   no_argument,       NULL, 't' },
        { "libname-awk-patt",      required_argument, NULL, 'w' },
        { 0,                       0,                 0,    0   }
    };
    /* Parse options until the first non-option argument is reached. Effectively
     * this makes the end-of-options-delimiter (`--`) optional. The following
     * invocations are equivalent:
     *   phpspy --rate-hz=2 php -r 'sleep(1);'
     *   phpspy --rate-hz=2 -- php -r 'sleep(1);'
     */
    optind = 1;
    while (
        optind < argc
        && argv[optind][0] == '-'
        && (c = getopt_long(argc, argv, "hp:P:T:te:s:H:V:l:i:n:r:mo:O:E:x:a:1b:f:F:d:cj:J:#:@vSe:g:tw:", long_opts, NULL)) != -1
    ) {
        switch (c) {
            case 'h': usage(stdout, 0); break;
            case 'p': opt_pid = atoi_with_min_or_exit("-p", optarg, 1); break;
            case 'P': opt_pgrep_args = optarg; break;
            case 'T': opt_num_workers = atoi_with_min_or_exit("-T", optarg, 1); break;
            case 's': opt_sleep_ns = strtol_with_min_or_exit("-s", optarg, 1); break;
            case 'H': opt_sleep_ns = (1000000000UL / strtol_with_min_or_exit("-H", optarg, 1)); break;
            case 'V': opt_phpv = optarg; break;
            case 'l': opt_trace_limit = strtoull(optarg, NULL, 10); break;
            case 'i': opt_time_limit_ms = strtol_with_min_or_exit("-i", optarg, 0); break;
            case 'n': opt_max_stack_depth = atoi_with_min_or_exit("-n", optarg, -1); break;
            case 'r':
                for (i = 0; i < strlen(optarg); i++) {
                    switch (optarg[i]) {
                        case 'q': opt_capture_req_qstring = 1; break;
                        case 'c': opt_capture_req_cookie  = 1; break;
                        case 'u': opt_capture_req_uri     = 1; break;
                        case 'p': opt_capture_req_path    = 1; break;
                        case 'Q': opt_capture_req_qstring = 0; break;
                        case 'C': opt_capture_req_cookie  = 0; break;
                        case 'U': opt_capture_req_uri     = 0; break;
                        case 'P': opt_capture_req_path    = 0; break;
                    }
                }
                opt_capture_req = opt_capture_req_qstring | opt_capture_req_cookie | opt_capture_req_uri | opt_capture_req_path;
                break;
            case 'm': opt_capture_mem = 1; break;
            case 'o': opt_path_output = optarg; break;
            case 'O': opt_path_child_out = optarg; break;
            case 'E': opt_path_child_err = optarg; break;
            case 'x': opt_executor_globals_addr = strtoull(optarg, NULL, 16); break;
            case 'a': opt_sapi_globals_addr = strtoull(optarg, NULL, 16); break;
            case '1': opt_frame_delim = '\t'; opt_trace_delim = '\n'; break;
            case 'b': opt_fout_buffer_size = atoi_with_min_or_exit("-b", optarg, 1); break;
            case 'f':
            case 'F':
                if (opt_filter_re) {
                    regfree(opt_filter_re);
                }
                if (regcomp(&filter_re, optarg, REG_EXTENDED | REG_NOSUB | REG_NEWLINE) == 0) {
                    opt_filter_re = &filter_re;
                } else {
                    log_error("parse_opts: Failed to compile filter regex\n\n"); /* TODO regerror */
                    usage(stderr, 1);
                }
                opt_filter_negate = c == 'F' ? 1 : 0;
                break;
            case 'd':
                for (i = 0; i < strlen(optarg); i++) {
                    switch (optarg[i]) {
                        case 'p': opt_verbose_fields_pid = 1; break;
                        case 't': opt_verbose_fields_ts  = 1; break;
                        case 'P': opt_verbose_fields_pid = 0; break;
                        case 'T': opt_verbose_fields_ts  = 0; break;
                    }
                }
                break;
            case 'c': opt_continue_on_error = 1; break;
            case 'j':
                if (strcmp(optarg, "fout") == 0) {
                    opt_event_handler = event_handler_fout;
                } else if (strcmp(optarg, "callgrind") == 0) {
                    opt_event_handler = event_handler_callgrind;
                } else {
                    log_error("parse_opts: Expected 'fout' or 'callgrind' for `--event-handler`\n\n");
                    usage(stderr, 1);
                }
                break;
            case 'J': opt_event_handler_opts = optarg; break;
            case '#': break;
            case '@': break;
            case 'v':
                printf(
                    "phpspy v%s USE_ZEND=%s COMMIT=%s\n",
                    PHPSPY_VERSION,
                    #ifdef USE_ZEND
                    "y"
                    #else
                    "n"
                    #endif
                    ,
                    #ifdef COMMIT
                    STR2(COMMIT)
                    #else
                    "-"
                    #endif
                );
                exit(0);
            case 'S': opt_pause = 1; break;
            case 'e': varpeek_add(optarg); break;
            case 'g': glopeek_add(optarg); break;
            case 't': opt_top_mode = 1; break;
            case 'w': opt_libname_awk_patt = optarg; break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x460(%rbp), %rdi
leaq 0x30920(%rip), %rsi     # 0x39990
movl $0x440, %edx            # imm = 0x440
callq 0x6360
movq 0x30f47(%rip), %rax     # 0x39fc8
movl $0x1, (%rax)
movq 0x30f3a(%rip), %rax     # 0x39fc8
movl (%rax), %ecx
xorl %eax, %eax
cmpl -0x4(%rbp), %ecx
movb %al, -0x461(%rbp)
jge 0x90ed
movq -0x10(%rbp), %rax
movq 0x30f20(%rip), %rcx     # 0x39fc8
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2d, %ecx
movb %al, -0x461(%rbp)
jne 0x90ed
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x460(%rbp), %rcx
leaq 0x2b907(%rip), %rdx     # 0x349db
xorl %eax, %eax
movl %eax, %r8d
callq 0x6170
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
setne %al
movb %al, -0x461(%rbp)
movb -0x461(%rbp), %al
testb $0x1, %al
jne 0x90fc
jmp 0x96aa
movl -0x14(%rbp), %eax
addl $-0x23, %eax
movl %eax, %ecx
movq %rcx, -0x470(%rbp)
subl $0x55, %eax
ja 0x96a5
movq -0x470(%rbp), %rax
leaq 0x28f5a(%rip), %rcx     # 0x3207c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30e8e(%rip), %rax     # 0x39fc0
movq (%rax), %rdi
xorl %esi, %esi
callq 0x9d70
jmp 0x96a5
movq 0x30e88(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x2b8c7(%rip), %rdi     # 0x34a19
movl $0x1, %edx
callq 0xe5e0
movl %eax, 0x311be(%rip)     # 0x3a320
jmp 0x96a5
movq 0x30e62(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq %rax, 0x33358(%rip)     # 0x3c4d0
jmp 0x96a5
movq 0x30e4c(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x2b88e(%rip), %rdi     # 0x34a1c
movl $0x1, %edx
callq 0xe5e0
movl %eax, 0x31186(%rip)     # 0x3a324
jmp 0x96a5
movq 0x30e26(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x2b86b(%rip), %rdi     # 0x34a1f
movl $0x1, %edx
callq 0xe650
movq %rax, 0x31163(%rip)     # 0x3a328
jmp 0x96a5
movq 0x30dff(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x2b847(%rip), %rdi     # 0x34a22
movl $0x1, %edx
callq 0xe650
movq %rax, %rcx
movl $0x3b9aca00, %eax       # imm = 0x3B9ACA00
xorl %edx, %edx
divq %rcx
movq %rax, 0x3112f(%rip)     # 0x3a328
jmp 0x96a5
movq 0x30dcb(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq %rax, 0x31141(%rip)     # 0x3a350
jmp 0x96a5
movq 0x30db5(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x62e0
movq %rax, 0x332d5(%rip)     # 0x3c508
jmp 0x96a5
movq 0x30d91(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x2b7dc(%rip), %rdi     # 0x34a25
xorl %edx, %edx
callq 0xe650
movq %rax, 0x332b9(%rip)     # 0x3c510
jmp 0x96a5
movq 0x30d6d(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x2b7bb(%rip), %rdi     # 0x34a28
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xe5e0
movl %eax, 0x310b3(%rip)     # 0x3a330
jmp 0x96a5
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x478(%rbp)
movq 0x30d34(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
callq 0x6160
movq %rax, %rcx
movq -0x478(%rbp), %rax
cmpq %rcx, %rax
jae 0x9362
movq 0x30d12(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $-0x43, %eax
movl %eax, %ecx
movq %rcx, -0x480(%rbp)
subl $0x32, %eax
ja 0x934f
movq -0x480(%rbp), %rax
leaq 0x28f80(%rip), %rcx     # 0x32268
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x331f9(%rip)     # 0x3c4f4
jmp 0x934f
movl $0x1, 0x331f1(%rip)     # 0x3c4f8
jmp 0x934f
movl $0x1, 0x331e9(%rip)     # 0x3c4fc
jmp 0x934f
movl $0x1, 0x331e1(%rip)     # 0x3c500
jmp 0x934f
movl $0x0, 0x331c9(%rip)     # 0x3c4f4
jmp 0x934f
movl $0x0, 0x331c1(%rip)     # 0x3c4f8
jmp 0x934f
movl $0x0, 0x331b9(%rip)     # 0x3c4fc
jmp 0x934f
movl $0x0, 0x331b1(%rip)     # 0x3c500
jmp 0x9351
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x928a
movl 0x3318c(%rip), %eax     # 0x3c4f4
orl 0x3318a(%rip), %eax     # 0x3c4f8
orl 0x33188(%rip), %eax     # 0x3c4fc
orl 0x33186(%rip), %eax     # 0x3c500
movl %eax, 0x33170(%rip)     # 0x3c4f0
jmp 0x96a5
movl $0x1, 0x33175(%rip)     # 0x3c504
jmp 0x96a5
movq 0x30c35(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq %rax, 0x30f93(%rip)     # 0x3a338
jmp 0x96a5
movq 0x30c1f(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq %rax, 0x30f85(%rip)     # 0x3a340
jmp 0x96a5
movq 0x30c09(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq %rax, 0x30f77(%rip)     # 0x3a348
jmp 0x96a5
movq 0x30bf3(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x62e0
movq %rax, 0x330eb(%rip)     # 0x3c4e0
jmp 0x96a5
movq 0x30bcf(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x62e0
movq %rax, 0x330cf(%rip)     # 0x3c4e8
jmp 0x96a5
movb $0x9, 0x30f0f(%rip)     # 0x3a334
movb $0xa, 0x30f09(%rip)     # 0x3a335
jmp 0x96a5
movq 0x30b98(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x2b5e9(%rip), %rdi     # 0x34a2b
movl $0x1, %edx
callq 0xe5e0
movl %eax, 0x30f0e(%rip)     # 0x3a360
jmp 0x96a5
cmpq $0x0, 0x330c1(%rip)     # 0x3c520
je 0x946d
movq 0x330b8(%rip), %rdi     # 0x3c520
callq 0x6150
movq 0x30b5c(%rip), %rax     # 0x39fd0
movq (%rax), %rsi
leaq 0x330f2(%rip), %rdi     # 0x3c570
movl $0xd, %edx
callq 0x6280
cmpl $0x0, %eax
jne 0x949d
leaq 0x330dc(%rip), %rax     # 0x3c570
movq %rax, 0x33085(%rip)     # 0x3c520
jmp 0x94bf
leaq 0x2b58a(%rip), %rdi     # 0x34a2e
movb $0x0, %al
callq 0x9cc0
movq 0x30b3e(%rip), %rax     # 0x39ff0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x9d70
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x46, %edx
cmovel %ecx, %eax
movl %eax, 0x33053(%rip)     # 0x3c528
jmp 0x96a5
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x488(%rbp)
movq 0x30adc(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
callq 0x6160
movq %rax, %rcx
movq -0x488(%rbp), %rax
cmpq %rcx, %rax
jae 0x9586
movq 0x30abe(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $-0x50, %eax
movl %eax, %ecx
movq %rcx, -0x490(%rbp)
subl $0x24, %eax
ja 0x9573
movq -0x490(%rbp), %rax
leaq 0x28c98(%rip), %rcx     # 0x321d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x32fdd(%rip)     # 0x3c52c
jmp 0x9573
movl $0x1, 0x32fd5(%rip)     # 0x3c530
jmp 0x9573
movl $0x0, 0x32fc5(%rip)     # 0x3c52c
jmp 0x9573
movl $0x0, 0x32fbd(%rip)     # 0x3c530
jmp 0x9575
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x94e2
jmp 0x96a5
movl $0x1, 0x32fab(%rip)     # 0x3c540
jmp 0x96a5
movq 0x30a2f(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
leaq 0x2b4b0(%rip), %rsi     # 0x34a5b
callq 0x6310
cmpl $0x0, %eax
jne 0x95c5
leaq 0x23844(%rip), %rax     # 0x2ce00
movq %rax, 0x30d95(%rip)     # 0x3a358
jmp 0x9614
movq 0x30a04(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
leaq 0x2b48a(%rip), %rsi     # 0x34a60
callq 0x6310
cmpl $0x0, %eax
jne 0x95f0
leaq 0x245e9(%rip), %rax     # 0x2dbd0
movq %rax, 0x30d6a(%rip)     # 0x3a358
jmp 0x9612
leaq 0x2b473(%rip), %rdi     # 0x34a6a
movb $0x0, %al
callq 0x9cc0
movq 0x309eb(%rip), %rax     # 0x39ff0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x9d70
jmp 0x9614
jmp 0x96a5
movq 0x309b0(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq %rax, 0x32f0e(%rip)     # 0x3c538
jmp 0x96a5
jmp 0x96a5
jmp 0x96a5
leaq 0x2b476(%rip), %rdi     # 0x34aad
leaq 0x2b491(%rip), %rsi     # 0x34acf
leaq 0x2b3e4(%rip), %rdx     # 0x34a29
leaq 0x2b489(%rip), %rcx     # 0x34ad5
movb $0x0, %al
callq 0x61a0
xorl %edi, %edi
callq 0x6580
movl $0x1, 0x32eb4(%rip)     # 0x3c518
jmp 0x96a5
movq 0x30963(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
callq 0xe710
jmp 0x96a5
movq 0x30952(%rip), %rax     # 0x39fd0
movq (%rax), %rdi
callq 0x10bb0
jmp 0x96a5
movl $0x1, 0x32e46(%rip)     # 0x3c4d8
jmp 0x96a5
movq 0x30935(%rip), %rax     # 0x39fd0
movq (%rax), %rax
movq %rax, 0x30cc3(%rip)     # 0x3a368
jmp 0x9087
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
nopw %cs:(%rax,%rax)