// File: /workspace/github_cpp_makefile_star2_O3/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, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r15
xorl %r12d, %r12d
xorl %esi, %esi
xorl %ecx, %ecx
xorl %eax, %eax
cmpb $0x0, (%r15)
je 0x3bf6
movzbl (%r15,%r12), %edx
cmpl $0x2c, %edx
je 0x3b68
testl %edx, %edx
jne 0x3bde
leaq (%r15,%r12), %rbx
incq %rax
movq %rsi, 0x40(%rsp)
testb $0x1, %sil
movl $0x0, %edx
cmoveq %rdx, %rax
movq %rax, %r13
addq %rcx, %r13
leaq (%r15,%r13), %rsi
leaq 0x10(%rsp), %rbp
movq %rbp, (%rsp)
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3804
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x3de0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x3bc5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r12, %rax
subq %r13, %rax
movzbl (%rbx), %ecx
cmpl $0x2c, %ecx
je 0x3be3
testl %ecx, %ecx
movq 0x40(%rsp), %rsi
jne 0x3be6
jmp 0x3bf6
movq %rcx, %r13
jmp 0x3be6
movb $0x1, %sil
incq %r12
movq %r13, %rcx
cmpq $0x64, %r12
jne 0x3b50
cmpb $0x0, 0x64(%r15)
leaq 0x10(%rsp), %r12
je 0x3c6c
leaq 0x64(%r15), %r13
movl $0x64, %r14d
movq %rsp, %rbp
cmpb $0x0, (%r15,%r14)
je 0x3c1e
cmpq $0x7e, %r14
jbe 0x3c62
jmp 0x3c6c
leaq (%r15,%r14), %rbx
movq %r12, (%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3804
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x21f0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x3c57
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
cmpb $0x0, (%rbx)
je 0x3c6c
cmpq $0x7f, %r14
jae 0x3c6c
incq %r14
cmpb $0x0, (%r13)
jne 0x3c0f
cmpq $0x81, 0x20(%rsp)
jb 0x3ce9
leaq 0x80(%r15), %r12
cmpb $0x0, (%r12)
je 0x3ce9
movl $0x80, %r14d
movq %rsp, %r13
cmpb $0x0, (%r15,%r14)
jne 0x3cd8
leaq (%r15,%r14), %rbx
leaq 0x10(%rsp), %rbp
movq %rbp, (%rsp)
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3804
movq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0x21f0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x3cd3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
cmpb $0x0, (%rbx)
je 0x3ce9
incq %r14
cmpq 0x20(%rsp), %r14
jae 0x3ce9
cmpb $0x0, (%r12)
jne 0x3c8e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x3d11
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2260