// File: /workspace/github_c_makefile_star2_O1/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 $0xd8, %rsp
testq %rdi, %rdi
je 0x3399
movq %rsi, %r15
testq %rsi, %rsi
je 0x33b8
movq %rdx, %r14
testq %rdx, %rdx
je 0x33d7
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movl $0x0, 0x70(%rsp)
callq 0x4b10
cmpq %r15, %r14
je 0x3263
leaq 0x34(%rsp), %r13
leaq 0x10(%rsp), %rbp
cmpl $0x0, (%r14)
je 0x3253
movq 0x8(%r14), %r12
movl (%r12), %eax
movl %eax, 0x10(%rsp)
addq $0x50, %r12
movq %r12, %rdi
callq 0x10c0
cmpq $0x20, %rax
jb 0x31e1
movl $0x20, %eax
leaq 0x14(%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 0x320c
movl $0x40, %eax
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x1060
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x64, %edx
callq 0x48db
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movl $0x0, 0x70(%rsp)
movq 0xe0(%r14), %r14
cmpq %r15, %r14
jne 0x31b4
cmpl $0x1, (%r14)
jne 0x32dd
movq 0x8(%r14), %r15
movl (%r15), %eax
leaq 0x14(%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 0x34(%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
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
movl $0x64, %edx
callq 0x48db
movq %rbx, %rdi
callq 0x44e6
cmpl $0xc8, %eax
jb 0x3387
movq %rbx, %rdi
callq 0x44e6
cltq
shrq $0x2, %rax
movabsq $0x28f5c28f5c28f5c3, %rcx # imm = 0x28F5C28F5C28F5C3
mulq %rcx
movq %rdx, %r14
shrq $0x2, %r14
cmpl $0x2, %r14d
jb 0x3387
movq (%rbx), %r13
movl %r14d, %eax
shrl %eax
cmpl $0x1, %eax
adcl $0x0, %eax
imulq $0x64, %rax, %rax
movq %rax, 0x8(%rsp)
decl %r14d
xorl %ebp, %ebp
leaq 0x74(%rsp), %rbx
movq %r13, %r15
addq %rbp, %r15
movl %r14d, %eax
imulq $0x64, %rax, %r12
addq %r13, %r12
movl $0x64, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1190
movl $0x64, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x1190
movl $0x64, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1190
addq $0x64, %rbp
decl %r14d
cmpq %rbp, 0x8(%rsp)
jne 0x3339
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x559c(%rip), %rdi      # 0x893c
leaq 0x4ef9(%rip), %rsi      # 0x82a0
leaq 0x5597(%rip), %rcx      # 0x8945
movl $0x2fb, %edx            # imm = 0x2FB
callq 0x10f0
leaq 0x55ca(%rip), %rdi      # 0x8989
leaq 0x4eda(%rip), %rsi      # 0x82a0
leaq 0x5578(%rip), %rcx      # 0x8945
movl $0x2fc, %edx            # imm = 0x2FC
callq 0x10f0
leaq 0x550c(%rip), %rdi      # 0x88ea
leaq 0x4ebb(%rip), %rsi      # 0x82a0
leaq 0x5559(%rip), %rcx      # 0x8945
movl $0x2fd, %edx            # imm = 0x2FD
callq 0x10f0
nop