// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo.c
// Function: main
int main(int argc, char **argv)
{
    struct dubbo_async_args async_args;
    memset(&async_args, 0, sizeof(async_args));
    async_args.req_n = 0;
    async_args.pipe_n = 0;
    async_args.verbos = false;

    struct dubbo_args args;
    memset(&args, 0, sizeof(args));
    args.attach = "{}";
    args.timeout.tv_sec = 3;
    args.timeout.tv_usec = 0;

    int opt = 0;
    opt = getopt(argc, argv, optString);
    optarg = trim_opt(optarg);
    while (opt != -1)
    {
        switch (opt)
        {
        case 'h':
            args.host = optarg;
            break;
        case 'p':
            args.port = optarg;
            break;
        case 'm':
        {
            char *c = strrchr(optarg, '.');
            ASSERT_OPT(c, "Invalid method %s", optarg);
            *c = 0;
            args.service = optarg;
            args.method = c + 1;
        }
        break;
        case 'a':
            args.args = optarg;
            break;
        case 'e':
            args.attach = optarg;
            break;
        case 't':
            args.timeout.tv_sec = atoi(optarg);
            break;
        case 'c':
            async_args.pipe_n = atoi(optarg);
            break;
        case 'n':
            async_args.req_n = atoi(optarg);
            break;
        case 'v':
            async_args.verbos = true;
            break;
        case '?':
            usage();
            break;
        default:
            break;
        }
        opt = getopt(argc, argv, optString);
        optarg = trim_opt(optarg);
    }

    ASSERT_OPT(args.host, "Missing Host -h=${host}");
    ASSERT_OPT(args.port, "Missing Port -p=${port}");
    ASSERT_OPT(args.service, "Missing Service -m=${service}.${method}");
    ASSERT_OPT(args.method, "Missing Method -m=${service}.${method}");
    ASSERT_OPT(args.args, "Missing Arguments -a'${jsonargs}'");
    ASSERT_OPT(args.timeout.tv_sec > 0, "Timeout must be positive");

    cJSON *json_args = cJSON_Parse(args.args);
    ASSERT_OPT(json_args && (cJSON_IsObject(json_args) || cJSON_IsArray(json_args)), "Invalid Arguments JSON Format : %s", args.args);
    cJSON_Delete(json_args);

    cJSON *json_attach = cJSON_Parse(args.attach);
    ASSERT_OPT(json_attach && cJSON_IsObject(json_attach), "Invalid Attach JSON Format as %s", args.attach);
    cJSON_Delete(json_attach);

    // fprintf(stderr, "Invoking dubbo://%s:%s/%s.%s?args=%s&attach=%s\n", args.host, args.port, args.service, args.method, args.args, args.attach);

    if (async_args.req_n > 0 && async_args.pipe_n > 0)
    {
        async_args.el = aeCreateEventLoop(1024);
        if (dubbo_bench_async(&args, &async_args))
        {
            aeMain(async_args.el);
            aeDeleteEventLoop(async_args.el);
            return 0;
        }
        else
        {
            aeDeleteEventLoop(async_args.el);
            return 1;
        }
    }
    else
    {
        return dubbo_invoke_sync(&args) ? 0 : 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2190
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movb $0x0, -0x18(%rbp)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2190
leaq 0x2c5e(%rip), %rax      # 0x10be0
movq %rax, -0x40(%rbp)
movq $0x3, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0x7275(%rip), %rdx      # 0x15220
callq 0x2310
movl %eax, -0x6c(%rbp)
movq 0x700e(%rip), %rax      # 0x14fc8
movq (%rax), %rdi
callq 0xe350
movq %rax, %rcx
movq 0x6ffc(%rip), %rax      # 0x14fc8
movq %rcx, (%rax)
cmpl $-0x1, -0x6c(%rbp)
je 0xe13c
movl -0x6c(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
subl $0x37, %eax
ja 0xe103
movq -0x90(%rbp), %rax
leaq 0x2b01(%rip), %rcx      # 0x10b00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x6fb9(%rip), %rax      # 0x14fc8
movq (%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0xe105
movq 0x6fa6(%rip), %rax      # 0x14fc8
movq (%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0xe105
movq 0x6f93(%rip), %rax      # 0x14fc8
movq (%rax), %rdi
movl $0x2e, %esi
callq 0x2150
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0xe074
movq 0x6fa4(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movq 0x6f6a(%rip), %rax      # 0x14fc8
movq (%rax), %rdx
leaq 0x2b7b(%rip), %rsi      # 0x10be3
movb $0x0, %al
callq 0x2220
callq 0xe460
movq -0x78(%rbp), %rax
movb $0x0, (%rax)
movq 0x6f46(%rip), %rax      # 0x14fc8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xe105
movq 0x6f2a(%rip), %rax      # 0x14fc8
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xe105
movq 0x6f1a(%rip), %rax      # 0x14fc8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xe105
movq 0x6f0a(%rip), %rax      # 0x14fc8
movq (%rax), %rdi
callq 0x2330
cltq
movq %rax, -0x38(%rbp)
jmp 0xe105
movq 0x6ef3(%rip), %rax      # 0x14fc8
movq (%rax), %rdi
callq 0x2330
movl %eax, -0x20(%rbp)
jmp 0xe105
movq 0x6edf(%rip), %rax      # 0x14fc8
movq (%rax), %rdi
callq 0x2330
movl %eax, -0x1c(%rbp)
jmp 0xe105
movb $0x1, -0x18(%rbp)
jmp 0xe105
callq 0xe460
jmp 0xe105
jmp 0xe105
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0x710d(%rip), %rdx      # 0x15220
callq 0x2310
movl %eax, -0x6c(%rbp)
movq 0x6ea6(%rip), %rax      # 0x14fc8
movq (%rax), %rdi
callq 0xe350
movq %rax, %rcx
movq 0x6e94(%rip), %rax      # 0x14fc8
movq %rcx, (%rax)
jmp 0xdfcf
cmpq $0x0, -0x68(%rbp)
jne 0xe160
movq 0x6eae(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x2aad(%rip), %rsi      # 0x10c01
movb $0x0, %al
callq 0x2220
callq 0xe460
cmpq $0x0, -0x60(%rbp)
jne 0xe184
movq 0x6e8a(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x2aad(%rip), %rsi      # 0x10c25
movb $0x0, %al
callq 0x2220
callq 0xe460
cmpq $0x0, -0x58(%rbp)
jne 0xe1a8
movq 0x6e66(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x2aad(%rip), %rsi      # 0x10c49
movb $0x0, %al
callq 0x2220
callq 0xe460
cmpq $0x0, -0x50(%rbp)
jne 0xe1cc
movq 0x6e42(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x2abd(%rip), %rsi      # 0x10c7d
movb $0x0, %al
callq 0x2220
callq 0xe460
cmpq $0x0, -0x48(%rbp)
jne 0xe1f0
movq 0x6e1e(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x2acc(%rip), %rsi      # 0x10cb0
movb $0x0, %al
callq 0x2220
callq 0xe460
cmpq $0x0, -0x38(%rbp)
jg 0xe214
movq 0x6dfa(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x2ad6(%rip), %rsi      # 0x10cde
movb $0x0, %al
callq 0x2220
callq 0xe460
movq -0x48(%rbp), %rdi
callq 0x4210
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0xe244
movq -0x80(%rbp), %rdi
callq 0x60d0
cmpl $0x0, %eax
jne 0xe265
movq -0x80(%rbp), %rdi
callq 0x6090
cmpl $0x0, %eax
jne 0xe265
movq 0x6dad(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
leaq 0x2aaa(%rip), %rsi      # 0x10d03
movb $0x0, %al
callq 0x2220
callq 0xe460
movq -0x80(%rbp), %rdi
callq 0x3b30
movq -0x40(%rbp), %rdi
callq 0x4210
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0xe299
movq -0x88(%rbp), %rdi
callq 0x60d0
cmpl $0x0, %eax
jne 0xe2ba
movq 0x6d58(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
leaq 0x2a84(%rip), %rsi      # 0x10d32
movb $0x0, %al
callq 0x2220
callq 0xe460
movq -0x88(%rbp), %rdi
callq 0x3b30
cmpl $0x0, -0x1c(%rbp)
jle 0xe320
cmpl $0x0, -0x20(%rbp)
jle 0xe320
movl $0x400, %edi            # imm = 0x400
callq 0x2500
movq %rax, -0x28(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xcf00
testb $0x1, %al
jne 0xe2f3
jmp 0xe30e
movq -0x28(%rbp), %rdi
callq 0x3680
movq -0x28(%rbp), %rdi
callq 0x2880
movl $0x0, -0x4(%rbp)
jmp 0xe33b
movq -0x28(%rbp), %rdi
callq 0x2880
movl $0x1, -0x4(%rbp)
jmp 0xe33b
leaq -0x68(%rbp), %rdi
callq 0xd1c0
movb %al, %dl
movl $0x1, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)