// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
callq 0x8c4d
testb %al, %al
je 0x8bb1
movq %r14, %rdi
callq 0x6d8b
movq %r14, %rdi
callq 0x6db2
movl %eax, %r12d
movq %r14, %rdi
callq 0x6db2
movl %eax, %r13d
movq %r14, %rdi
callq 0x6d3d
movq %rax, %rbx
movq %r14, %rdi
callq 0x6d64
movl %eax, %r15d
cmpl $0x400001, %eax         # imm = 0x400001
jge 0x8b71
movl %r12d, %eax
andb $0x1f, %al
cmpb $0x2, %al
jne 0x8ba2
testb %r12b, %r12b
js 0x8bac
movq %r14, %rdi
movl %r15d, %esi
callq 0x7171
movq %rax, -0x30(%rbp)
movslq %r15d, %rsi
movq %r14, %rdi
callq 0x64f9
movl $0x1, %edi
movl $0x38, %esi
callq 0x21b0
testq %rax, %rax
je 0x8c2e
movq %rax, %r15
movq %rax, %r14
movl $0xffffffff, 0xc(%r15)  # imm = 0xFFFFFFFF
movq %rbx, (%r15)
shrb $0x5, %r12b
movl %r12d, %eax
andb $0x1, %al
movb %al, 0x8(%r15)
movzbl %r13b, %eax
cmpl $0x31, %eax
jle 0x89fb
cmpl $0x45, %eax
movq -0x30(%rbp), %r13
jle 0x8a3c
cmpl $0x46, %eax
je 0x8b04
cmpl $0x50, %eax
je 0x8b16
cmpl $0x5a, %eax
jne 0x8b1f
leaq 0x248a(%rip), %rdi      # 0xae80
jmp 0x8b26
cmpl $0x1e, %eax
movq -0x30(%rbp), %r13
jg 0x8a1e
cmpl $0x14, %eax
je 0x8a5a
cmpl $0x1e, %eax
jne 0x8b1f
leaq 0x2403(%rip), %rdi      # 0xae1c
jmp 0x8b26
cmpl $0x1f, %eax
je 0x8afb
cmpl $0x28, %eax
jne 0x8b1f
leaq 0x2403(%rip), %rdi      # 0xae3a
jmp 0x8b26
cmpl $0x32, %eax
je 0x8b0d
cmpl $0x3c, %eax
jne 0x8b1f
leaq 0x23fe(%rip), %rdi      # 0xae53
jmp 0x8b26
leaq 0x23b8(%rip), %rdi      # 0xae19
callq 0x2340
movq %rax, 0x10(%r14)
movb $0x1, 0x9(%r14)
testb $0x1, %r12b
jne 0x8b67
movq %r13, %rdi
callq 0x6db2
movl %eax, %r12d
cmpb $-0x40, %al
jge 0x8c09
leaq 0xc(%r15), %rbx
cmpb $-0x6e, %r12b
je 0x8bf6
movzbl %r12b, %eax
cmpl $0x91, %eax
je 0x8be2
cmpl $0x90, %eax
jne 0x8c14
movq -0x30(%rbp), %r13
movq %r13, %rdi
callq 0x631e
movq %rax, -0x38(%rbp)
movq %r13, %rdi
callq 0x62f0
leaq 0x18(%r15), %rdx
addq $0x20, %r15
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movq %r15, %rcx
callq 0x7feb
testb %al, %al
je 0x8c22
movq (%r15), %rsi
movq %r13, %rdi
callq 0x64f9
jmp 0x8bf6
leaq 0x2329(%rip), %rdi      # 0xae2b
jmp 0x8b26
leaq 0x235a(%rip), %rdi      # 0xae65
jmp 0x8b26
leaq 0x2332(%rip), %rdi      # 0xae46
jmp 0x8b26
leaq 0x2356(%rip), %rdi      # 0xae73
jmp 0x8b26
leaq 0x2367(%rip), %rdi      # 0xae8d
callq 0x2340
movq %rax, 0x10(%r14)
movq %r13, %rdi
callq 0x631e
movq %rax, %rbx
movq %r13, %rdi
callq 0x62f0
leaq 0x18(%r15), %rdx
addq $0x20, %r15
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rcx
callq 0x7feb
testb %al, %al
je 0x8bcb
movq (%r15), %rsi
movq %r13, %rdi
callq 0x64f9
movq %r13, %rdi
callq 0x627d
jmp 0x8bb9
movq 0x7480(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x2107(%rip), %rsi      # 0xac89
leaq 0x2149(%rip), %rcx      # 0xacd2
leaq 0x1e71(%rip), %r8       # 0xaa01
movl %r15d, %edx
movl $0xbf, %r9d
xorl %eax, %eax
callq 0x21e0
jmp 0x8bb1
movzbl %al, %edi
callq 0x24e0
jmp 0x8bb1
callq 0x2515
callq 0x2644
xorl %r14d, %r14d
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2613
movq %r13, %rdi
callq 0x627d
movq %r14, %rdi
callq 0x23a0
jmp 0x8bb6
leaq 0x18(%r15), %rsi
addq $0x20, %r15
movq -0x30(%rbp), %rdi
movq %r15, %rdx
callq 0x825f
addb $0x70, %r12b
movzbl %r12b, %eax
movl %eax, (%rbx)
movq -0x30(%rbp), %r13
jmp 0x8b67
movzbl %r12b, %edi
callq 0x25ad
jmp 0x8c27
movq %rbx, %rdi
callq 0x2577
movq -0x30(%rbp), %r13
jmp 0x8c27
callq 0x2546
callq 0x25e2
jmp 0x8bd0
leaq 0x2197(%rip), %rdi      # 0xadcc
leaq 0x1dc5(%rip), %rsi      # 0xaa01
leaq 0x1ed6(%rip), %rcx      # 0xab19
movl $0x1d0, %edx            # imm = 0x1D0
callq 0x2150