// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
leaq 0x10(%rsp), %rbp
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %eax, %eax
cmpb $0x0, (%r15)
je 0x3bc9
movzbl (%r15,%r14), %edx
cmpl $0x2c, %edx
je 0x3b47
testl %edx, %edx
jne 0x3bb1
incq %rax
testb $0x1, %r12b
movl $0x0, %edx
cmoveq %rdx, %rax
movq %rax, %rbx
addq %rcx, %rbx
leaq (%r15,%rbx), %rsi
leaq 0x20(%rsp), %r13
movq %r13, 0x10(%rsp)
leaq (%r15,%r14), %rdx
movq %rbp, %rdi
callq 0x37d4
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x3dba
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3b9b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r14, %rax
subq %rbx, %rax
movzbl (%r15,%r14), %ecx
cmpl $0x2c, %ecx
je 0x3bb6
testl %ecx, %ecx
jne 0x3bb9
jmp 0x3bc9
movq %rcx, %rbx
jmp 0x3bb9
movb $0x1, %r12b
incq %r14
movq %rbx, %rcx
cmpq $0x64, %r14
jne 0x3b2f
cmpb $0x0, 0x64(%r15)
leaq 0x20(%rsp), %r14
movq 0x30(%rsp), %r12
je 0x3c44
leaq 0x64(%r15), %r13
movl $0x64, %ebx
leaq 0x10(%rsp), %rbp
cmpb $0x0, (%r15,%rbx)
je 0x3bf7
cmpq $0x7e, %rbx
jbe 0x3c3a
jmp 0x3c44
movq %r14, 0x10(%rsp)
leaq (%r15,%rbx), %rdx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x37d4
movq %r12, %rdi
movq %rbp, %rsi
callq 0x21f0
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x3c2d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
cmpb $0x0, (%r15,%rbx)
je 0x3c44
cmpq $0x7f, %rbx
jae 0x3c44
incq %rbx
cmpb $0x0, (%r13)
jne 0x3be8
cmpq $0x81, 0x8(%rsp)
movq 0x38(%rsp), %rbp
jb 0x3cc1
leaq 0x80(%r15), %r12
cmpb $0x0, (%r12)
je 0x3cc1
movl $0x80, %ebx
leaq 0x10(%rsp), %r13
cmpb $0x0, (%r15,%rbx)
jne 0x3cb0
movq %r14, 0x10(%rsp)
leaq (%r15,%rbx), %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x37d4
movq %rbp, %rdi
movq %r13, %rsi
callq 0x21f0
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x3ca9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
cmpb $0x0, (%r15,%rbx)
je 0x3cc1
incq %rbx
cmpq 0x8(%rsp), %rbx
jae 0x3cc1
cmpb $0x0, (%r12)
jne 0x3c6c
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3cea
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r14, %rdi
callq 0x2260