// File: /workspace/github_c_makefile_star2_O3/sachinites[P]CommandParser/cmd_hier.c
// Function: build_cmd_tree_leaves_data
void
build_cmd_tree_leaves_data(ser_buff_t *tlv_buff,/*Output serialize buffer*/
        param_t *src_param, /*Source command*/
        param_t *dst_param){/*Destination command*/

    assert(tlv_buff);
    assert(src_param);
    assert(dst_param);

    tlv_struct_t tlv, *tlv_temp = NULL;
    unsigned int tlv_units = 0, i = 0, j = 0;

    memset(&tlv, 0, sizeof(tlv_struct_t));
    reset_serialize_buffer(tlv_buff);

    while(dst_param != src_param){
        if(IS_PARAM_CMD(dst_param)){
            dst_param = dst_param->parent;
            continue;
        }

        prepare_tlv_from_leaf(GET_PARAM_LEAF(dst_param), (&tlv));
        put_value_in_tlv((&tlv), GET_LEAF_VALUE_PTR(dst_param)); 
        collect_tlv(tlv_buff, &tlv);
        memset(&tlv, 0, sizeof(tlv_struct_t));

        dst_param = dst_param->parent;
    }

    if(IS_PARAM_LEAF(dst_param)){
        prepare_tlv_from_leaf(GET_PARAM_LEAF(dst_param), (&tlv));
        put_value_in_tlv((&tlv), GET_LEAF_VALUE_PTR(dst_param)); 
        collect_tlv(tlv_buff, &tlv);
    }

    /*Now reverse the TLV buffer*/
    if(get_serialize_buffer_size(tlv_buff) < (sizeof(tlv_struct_t) << 1)){
        return;
    }

    tlv_units = get_serialize_buffer_size(tlv_buff)/sizeof(tlv_struct_t);
    tlv_temp = (tlv_struct_t *)(tlv_buff->b);
    j = tlv_units -1;

    for(; i < (tlv_units >> 1); i++, j--){
        swap_tlv_units(tlv_temp+i, tlv_temp +j);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
testq %rdi, %rdi
je 0x3359
movq %rsi, %r15
testq %rsi, %rsi
je 0x3378
movq %rdx, %r14
testq %rdx, %rdx
je 0x3397
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movl $0x0, 0x60(%rsp)
callq 0x49b2
cmpq %r15, %r14
je 0x3244
leaq 0x24(%rsp), %r13
movq %rsp, %rbp
cmpl $0x0, (%r14)
je 0x3234
movq 0x8(%r14), %r12
movl (%r12), %eax
movl %eax, (%rsp)
addq $0x50, %r12
movq %r12, %rdi
callq 0x10c0
cmpq $0x20, %rax
jb 0x31c3
movl $0x20, %eax
leaq 0x4(%rsp), %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x1060
movq 0x8(%r14), %r12
addq $0x4, %r12
movq %r12, %rdi
callq 0x10c0
cmpq $0x40, %rax
jb 0x31ee
movl $0x40, %eax
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x1060
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x64, %edx
callq 0x477d
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movl $0x0, 0x60(%rsp)
movq 0xe0(%r14), %r14
cmpq %r15, %r14
jne 0x3197
cmpl $0x1, (%r14)
jne 0x32bc
movq 0x8(%r14), %r15
movl (%r15), %eax
leaq 0x4(%rsp), %r12
movl %eax, -0x4(%r12)
addq $0x50, %r15
movq %r15, %rdi
callq 0x10c0
cmpq $0x20, %rax
movl $0x20, %edx
cmovbq %rax, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1060
leaq 0x24(%rsp), %r15
movq 0x8(%r14), %r14
addq $0x4, %r14
movq %r14, %rdi
callq 0x10c0
cmpq $0x40, %rax
movl $0x40, %edx
cmovbq %rax, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1060
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x64, %edx
callq 0x477d
movq %rbx, %rdi
callq 0x439a
cmpl $0xc8, %eax
jb 0x3347
movq %rbx, %rdi
callq 0x439a
cltq
shrq $0x2, %rax
movabsq $0x28f5c28f5c28f5c3, %rcx # imm = 0x28F5C28F5C28F5C3
mulq %rcx
shrq $0x2, %rdx
cmpl $0x2, %edx
jb 0x3347
movq (%rbx), %r12
movl %edx, %r13d
shrl %r13d
leal -0x1(%rdx), %ebp
leaq 0x64(%rsp), %rbx
movq %r12, %r14
movl %ebp, %eax
imulq $0x64, %rax, %r15
addq %r12, %r15
movl $0x64, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1190
movl $0x64, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x1190
movl $0x64, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1190
addq $0x64, %r14
decl %ebp
decq %r13
jne 0x3303
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x55dc(%rip), %rdi      # 0x893c
leaq 0x4f39(%rip), %rsi      # 0x82a0
leaq 0x55d7(%rip), %rcx      # 0x8945
movl $0x2fb, %edx            # imm = 0x2FB
callq 0x10f0
leaq 0x560a(%rip), %rdi      # 0x8989
leaq 0x4f1a(%rip), %rsi      # 0x82a0
leaq 0x55b8(%rip), %rcx      # 0x8945
movl $0x2fc, %edx            # imm = 0x2FC
callq 0x10f0
leaq 0x554c(%rip), %rdi      # 0x88ea
leaq 0x4efb(%rip), %rsi      # 0x82a0
leaq 0x5599(%rip), %rcx      # 0x8945
movl $0x2fd, %edx            # imm = 0x2FD
callq 0x10f0
nop