// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rdi, %rbx
callq 0x8d84
testb %al, %al
je 0x8abc
movq %rbx, %rdi
callq 0x6ecd
movq %rbx, %rdi
callq 0x6ef4
movl %eax, %r15d
movq %rbx, %rdi
callq 0x6ef4
movq %rax, -0x30(%rbp)
movq %rbx, %rdi
callq 0x6e7f
movq %rax, %r13
movq %rbx, %rdi
callq 0x6ea6
movl %eax, %r12d
cmpl $0x400001, %eax         # imm = 0x400001
jge 0x8ce4
movl %r15d, %eax
andb $0x1f, %al
cmpb $0x2, %al
jne 0x8d1b
movb $0x1, %r14b
testb %r15b, %r15b
jns 0x8ad0
callq 0x2515
jmp 0x8acd
movq $0x0, -0x30(%rbp)
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %r14d, %r14d
testb %r14b, %r14b
je 0x8cdd
movq %rbx, %rdi
movl %r12d, %esi
callq 0x72ad
movq %rax, %r14
movslq %r12d, %rsi
movq %rbx, %rdi
callq 0x6638
movl $0x1, %edi
movl $0x38, %esi
callq 0x21b0
testq %rax, %rax
je 0x8d65
movq %rax, %rbx
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq %r13, (%rax)
shrb $0x5, %r15b
movl %r15d, %eax
andb $0x1, %al
movb %al, 0x8(%rbx)
movq -0x30(%rbp), %r12
movzbl %r12b, %eax
cmpl $0x31, %eax
jle 0x8b4d
cmpl $0x45, %eax
jle 0x8b78
cmpl $0x46, %eax
je 0x8b9d
cmpl $0x50, %eax
je 0x8baf
cmpl $0x5a, %eax
jne 0x8bb8
leaq 0x2335(%rip), %rdi      # 0xae80
jmp 0x8bbf
cmpl $0x1e, %eax
jg 0x8b65
cmpl $0x14, %eax
je 0x8b8b
cmpl $0x1e, %eax
jne 0x8bb8
leaq 0x22b9(%rip), %rdi      # 0xae1c
jmp 0x8bbf
cmpl $0x1f, %eax
je 0x8b94
cmpl $0x28, %eax
jne 0x8bb8
leaq 0x22c4(%rip), %rdi      # 0xae3a
jmp 0x8bbf
cmpl $0x32, %eax
je 0x8ba6
cmpl $0x3c, %eax
jne 0x8bb8
leaq 0x22ca(%rip), %rdi      # 0xae53
jmp 0x8bbf
leaq 0x2287(%rip), %rdi      # 0xae19
jmp 0x8bbf
leaq 0x2290(%rip), %rdi      # 0xae2b
jmp 0x8bbf
leaq 0x22c1(%rip), %rdi      # 0xae65
jmp 0x8bbf
leaq 0x2299(%rip), %rdi      # 0xae46
jmp 0x8bbf
leaq 0x22bd(%rip), %rdi      # 0xae73
jmp 0x8bbf
leaq 0x22ce(%rip), %rdi      # 0xae8d
callq 0x2340
movq %rax, 0x10(%rbx)
cmpb $0x14, %r12b
jne 0x8c5f
movb $0x1, 0x9(%rbx)
testb $0x1, %r15b
jne 0x8cc3
movq %r14, %rdi
callq 0x6ef4
movl %eax, %r15d
cmpb $-0x40, %al
jge 0x8d2f
leaq 0xc(%rbx), %r12
cmpb $-0x6e, %r15b
je 0x8cb7
movzbl %r15b, %eax
cmpl $0x91, %eax
je 0x8ca4
cmpl $0x90, %eax
jne 0x8d3a
movq %r14, %rdi
callq 0x645d
movq %rax, -0x30(%rbp)
movq %r14, %rdi
callq 0x642f
leaq 0x18(%rbx), %rdx
movq %rbx, %r13
addq $0x20, %r13
movq -0x30(%rbp), %rdi
movq %rax, %rsi
movq %r13, %rcx
callq 0x8135
testb %al, %al
je 0x8d44
movq (%r13), %rsi
movq %r14, %rdi
callq 0x6638
jmp 0x8cb7
movb $0x0, 0x9(%rbx)
movq %r14, %rdi
callq 0x645d
movq %rax, %r12
movq %r14, %rdi
callq 0x642f
leaq 0x18(%rbx), %rdx
movq %rbx, %r15
addq $0x20, %r15
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rcx
callq 0x8135
testb %al, %al
je 0x8d28
movq (%r15), %rsi
movq %r14, %rdi
callq 0x6638
jmp 0x8cc3
leaq 0x18(%rbx), %rsi
movq %rbx, %rdx
addq $0x20, %rdx
movq %r14, %rdi
callq 0x83b0
addb $0x70, %r15b
movzbl %r15b, %eax
movl %eax, (%r12)
movq %r14, %rdi
callq 0x63bc
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2546
jmp 0x8d5e
movq 0x730d(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x1f94(%rip), %rsi      # 0xac89
leaq 0x1fd6(%rip), %rcx      # 0xacd2
leaq 0x1cfe(%rip), %r8       # 0xaa01
xorl %r14d, %r14d
movl %r12d, %edx
movl $0xbf, %r9d
xorl %eax, %eax
callq 0x21e0
jmp 0x8ad0
movzbl %al, %edi
callq 0x24e0
jmp 0x8acd
callq 0x2577
jmp 0x8d4e
movzbl %r15b, %edi
callq 0x260f
jmp 0x8d49
movq %r12, %rdi
callq 0x25d9
jmp 0x8d49
callq 0x25a8
callq 0x2644
movq %r14, %rdi
callq 0x63bc
movq %rbx, %rdi
callq 0x23a0
xorl %ebx, %ebx
jmp 0x8ccb
leaq 0x2060(%rip), %rdi      # 0xadcc
leaq 0x1c8e(%rip), %rsi      # 0xaa01
leaq 0x1d9f(%rip), %rcx      # 0xab19
movl $0x1d0, %edx            # imm = 0x1D0
callq 0x2150