// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x3a70
jmp 0x3a8f
leaq 0x6f31(%rip), %rdi      # 0xa9a8
leaq 0x688c(%rip), %rsi      # 0xa30a
movl $0x2fb, %edx            # imm = 0x2FB
leaq 0x6f27(%rip), %rcx      # 0xa9b1
callq 0x10c0
cmpq $0x0, -0x10(%rbp)
je 0x3a98
jmp 0x3ab7
leaq 0x6f56(%rip), %rdi      # 0xa9f5
leaq 0x6864(%rip), %rsi      # 0xa30a
movl $0x2fc, %edx            # imm = 0x2FC
leaq 0x6eff(%rip), %rcx      # 0xa9b1
callq 0x10c0
cmpq $0x0, -0x18(%rbp)
je 0x3ac0
jmp 0x3adf
leaq 0x6e8d(%rip), %rdi      # 0xa954
leaq 0x683c(%rip), %rsi      # 0xa30a
movl $0x2fd, %edx            # imm = 0x2FD
leaq 0x6ed7(%rip), %rcx      # 0xa9b1
callq 0x10c0
movq $0x0, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movl $0x0, -0x90(%rbp)
movl $0x0, -0x94(%rbp)
leaq -0x7c(%rbp), %rdi
xorl %esi, %esi
movl $0x64, %edx
callq 0x10d0
movq -0x8(%rbp), %rdi
callq 0x6100
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x3c8c
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x3b49
movq -0x18(%rbp), %rax
movq 0xe0(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x3b21
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
leaq -0x7c(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x50, %rax
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x50, %rdi
callq 0x1090
movq %rax, %rcx
movl $0x20, %eax
cmpq %rcx, %rax
jae 0x3ba4
movl $0x20, %eax
movq %rax, -0xb0(%rbp)
jmp 0x3bbc
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x50, %rdi
callq 0x1090
movq %rax, -0xb0(%rbp)
movq -0xa0(%rbp), %rsi
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rdx
callq 0x1050
leaq -0x7c(%rbp), %rax
addq $0x24, %rax
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x4, %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x4, %rdi
callq 0x1090
movq %rax, %rcx
movl $0x40, %eax
cmpq %rcx, %rax
jae 0x3c24
movl $0x40, %eax
movq %rax, -0xc8(%rbp)
jmp 0x3c3c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x4, %rdi
callq 0x1090
movq %rax, -0xc8(%rbp)
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
callq 0x1050
movq -0x8(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
movl $0x64, %edx
callq 0x5da0
leaq -0x7c(%rbp), %rdi
xorl %esi, %esi
movl $0x64, %edx
callq 0x10d0
movq -0x18(%rbp), %rax
movq 0xe0(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x3b21
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x3db8
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
leaq -0x7c(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x50, %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x50, %rdi
callq 0x1090
movq %rax, %rcx
movl $0x20, %eax
cmpq %rcx, %rax
jae 0x3cf4
movl $0x20, %eax
movq %rax, -0xe0(%rbp)
jmp 0x3d0c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x50, %rdi
callq 0x1090
movq %rax, -0xe0(%rbp)
movq -0xd0(%rbp), %rsi
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
callq 0x1050
leaq -0x7c(%rbp), %rax
addq $0x24, %rax
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x4, %rax
movq %rax, -0xe8(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x4, %rdi
callq 0x1090
movq %rax, %rcx
movl $0x40, %eax
cmpq %rcx, %rax
jae 0x3d74
movl $0x40, %eax
movq %rax, -0xf8(%rbp)
jmp 0x3d8c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x4, %rdi
callq 0x1090
movq %rax, -0xf8(%rbp)
movq -0xe8(%rbp), %rsi
movq -0xf0(%rbp), %rdi
movq -0xf8(%rbp), %rdx
callq 0x1050
movq -0x8(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
movl $0x64, %edx
callq 0x5da0
movq -0x8(%rbp), %rdi
callq 0x5520
cltq
cmpq $0xc8, %rax
jae 0x3dd0
jmp 0x3e67
movq -0x8(%rbp), %rdi
callq 0x5520
cltq
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
movl %eax, -0x8c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movl -0x8c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x94(%rbp)
movl -0x90(%rbp), %eax
movl -0x8c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x3e67
movq -0x88(%rbp), %rdi
movl -0x90(%rbp), %eax
imulq $0x64, %rax, %rax
addq %rax, %rdi
movq -0x88(%rbp), %rsi
movl -0x94(%rbp), %eax
imulq $0x64, %rax, %rax
addq %rax, %rsi
callq 0x3e70
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movl -0x94(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x3e08
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq