LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/sa.c
// Function: sa_toip
void sa_toip(union sockaddr_all *u, char *buf, int size)
{
    // 使用 static变量做成不需要buf与size参数的函数?
    // static __thread char buf[INET6_ADDRSTRLEN];
    assert(size >= INET6_ADDRSTRLEN);
    if (u->s.sa_family == AF_INET)
    {
        inet_ntop(AF_INET, &(u->v4.sin_addr), buf, INET_ADDRSTRLEN);
    }
    else if (u->s.sa_family == AF_INET6)
    {
        inet_ntop(AF_INET6, &(u->v6.sin6_addr), buf, INET6_ADDRSTRLEN);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpl $0x2e, -0x14(%rbp)
jl 0xa8bb
jmp 0xa8da
leaq 0x527b(%rip), %rdi      # 0xfb3d
leaq 0x528d(%rip), %rsi      # 0xfb56
movl $0x43, %edx
leaq 0x5286(%rip), %rcx      # 0xfb5b
callq 0x2170
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x2, %eax
jne 0xa903
movq -0x8(%rbp), %rsi
addq $0x4, %rsi
movq -0x10(%rbp), %rdx
movl $0x2, %edi
movl $0x10, %ecx
callq 0x2030
jmp 0xa92c
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
cmpl $0xa, %eax
jne 0xa92a
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rdx
movl $0xa, %edi
movl $0x2e, %ecx
callq 0x2030
jmp 0xa92c
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/sa.c
// Function: sa_toipport
void sa_toipport(union sockaddr_all *u, char *buf, int size)
{
    assert(size >= INET6_ADDRSTRLEN);
    sa_toip(u, buf, size);
    size_t end = strlen(buf);
    uint16_t port = ntohs(u->v4.sin_port);
    assert(size > end);
    snprintf(buf + end, size - end, ":%u", port);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpl $0x2e, -0x14(%rbp)
jl 0xa95b
jmp 0xa97a
leaq 0x51db(%rip), %rdi      # 0xfb3d
leaq 0x51ed(%rip), %rsi      # 0xfb56
movl $0x50, %edx
leaq 0x5216(%rip), %rcx      # 0xfb8b
callq 0x2170
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xa8a0
movq -0x10(%rbp), %rdi
callq 0x20e0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x22a0
movw %ax, -0x22(%rbp)
movslq -0x14(%rbp), %rax
cmpq -0x20(%rbp), %rax
jbe 0xa9b4
jmp 0xa9d3
leaq 0x5204(%rip), %rdi      # 0xfbbf
leaq 0x5194(%rip), %rsi      # 0xfb56
movl $0x54, %edx
leaq 0x51bd(%rip), %rcx      # 0xfb8b
callq 0x2170
movq -0x10(%rbp), %rdi
addq -0x20(%rbp), %rdi
movslq -0x14(%rbp), %rsi
subq -0x20(%rbp), %rsi
movzwl -0x22(%rbp), %ecx
leaq 0x51dc(%rip), %rdx      # 0xfbca
movb $0x0, %al
callq 0x2130
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/sa.c
// Function: sa_resolve
bool sa_resolve(char *hostname, union sockaddr_all *u)
{
    assert(u);
    struct addrinfo hints;
    struct addrinfo *res;
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = PF_INET;
    hints.ai_socktype = SOCK_STREAM;

    int status = getaddrinfo(hostname, NULL, &hints, &res);
    if (status != 0)
    {
        fprintf(stderr, "ERROR getaddrinfo: %s\n", gai_strerror(status));
        return false;
    }

    // FIXME 遍历检测可用??
    // 只获取链表第一个元素 struct addrinfo *p; for(p = res; p != NULL; p = p->ai_next) { }
    if (res == NULL)
    {
        freeaddrinfo(res);
        false;
    }

    u->v4.sin_family = res->ai_family;
    u->v4.sin_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr;
    #ifdef __APPLE__ 
    u->v4.sin_len = res->ai_addrlen;
    #endif
    freeaddrinfo(res);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xaaa9
jmp 0xaac8
leaq 0x511c(%rip), %rdi      # 0xfbcc
leaq 0x509f(%rip), %rsi      # 0xfb56
movl $0x6a, %edx
leaq 0x514e(%rip), %rcx      # 0xfc11
callq 0x2170
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2190
movl $0x2, -0x44(%rbp)
movl $0x1, -0x40(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x2380
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0xab35
movq 0xa4ed(%rip), %rax      # 0x14ff8
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x54(%rbp), %edi
callq 0x2140
movq -0x60(%rbp), %rdi
movq %rax, %rdx
leaq 0x4f45(%rip), %rsi      # 0xfa6d
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xab75
cmpq $0x0, -0x50(%rbp)
jne 0xab45
movq -0x50(%rbp), %rdi
callq 0x23d0
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x18(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
movq -0x50(%rbp), %rdi
callq 0x23d0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: utf8len
size_t utf8len(const char *s, size_t sz)
{
    size_t len = 0;
    size_t i = 0;
    for (; i < sz; i++)
    {
        if ((*s & 0xC0) != 0x80)
        {
            ++len;
        }
    }
    return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xae75
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0xae65
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xae67
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xae3c
movq -0x18(%rbp), %rax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: utf8cpy
int utf8cpy(uint8_t *dst, const uint8_t *src, size_t sz)
{
    int i = 0;
    uint8_t c;

    while (sz--)
    {
        c = src[i];
        if (c <= 0x80)
        {
            i += 1;
        }
        else if ((c & 0xE0) == 0xC0)
        {
            i += 2;
        }
        else if ((c & 0xF0) == 0xE0)
        {
            i += 3;
        }
        else if ((c & 0xF8) == 0xF0)
        {
            i += 4;
        }
        else
        {
            // invalid utf8
            return -1;
        }
    }

    if (i)
    {
        memcpy(dst, src, i);
    }

    return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x20(%rbp)
cmpq $0x0, %rax
je 0xaf3d
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x25(%rbp)
movzbl -0x25(%rbp), %eax
cmpl $0x80, %eax
jg 0xaed8
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xaf38
movzbl -0x25(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0xaef3
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x24(%rbp)
jmp 0xaf36
movzbl -0x25(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0xaf0e
movl -0x24(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x24(%rbp)
jmp 0xaf34
movzbl -0x25(%rbp), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0xaf29
movl -0x24(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x24(%rbp)
jmp 0xaf32
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaf5a
jmp 0xaf34
jmp 0xaf36
jmp 0xaf38
jmp 0xae9b
cmpl $0x0, -0x24(%rbp)
je 0xaf54
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x2240
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: hs_encode_int
int hs_encode_int(int32_t val, uint8_t *out)
{
    if (-0x10 <= val && val <= 0x2f)
    {
        out[0] = val + 0x90;
        return 1;
    }
    else if (-0x800 <= val + 0xc8 && val <= 0x7ff)
    {
        out[1] = val & 0xff;
        out[0] = (val >> 8) + 0xc8;
        return 2;
    }
    else if (-0x40000 <= val && val <= 0x3ffff)
    {
        out[0] = (val >> 16) + 0xd4;
        *(uint16_t *)(out + 1) = htobe16(val & 0xffff);
        return 3;
    }
    else
    {
        out[0] = 'I';
        *(int32_t *)(out + 1) = htobe32(val);
        return 5;
    }
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xfffffff0, %eax       # imm = 0xFFFFFFF0
cmpl -0x8(%rbp), %eax
jg 0xaffb
cmpl $0x2f, -0x8(%rbp)
jg 0xaffb
movl -0x8(%rbp), %eax
addl $0x90, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0xb0ac
movl -0x8(%rbp), %ecx
addl $0xc8, %ecx
movl $0xfffff800, %eax       # imm = 0xFFFFF800
cmpl %ecx, %eax
jg 0xb043
cmpl $0x7ff, -0x8(%rbp)      # imm = 0x7FF
jg 0xb043
movl -0x8(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x8(%rbp), %eax
sarl $0x8, %eax
addl $0xc8, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0xb0ac
movl $0xfffc0000, %eax       # imm = 0xFFFC0000
cmpl -0x8(%rbp), %eax
jg 0xb08d
cmpl $0x3ffff, -0x8(%rbp)    # imm = 0x3FFFF
jg 0xb08d
movl -0x8(%rbp), %eax
sarl $0x10, %eax
addl $0xd4, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movl -0x8(%rbp), %eax
andl $0xffff, %eax           # imm = 0xFFFF
movzwl %ax, %edi
callq 0xb0c0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x1(%rax)
movl $0x3, -0x4(%rbp)
jmp 0xb0ac
movq -0x10(%rbp), %rax
movb $0x49, (%rax)
movl -0x8(%rbp), %edi
callq 0xb0f0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1(%rax)
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: hs_decode_int
bool hs_decode_int(const uint8_t *buf, size_t sz, int32_t *out)
{
    bool r = true;
    uint8_t code = buf[0];
    if (sz >= 1 && code >= 0x80 && code <= 0xbf)
    {
        *out = code - 0x90;
    }
    else if (sz >= 2 && code >= 0xc0 && code <= 0xcf)
    {
        *out = ((code - 0xc8) << 8) + buf[1];
    }
    else if (sz >= 3 && code >= 0xd0 && code <= 0xd7)
    {
        *out = ((code - 0xd4) << 16) + (buf[1] << 8) + buf[2];
    }
    else if (sz >= 5 && code == 'I')
    {
        *out = be32toh(*(uint32_t *)&buf[1]);
    }
    else
    {
        r = false;
    }
    return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x1, -0x19(%rbp)
movq -0x8(%rbp), %rax
movb (%rax), %al
movb %al, -0x1a(%rbp)
cmpq $0x1, -0x10(%rbp)
jb 0xb183
movzbl -0x1a(%rbp), %eax
cmpl $0x80, %eax
jl 0xb183
movzbl -0x1a(%rbp), %eax
cmpl $0xbf, %eax
jg 0xb183
movzbl -0x1a(%rbp), %ecx
subl $0x90, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xb238
cmpq $0x2, -0x10(%rbp)
jb 0xb1bf
movzbl -0x1a(%rbp), %eax
cmpl $0xc0, %eax
jl 0xb1bf
movzbl -0x1a(%rbp), %eax
cmpl $0xcf, %eax
jg 0xb1bf
movzbl -0x1a(%rbp), %ecx
subl $0xc8, %ecx
shll $0x8, %ecx
movq -0x8(%rbp), %rax
movzbl 0x1(%rax), %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xb236
cmpq $0x3, -0x10(%rbp)
jb 0xb208
movzbl -0x1a(%rbp), %eax
cmpl $0xd0, %eax
jl 0xb208
movzbl -0x1a(%rbp), %eax
cmpl $0xd7, %eax
jg 0xb208
movzbl -0x1a(%rbp), %ecx
subl $0xd4, %ecx
shll $0x10, %ecx
movq -0x8(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x8, %eax
addl %eax, %ecx
movq -0x8(%rbp), %rax
movzbl 0x2(%rax), %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xb234
cmpq $0x5, -0x10(%rbp)
jb 0xb22e
movzbl -0x1a(%rbp), %eax
cmpl $0x49, %eax
jne 0xb22e
movq -0x8(%rbp), %rax
movl 0x1(%rax), %edi
callq 0xb0f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xb232
movb $0x0, -0x19(%rbp)
jmp 0xb234
jmp 0xb236
jmp 0xb238
movb -0x19(%rbp), %al
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: hs_encode_string
int hs_encode_string(const char *str, uint8_t *out)
{
    size_t index = 0;
    int length = strlen(str);

    // TODO
    if (length > 0x8000)
    {
        return -1;
    }

    if (length <= 31)
    {
        out[index++] = (uint8_t)(length);
    }
    else if (length <= 1023)
    {
        out[index++] = (uint8_t)(48 + (length >> 8));
        // Integer overflow and wrapping assumed
        out[index++] = (uint8_t)(length);
    }
    else
    {
        out[index++] = 'S';
        out[index++] = (uint8_t)((length >> 8));
        // Integer overflow and wrapping assumed
        out[index++] = (uint8_t)(length);
    }

    memcpy(out + index, str, length);
    return index + length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20e0
movl %eax, -0x24(%rbp)
cmpl $0x8000, -0x24(%rbp)    # imm = 0x8000
jle 0xb289
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb36b
cmpl $0x1f, -0x24(%rbp)
jg 0xb2af
movl -0x24(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x20(%rbp)
movb %dl, (%rax,%rcx)
jmp 0xb348
cmpl $0x3ff, -0x24(%rbp)     # imm = 0x3FF
jg 0xb2f6
movl -0x24(%rbp), %eax
sarl $0x8, %eax
addl $0x30, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x20(%rbp)
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x20(%rbp)
movb %dl, (%rax,%rcx)
jmp 0xb346
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb $0x53, (%rax,%rcx)
movl -0x24(%rbp), %eax
sarl $0x8, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x20(%rbp)
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x20(%rbp)
movb %dl, (%rax,%rcx)
jmp 0xb348
movq -0x18(%rbp), %rdi
addq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x2240
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
addq %rcx, %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: hs_decode_string
bool hs_decode_string(const uint8_t *buf, size_t sz, char **out, size_t *out_sz)
{
    short is_last_chunk = 0;
    size_t out_length = 0;
    uint8_t *out_str = (uint8_t *)malloc(sz);
    if (NULL == out_str)
    {
        return false;
    }

    if (internal_decode_string(buf, sz, out_str, &out_length, &is_last_chunk))
    {
        uint8_t *new_out = (uint8_t *)realloc(out_str, out_length);
        if (NULL != new_out)
        {
            out_str = new_out;
        }
        *out = (char *)out_str;
        *out_sz = out_length;
        return true;
    }
    else
    {
        free(out_str);
        return false;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movw $0x0, -0x2a(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x23f8
movq %rax, -0x40(%rbp)
xorl %eax, %eax
cmpq -0x40(%rbp), %rax
jne 0xb3c1
movb $0x0, -0x1(%rbp)
jmp 0xb42a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x2a(%rbp), %r8
callq 0xb440
testb $0x1, %al
jne 0xb3e0
jmp 0xb41d
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2400
movq %rax, -0x48(%rbp)
xorl %eax, %eax
cmpq -0x48(%rbp), %rax
je 0xb401
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0xb42a
movq -0x40(%rbp), %rdi
callq 0x23f0
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: hs_encode_binary
void hs_encode_binary(const char *bin, size_t sz, struct buffer *out_buf)
{
    // 不做判断, 最后一块体积填0 ?!
    // int just_right = sz % chunk_max == 0;
    while (sz > BIN_CHUNK_MAX)
    {
        buf_appendInt8(out_buf, 'b');
        buf_appendInt16(out_buf, (uint16_t)BIN_CHUNK_MAX);
        buf_append(out_buf, bin, BIN_CHUNK_MAX);
        bin += BIN_CHUNK_MAX;
        sz -= BIN_CHUNK_MAX;
    }
    buf_appendInt8(out_buf, 'B');
    buf_appendInt16(out_buf, sz);
    if (sz)
    {
        buf_append(out_buf, bin, sz);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x10000, -0x10(%rbp)   # imm = 0x10000
jbe 0xb777
movq -0x18(%rbp), %rdi
movl $0x62, %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x8e90
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl $0x10000, %edx          # imm = 0x10000
callq 0x8aa0
movq -0x8(%rbp), %rax
addq $0x10000, %rax          # imm = 0x10000
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rax
subq $0x10000, %rax          # imm = 0x10000
movq %rax, -0x10(%rbp)
jmp 0xb724
movq -0x18(%rbp), %rdi
movl $0x42, %esi
callq 0x8f00
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movswl %ax, %esi
callq 0x8e90
cmpq $0x0, -0x10(%rbp)
je 0xb7ad
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x8aa0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_hessian.c
// Function: hs_decode_binary_chunk
static bool hs_decode_binary_chunk(struct buffer *buf, char **out, size_t *out_sz, size_t *left)
{
    int sz = buf_readInt16(buf);
    if (*left < sz)
    {
        char *new_out = realloc(*out, *out_sz + BIN_CHUNK_MAX + 1);
        if (new_out == NULL)
        {
            return false;
        }
        *out = new_out;
        *left = BIN_CHUNK_MAX;
    }

    memcpy(*out + *out_sz, buf_peek(buf), sz);
    *out_sz += sz;
    *left -= sz;
    buf_retrieve(buf, sz);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9580
cwtl
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
cmpq %rcx, %rax
jae 0xba5a
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
addq $0x10000, %rsi          # imm = 0x10000
addq $0x1, %rsi
callq 0x2400
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xba44
movb $0x0, -0x1(%rbp)
jmp 0xbab5
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq $0x10000, (%rax)        # imm = 0x10000
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
addq (%rcx), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x83b0
movq -0x40(%rbp), %rdi
movq %rax, %rsi
movslq -0x2c(%rbp), %rdx
callq 0x2240
movslq -0x2c(%rbp), %rcx
movq -0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movslq -0x2c(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x86f0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: dubbo_res_release
void dubbo_res_release(struct dubbo_res *res)
{
    if (res->desc)
    {
        free(res->desc);
    }
    if (res->data)
    {
        free(res->data);
    }
    if (res->attach)
    {
        free(res->attach);
    }
    free(res);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xbae4
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x23f0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xbafc
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x23f0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0xbb14
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x23f0
movq -0x8(%rbp), %rdi
callq 0x23f0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: dubbo_req_create
struct dubbo_req *dubbo_req_create(const char *service, const char *method, const char *json_args, const char *json_attach)
{
    struct dubbo_req *req = calloc(1, sizeof(*req));
    assert(req);
    req->reqid = next_reqid();
    req->is_twoway = true;
    req->is_evt = false;
    req->service = strdup(service);
    req->method = strdup(method);

    char *args = rebuild_json_args(json_args);
    if (args == NULL)
    {
        LOG_ERROR("invalid json args %s", json_args);
        return NULL;
    }

    req->argc = DUBBO_GENERIC_METHOD_ARGC;
    req->argv = calloc(3, sizeof(void *));
    assert(req->argv);
    req->argv[DUBBO_GENERIC_METHOD_ARGV_METHOD_IDX] = strdup(method);
    req->argv[DUBBO_GENERIC_METHOD_ARGV_TYPES_IDX] = NULL;
    req->argv[DUBBO_GENERIC_METHOD_ARGV_ARGS_IDX] = args;

    // fixme 要处理成 hessian map
    if (json_attach)
    {
        req->attach = strdup(json_attach);
    }

    return req;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x1, %edi
movl $0x48, %esi
callq 0x21f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xbb64
jmp 0xbb83
leaq 0x4cfd(%rip), %rdi      # 0x10868
leaq 0x43c2(%rip), %rsi      # 0xff34
movl $0x17f, %edx            # imm = 0x17F
leaq 0x43c4(%rip), %rcx      # 0xff42
callq 0x2170
callq 0xc530
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x9(%rax)
movq -0x10(%rbp), %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rdi
callq 0xbcd0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xbc1b
movq 0x9413(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x43aa(%rip), %rsi      # 0xff9d
leaq 0x43e1(%rip), %rcx      # 0xffdb
leaq 0x4333(%rip), %r8       # 0xff34
movl $0x189, %r9d            # imm = 0x189
movb $0x0, %al
callq 0x2220
movq $0x0, -0x8(%rbp)
jmp 0xbcc6
movq -0x30(%rbp), %rax
movl $0x3, 0x28(%rax)
movl $0x3, %edi
movl $0x8, %esi
callq 0x21f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xbc4d
jmp 0xbc6c
leaq 0x4398(%rip), %rdi      # 0xffec
leaq 0x42d9(%rip), %rsi      # 0xff34
movl $0x18f, %edx            # imm = 0x18F
leaq 0x42db(%rip), %rcx      # 0xff42
callq 0x2170
movq -0x18(%rbp), %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq $0x0, 0x8(%rax)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, 0x10(%rax)
cmpq $0x0, -0x28(%rbp)
je 0xbcbe
movq -0x28(%rbp), %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: rebuild_json_args
static char *rebuild_json_args(const char *json_str)
{
    cJSON *root = cJSON_Parse(json_str);
    if (root == NULL)
    {
        return NULL;
    }
    if (!cJSON_IsArray(root) && !cJSON_IsObject(root))
    {
        cJSON_Delete(root);
        return NULL;
    }

    cJSON *arr = cJSON_CreateArray();
    cJSON *el;
    cJSON_ArrayForEach(el, root)
    {
        cJSON_AddItemToArray(arr, cJSON_Duplicate(el, true));
    }
    cJSON_Delete(root);

    // fixme 消除内存 copy
    char *utf8_json = cJSON_PrintUnformatted(arr);
    char *ascii_s = utf82ascii(utf8_json);
    free(utf8_json);
    return ascii_s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4210
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xbcfd
movq $0x0, -0x8(%rbp)
jmp 0xbdc7
movq -0x18(%rbp), %rdi
callq 0x6090
cmpl $0x0, %eax
jne 0xbd2f
movq -0x18(%rbp), %rdi
callq 0x60d0
cmpl $0x0, %eax
jne 0xbd2f
movq -0x18(%rbp), %rdi
callq 0x3b30
movq $0x0, -0x8(%rbp)
jmp 0xbdc7
callq 0x55d0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xbd4d
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xbd55
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0xbd55
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xbd93
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5a60
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x4aa0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xbd5d
movq -0x18(%rbp), %rdi
callq 0x3b30
movq -0x20(%rbp), %rdi
callq 0x4400
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xab80
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x23f0
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: dubbo_req_release
void dubbo_req_release(struct dubbo_req *req)
{
    free(req->argv[DUBBO_GENERIC_METHOD_ARGV_METHOD_IDX]);
    // free(req->argv[DUBBO_GENERIC_METHOD_ARGV_TYPES_IDX]);
    free(req->argv[DUBBO_GENERIC_METHOD_ARGV_ARGS_IDX]);
    free(req->argv);
    if (req->attach)
    {
        free(req->attach);
    }
    free(req);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rdi
callq 0x23f0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rdi
callq 0x23f0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x23f0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xbe32
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x23f0
movq -0x8(%rbp), %rdi
callq 0x23f0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: dubbo_encode
struct buffer *dubbo_encode(const struct dubbo_req *req)
{
    struct buffer *buf = buf_create_ex(DUBBO_BUF_LEN, DUBBO_HDR_LEN);
    if (encode_req(buf, req))
    {
        return buf;
    }
    else
    {
        buf_release(buf);
        return NULL;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x2000, %edi           # imm = 0x2000
movl $0x10, %esi
callq 0x8140
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xbed0
testb $0x1, %al
jne 0xbea2
jmp 0xbeac
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xbebd
movq -0x18(%rbp), %rdi
callq 0x8270
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: encode_req
static bool encode_req(struct buffer *buf, const struct dubbo_req *req)
{
    struct dubbo_hdr hdr;
    memset(&hdr, 0, sizeof(hdr));

    hdr.reqid = req->reqid;
    hdr.status = 0;
    hdr.flag = (int8_t)DUBBO_FLAG_REQ | (int8_t)DUBBO_HESSIAN2_SERI_ID;
    if (req->is_twoway)
    {
        hdr.flag |= DUBBO_FLAG_TWOWAY;
    }
    if (req->is_evt)
    {
        hdr.flag |= DUBBO_FLAG_EVT;
    }

    if (req->is_evt)
    {
        buf_append(buf, req->data, req->data_sz);
    }
    else
    {
        if (!encode_req_data(buf, req))
        {
            LOG_ERROR("failed to encode req data");
            return false;
        }
    }
    hdr.body_sz = buf_readable(buf);

    if (!encode_req_hdr(buf, &hdr))
    {
        LOG_ERROR("failed to encode req hdr");
        return false;
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2190
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movb $0x0, -0x27(%rbp)
movb $-0x7e, -0x28(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x8(%rax)
je 0xbf17
movsbl -0x28(%rbp), %eax
orl $0x40, %eax
movb %al, -0x28(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x9(%rax)
je 0xbf2b
movsbl -0x28(%rbp), %eax
orl $0x20, %eax
movb %al, -0x28(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x9(%rax)
je 0xbf50
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdx
callq 0x8aa0
jmp 0xbf95
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xc570
testb $0x1, %al
jne 0xbf93
movq 0x9090(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x4169(%rip), %rsi      # 0x100db
leaq 0x41a5(%rip), %rdx      # 0x1011e
leaq 0x3fb4(%rip), %rcx      # 0xff34
movl $0x14d, %r8d            # imm = 0x14D
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xbfe8
jmp 0xbf95
movq -0x10(%rbp), %rdi
callq 0x8330
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xc770
testb $0x1, %al
jne 0xbfe4
movq 0x903f(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x4166(%rip), %rsi      # 0x10129
leaq 0x4154(%rip), %rdx      # 0x1011e
leaq 0x3f63(%rip), %rcx      # 0xff34
movl $0x155, %r8d            # imm = 0x155
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xbfe8
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: dubbo_decode
struct dubbo_res *dubbo_decode(struct buffer *buf)
{
    struct dubbo_hdr hdr;
    memset(&hdr, 0, sizeof(hdr));

    if (!decode_res_hdr(buf, &hdr))
    {
        LOG_ERROR("failed to decode dubbo response");
        return NULL;
    }

    // 读取所有 body+attach
    // struct buffer *body_buf = buf_create(hdr.body_sz);
    // buf_append(body_buf, buf_peek(buf), hdr.body_sz);

    struct buffer *body_buf = buf_readonlyView(buf, hdr.body_sz);
    buf_retrieve(buf, hdr.body_sz);

    struct dubbo_res *res = calloc(1, sizeof(*res));
    assert(res);
    res->type = -1;
    res->reqid = hdr.reqid;

    bool ok = decode_res(body_buf, &hdr, res);
    buf_release(body_buf);

    if (ok)
    {
        return res;
    }
    else
    {
        free(res);
        return NULL;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2190
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xc120
testb $0x1, %al
jne 0xc066
movq 0x8fc4(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x3fb8(%rip), %rsi      # 0xfff6
leaq 0x3ffa(%rip), %rdx      # 0x1003f
leaq 0x3ee8(%rip), %rcx      # 0xff34
movl $0x1c4, %r8d            # imm = 0x1C4
movb $0x0, %al
callq 0x2220
movq $0x0, -0x8(%rbp)
jmp 0xc114
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x9ae0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x86f0
movl $0x1, %edi
movl $0x38, %esi
callq 0x21f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xc09f
jmp 0xc0be
leaq 0x4259(%rip), %rdi      # 0x102ff
leaq 0x3e87(%rip), %rsi      # 0xff34
movl $0x1d0, %edx            # imm = 0x1D0
leaq 0x3f93(%rip), %rcx      # 0x1004c
callq 0x2170
movq -0x30(%rbp), %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq -0x20(%rbp), %rsi
callq 0xc280
andb $0x1, %al
movb %al, -0x31(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8270
testb $0x1, -0x31(%rbp)
je 0xc103
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xc114
movq -0x30(%rbp), %rdi
callq 0x23f0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: decode_res_hdr
static bool decode_res_hdr(struct buffer *buf, struct dubbo_hdr *hdr)
{
    if (!is_dubbo_pkt(buf))
    {
        return false;
    }

    buf_readInt16(buf); // magic
    hdr->flag = buf_readInt8(buf);
    hdr->status = buf_readInt8(buf);
    hdr->reqid = buf_readInt64(buf);
    hdr->body_sz = buf_readInt32(buf);

    if (hdr->body_sz > DUBBO_MAX_PKT_SZ)
    {
        LOG_ERROR("too big dubbo pkt body size: %d", hdr->body_sz);
        return false;
    }

    int8_t seria_id = hdr->flag & DUBBO_SERI_MASK;
    if (seria_id != DUBBO_HESSIAN2_SERI_ID)
    {
        LOG_ERROR("unsupport dubbo serialization id %d", seria_id);
        return false;
    }

    if ((hdr->flag & DUBBO_FLAG_REQ) == 0)
    {
        // decode response
        return true;
    }
    else
    {
        // decode request
        LOG_ERROR("unsupport decode dubbo request packet");
        return false;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0xc3d0
testb $0x1, %al
jne 0xc146
movb $0x0, -0x1(%rbp)
jmp 0xc274
movq -0x10(%rbp), %rdi
callq 0x9580
movq -0x10(%rbp), %rdi
callq 0x95b0
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rdi
callq 0x95b0
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x10(%rbp), %rdi
callq 0x9520
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
callq 0x9550
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
cmpl $0x400000, 0x4(%rax)    # imm = 0x400000
jle 0xc1e1
movq 0x8e4c(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0x3fff(%rip), %rsi      # 0x101bc
leaq 0x4041(%rip), %rcx      # 0x10205
leaq 0x3d69(%rip), %r8       # 0xff34
movl $0xbf, %r9d
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xc274
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
andl $0x1f, %eax
movb %al, -0x19(%rbp)
movsbl -0x19(%rbp), %eax
cmpl $0x2, %eax
je 0xc22d
movq 0x8dfa(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movsbl -0x19(%rbp), %edx
leaq 0x4008(%rip), %rsi      # 0x10214
leaq 0x3ff2(%rip), %rcx      # 0x10205
leaq 0x3d1a(%rip), %r8       # 0xff34
movl $0xc6, %r9d
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xc274
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0xc244
movb $0x1, -0x1(%rbp)
jmp 0xc274
movq 0x8dad(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x400c(%rip), %rsi      # 0x10261
leaq 0x3fa9(%rip), %rdx      # 0x10205
leaq 0x3cd1(%rip), %rcx      # 0xff34
movl $0xd2, %r8d
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: decode_res
static bool decode_res(struct buffer *buf, const struct dubbo_hdr *hdr, struct dubbo_res *res)
{
    res->is_evt = hdr->flag & DUBBO_FLAG_EVT;
    res->desc = strdup(get_res_status_desc(hdr->status));

    if (hdr->status == DUBBO_RES_T_OK)
    {
        res->ok = true;
        if (res->is_evt)
        {
            // decode evt
        }
        else
        {
            if (!decode_res_data(buf, hdr, res))
            {
                LOG_ERROR("failed to decode response data");
                return false;
            }
        }
    }
    else
    {
        res->ok = false;
        read_hs_str(buf, &res->data, &res->data_sz);
    }

    // fixme read attach

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
setne %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x8(%rax)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %edi
callq 0xc800
movq %rax, %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x14, %eax
jne 0xc340
movq -0x20(%rbp), %rax
movb $0x1, 0x9(%rax)
movq -0x20(%rbp), %rax
testb $0x1, 0x8(%rax)
je 0xc2ef
jmp 0xc33b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xc8c0
testb $0x1, %al
jne 0xc339
movq 0x8ced(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x3f9b(%rip), %rsi      # 0x102b0
leaq 0x3fdc(%rip), %rdx      # 0x102f8
leaq 0x3c11(%rip), %rcx      # 0xff34
movl $0x16c, %r8d            # imm = 0x16C
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xc3c5
jmp 0xc33b
jmp 0xc3c1
movq -0x20(%rbp), %rax
movb $0x0, 0x9(%rax)
movq -0x10(%rbp), %rdi
callq 0x83b0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8330
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movq -0x20(%rbp), %rdx
addq $0x18, %rdx
movq -0x20(%rbp), %rcx
addq $0x20, %rcx
callq 0xb380
testb $0x1, %al
jne 0xc3b0
movq 0x8c73(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x3f74(%rip), %rsi      # 0x10303
leaq 0x3f62(%rip), %rdx      # 0x102f8
leaq 0x3b97(%rip), %rcx      # 0xff34
movl $0x174, %r8d            # imm = 0x174
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xc3c5
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x86f0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: is_completed_dubbo_pkt
bool is_completed_dubbo_pkt(const struct buffer *buf, int *remaining)
{
    if (!is_dubbo_pkt(buf))
    {
        return false;
    }

    int32_t body_sz = 0;
    memcpy(&body_sz, buf_peek(buf) + DUBBO_HDR_LEN - sizeof(int32_t), sizeof(int32_t));
    body_sz = be32toh(body_sz);
    if (body_sz <= 0 || body_sz > DUBBO_MAX_PKT_SZ)
    {
        LOG_ERROR("invalid dubbo pkt body size %d", body_sz);
        return false;
    }

    if (remaining)
    {
        *remaining = body_sz + DUBBO_HDR_LEN - buf_readable(buf);
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0xc3d0
testb $0x1, %al
jne 0xc446
movb $0x0, -0x1(%rbp)
jmp 0xc4dd
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x83b0
movl 0xc(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %edi
callq 0xc4f0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jle 0xc476
cmpl $0x400000, -0x1c(%rbp)  # imm = 0x400000
jle 0xc4ab
movq 0x8b7b(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
leaq 0x3bf2(%rip), %rsi      # 0x1007c
leaq 0x3c33(%rip), %rcx      # 0x100c4
leaq 0x3a9c(%rip), %r8       # 0xff34
movl $0x1f4, %r9d            # imm = 0x1F4
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xc4dd
cmpq $0x0, -0x18(%rbp)
je 0xc4d9
movl -0x1c(%rbp), %eax
addl $0x10, %eax
cltq
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8330
movq %rax, %rcx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: encode_req_hdr
static bool encode_req_hdr(struct buffer *buf, const struct dubbo_hdr *hdr)
{
    if (buf_prependable(buf) < DUBBO_HDR_LEN)
    {
        return false;
    }

    buf_prependInt32(buf, hdr->body_sz);
    buf_prependInt64(buf, hdr->reqid);
    buf_prependInt8(buf, hdr->status);
    buf_prependInt8(buf, hdr->flag);
    buf_prependInt16(buf, DUBBO_MAGIC); // fixme
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8390
cmpq $0x10, %rax
jae 0xc795
movb $0x0, -0x1(%rbp)
jmp 0xc7e9
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x9070
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x9030
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %esi
callq 0x90f0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x90f0
movq -0x10(%rbp), %rdi
movl $0xffffdabb, %esi       # imm = 0xFFFFDABB
callq 0x90b0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: get_res_status_desc
static char *get_res_status_desc(int8_t status)
{
    switch (status)
    {
    case DUBBO_RES_T_OK:
        return "OK";
    case DUBBO_RES_T_CLIENT_TIMEOUT:
        return "CLIENT TIMEOUT";
    case DUBBO_RES_T_SERVER_TIMEOUT:
        return "SERVER TIMEOUT";
    case DUBBO_RES_T_BAD_REQUEST:
        return "BAD REQUEST";
    case DUBBO_RES_T_BAD_RESPONSE:
        return "BAD RESPONSE";
    case DUBBO_RES_T_SERVICE_NOT_FOUND:
        return "SERVICE NOT FOUND";
    case DUBBO_RES_T_SERVICE_ERROR:
        return "SERVICE ERROR";
    case DUBBO_RES_T_SERVER_ERROR:
        return "SERVER ERROR";
    case DUBBO_RES_T_CLIENT_ERROR:
        return "CLIENT ERROR";
    default:
        return "UNKNOWN";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %dil, %al
movb %al, -0x9(%rbp)
movsbl -0x9(%rbp), %eax
addl $-0x14, %eax
movl %eax, %ecx
movq %rcx, -0x18(%rbp)
subl $0x46, %eax
ja 0xc8a9
movq -0x18(%rbp), %rax
leaq 0x35ed(%rip), %rcx      # 0xfe18
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x3b11(%rip), %rax      # 0x1034c
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b07(%rip), %rax      # 0x1034f
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b09(%rip), %rax      # 0x1035e
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b0b(%rip), %rax      # 0x1036d
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b0a(%rip), %rax      # 0x10379
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b0a(%rip), %rax      # 0x10386
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b0f(%rip), %rax      # 0x10398
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b10(%rip), %rax      # 0x103a6
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b10(%rip), %rax      # 0x103b3
movq %rax, -0x8(%rbp)
jmp 0xc8b4
leaq 0x3b10(%rip), %rax      # 0x103c0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_codec.c
// Function: decode_res_data
static bool decode_res_data(struct buffer *buf, const struct dubbo_hdr *hdr, struct dubbo_res *res)
{
    uint8_t flag = buf_readInt8(buf);
    // hessian2 小整数
    if (flag < 0x80 || flag > 0xbf)
    {
        LOG_ERROR("invalid response type %d (raw)", flag);
        return false;
    }
    flag -= 0x90;

    switch (flag)
    {
    case DUBBO_RES_NULL:
        break;
    case DUBBO_RES_EX:
        read_hs_str(buf, &res->data, &res->data_sz);
        break;
    case DUBBO_RES_VAL:
#ifdef DUBBO_BYTE_CODEC
        hs_decode_binary(buf, &res->data, &res->data_sz);
#else
        read_hs_str(buf, &res->data, &res->data_sz);
#endif
        break;
    default:
        LOG_ERROR("unknown result flag, expect '0' '1' '2', get %d", res->type);
        return false;
    }

    res->type = flag;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x95b0
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x80, %eax
jl 0xc8f6
movzbl -0x21(%rbp), %eax
cmpl $0xbf, %eax
jle 0xc92f
movq 0x86fb(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movzbl -0x21(%rbp), %edx
leaq 0x3abd(%rip), %rsi      # 0x103c8
leaq 0x3afe(%rip), %rcx      # 0x10410
leaq 0x361b(%rip), %r8       # 0xff34
movl $0x107, %r9d            # imm = 0x107
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xca43
movb -0x21(%rbp), %al
addb $0x70, %al
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
movl %eax, -0x28(%rbp)
testl %eax, %eax
je 0xc965
jmp 0xc944
movl -0x28(%rbp), %eax
subl $0x1, %eax
je 0xc9e0
jmp 0xc952
movl -0x28(%rbp), %eax
subl $0x2, %eax
jne 0xc9fb
jmp 0xc960
jmp 0xca34
movq -0x10(%rbp), %rdi
callq 0x83b0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8330
movq -0x30(%rbp), %rdi
movq %rax, %rsi
movq -0x20(%rbp), %rdx
addq $0x18, %rdx
movq -0x20(%rbp), %rcx
addq $0x20, %rcx
callq 0xb380
testb $0x1, %al
jne 0xc9cd
movq 0x8656(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x3957(%rip), %rsi      # 0x10303
leaq 0x3a5d(%rip), %rdx      # 0x10410
leaq 0x357a(%rip), %rcx      # 0xff34
movl $0x111, %r8d            # imm = 0x111
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xca43
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x86f0
jmp 0xca34
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x18, %rsi
movq -0x20(%rbp), %rdx
addq $0x20, %rdx
callq 0xb7c0
jmp 0xca34
movq 0x85f6(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movl 0xc(%rax), %edx
leaq 0x3a0d(%rip), %rsi      # 0x10420
leaq 0x39f6(%rip), %rcx      # 0x10410
leaq 0x3513(%rip), %r8       # 0xff34
movl $0x11b, %r9d            # imm = 0x11B
movb $0x0, %al
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0xca43
movzbl -0x21(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_client.c
// Function: cli_connect_timeout
int cli_connect_timeout(struct aeEventLoop *el, long long id, void *ud)
{
    struct dubbo_client *cli = (struct dubbo_client *)ud;
    LOG_ERROR("连接超时");
    cli_reconnect(cli);
    return AE_NOMORE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq 0x8585(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x3a13(%rip), %rsi      # 0x10490
leaq 0x3a42(%rip), %rdx      # 0x104c6
leaq 0x3a4f(%rip), %rcx      # 0x104da
movl $0x98, %r8d
movb $0x0, %al
callq 0x2220
movq -0x20(%rbp), %rdi
callq 0xcab0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/goghcrow[P]dubbo_ab/dubbo_client.c
// Function: cli_reconnect
static void cli_reconnect(struct dubbo_client *cli)
{
    LOG_INFO("重新连接...");
    cli_close(cli);
    if (!cli_connect(cli))
    {
        LOG_ERROR("重连失败");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq 0x8535(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x3ed3(%rip), %rsi      # 0x109a0
leaq 0x3f04(%rip), %rdx      # 0x109d8
leaq 0x39ff(%rip), %rcx      # 0x104da
movl $0x113, %r8d            # imm = 0x113
movb $0x0, %al
callq 0x2220
movq -0x8(%rbp), %rdi
callq 0xde50
movq -0x8(%rbp), %rdi
callq 0xcb30
testb $0x1, %al
jne 0xcb2a
movq 0x84f3(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x3ed7(%rip), %rsi      # 0x109e6
leaq 0x3ec2(%rip), %rdx      # 0x109d8
leaq 0x39bd(%rip), %rcx      # 0x104da
movl $0x117, %r8d            # imm = 0x117
movb $0x0, %al
callq 0x2220
addq $0x10, %rsp
popq %rbp
retq