// File: /workspace/github_cpp_makefile_star2_O2/AraKhachatryan[P]messenger/encode_decode.cpp
// Function: decode_message(char const*, unsigned long, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void decode_message( const char * encoded_message, size_t io_buffer_length,
                    std::vector<std::string>& dest_names, std::string& message_info, std::string&  message )
{
    size_t name_char_count = 0;
    size_t name_char_firs_pos = 0;
    bool new_name_flag = 0;


    for( size_t i = 0; i < 100; ++i )
    {
        if ( encoded_message[0] == 0x00 )
        {
            break;
        }

        if ( (encoded_message[i] == ',') || (encoded_message[i] == 0x00) )
        {
            if ( new_name_flag )
            {
                name_char_firs_pos += name_char_count + new_name_flag;
            }
            name_char_count = i - name_char_firs_pos;

            dest_names.push_back(std::string(encoded_message + name_char_firs_pos, name_char_count));

            if ( encoded_message[i] == 0x00 )
            {
                break;
            }

            if ( encoded_message[i] == ',' )
            {
                new_name_flag = 1;
                continue;
            }
        }
    }

    // copy message info part to message_info until reaching 0x00
    name_char_count = 0;
    for( size_t i = 100; i < 128; ++i )
    {
        if ( encoded_message[100] == 0x00 )
        {
            break;
        }

        if ( encoded_message[i] == 0x00 )
        {
            name_char_count = i - 100;

            message_info = std::string(encoded_message + 100, name_char_count);

            if ( encoded_message[i] == 0x00 )
            {
                break;
            }
        }

    }

    // copy message part to message until reaching 0x00
    name_char_count = 0;
    for( size_t i = 128; i < io_buffer_length; ++i )
    {
        if ( encoded_message[128] == 0x00 )
        {
            break;
        }

        if ( encoded_message[i] == 0x00 )
        {
            name_char_count = i - 128;

            message = std::string(encoded_message + 128, name_char_count);

            if ( encoded_message[i] == 0x00 )
            {
                break;
            }
        }

    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, %r15
movq %rsp, %r14
xorl %r13d, %r13d
xorl %eax, %eax
xorl %edx, %edx
xorl %ebp, %ebp
cmpq $0x64, %rbp
je 0x3198
cmpb $0x0, (%r15)
je 0x3198
movzbl (%r15,%rbp), %ecx
cmpl $0x2c, %ecx
je 0x311c
testl %ecx, %ecx
jne 0x3183
leaq (%r15,%rbp), %rbx
incq %r13
movq %rdx, 0x38(%rsp)
testb $0x1, %dl
movl $0x0, %ecx
cmoveq %rcx, %r13
movq %r13, %r12
addq %rax, %r12
leaq (%r15,%r12), %rsi
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %rbx, %rdx
callq 0x2d3c
movq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x32e0
movq %rbp, %r13
subq %r12, %r13
movq %r14, %rdi
callq 0x20f0
movzbl (%rbx), %eax
cmpl $0x2c, %eax
je 0x3188
testl %eax, %eax
movq %rsp, %r14
movq 0x38(%rsp), %rdx
jne 0x318d
jmp 0x3198
movq %rax, %r12
jmp 0x318d
movb $0x1, %dl
movq %rsp, %r14
incq %rbp
movq %r12, %rax
jmp 0x30fa
leaq 0x64(%r15), %r13
xorl %r14d, %r14d
movq %rsp, %rbp
movq 0x20(%rsp), %r12
cmpq $0x1c, %r14
je 0x31f4
cmpb $0x0, (%r13)
je 0x31f4
cmpb $0x0, (%r13,%r14)
jne 0x31ef
leaq (%r14,%r13), %rbx
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2d3c
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2210
movq %rbp, %rdi
callq 0x20f0
cmpb $0x0, (%rbx)
je 0x31f4
incq %r14
jmp 0x31a7
leaq 0x80(%r15), %r12
movl $0x80, %r14d
movq %rsp, %r13
movq 0x28(%rsp), %rbp
cmpq 0x40(%rsp), %r14
jae 0x3256
cmpb $0x0, (%r12)
je 0x3256
cmpb $0x0, (%r15,%r14)
jne 0x3251
leaq (%r15,%r14), %rbx
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x2d3c
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2210
movq %r13, %rdi
callq 0x20f0
cmpb $0x0, (%rbx)
je 0x3256
incq %r14
jmp 0x3209
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2280