// File: /workspace/github_cpp_makefile_star2_O2/NovaGL[P]HarmonyHubControl/HarmonyHubControl.cpp
// Function: parseConfiguration(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::map<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::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&, std::vector<Device, std::allocator<Device>>&)
int parseConfiguration(const std::string& strConfiguration, std::map< std::string, std::string >& mapActivities, std::vector< Device >& vecDevices)
{
    rapidjson::Document doc;
    doc.Parse(strConfiguration.c_str());
    if(doc.HasParseError())
    {
        std::ostringstream stringStream;
        stringStream << "parseConfiguration : Error(offset " << doc.GetErrorOffset() << "): " <<
            GetParseError_En(doc.GetParseError());
        errorString = stringStream.str();
        return 1;
    }
    
    // Search for activities
    rapidjson::Value::ConstMemberIterator itr = doc.FindMember("activity");
    if (itr != doc.MemberEnd() && itr->value.IsArray())
    {
        for (const auto& activity : itr->value.GetArray())
        {
            mapActivities.insert(std::map< std::string, std::string>::value_type(TryGetMemberString(activity,"id"), TryGetMemberString(activity,"label")));
        }
    }
    
    // Search for devices and commands
    itr = doc.FindMember("device");
    if (itr != doc.MemberEnd() && itr->value.IsArray())
    {
        for (const auto& device : itr->value.GetArray())
        {
            Device d;
            d.m_strID = TryGetMemberString(device, "id");
            d.m_strLabel = TryGetMemberString(device, "label");
            d.m_strType = TryGetMemberString(device, "type");
            d.m_strManufacturer = TryGetMemberString(device, "manufacturer");
            d.m_strModel = TryGetMemberString(device, "model");

            if (parseControlGroup(device, d.m_vecFunctions) != 0)
            {
                return 1;
            }

            vecDevices.push_back(d);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1c8(%rsp), %r15
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x6a68
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x743c
cmpl $0x0, 0x218(%rsp)
je 0x5221
leaq 0x50(%rsp), %rdi
callq 0x3360
leaq 0x67a2(%rip), %rsi      # 0xb943
leaq 0x50(%rsp), %rdi
callq 0x3270
movq 0x220(%rsp), %rsi
movq %rax, %rdi
callq 0x31d0
leaq 0x67a4(%rip), %rsi      # 0xb966
movq %rax, %rdi
callq 0x3270
movq %rax, %rbx
movl 0x218(%rsp), %edi
callq 0x6bce
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3270
leaq 0x58(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x3420
leaq 0xe0be(%rip), %rdi      # 0x132b8
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3518
leaq 0x50(%rsp), %rdi
callq 0x30e0
pushq $0x1
popq %rbp
jmp 0x551d
leaq 0x659d(%rip), %rdx      # 0xb7c5
leaq 0x50(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x6bec
leaq 0x50(%rsp), %rdi
movq (%rdi), %rbx
leaq 0x1c8(%rsp), %rsi
callq 0x6c44
cmpq 0x50(%rsp), %rbx
je 0x52fb
cmpw $0x4, 0x1e(%rbx)
jne 0x52fb
addq $0x10, %rbx
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x6b5e
movq (%rsp), %rdi
callq 0x9536
movq %rax, %r15
movq (%rsp), %rdi
callq 0x956c
movq %rax, %r12
leaq 0x30(%rsp), %rbp
leaq 0x10(%rsp), %r13
leaq 0x50(%rsp), %rbx
cmpq %r12, %r15
je 0x52fb
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x8dee(%rip), %rdx      # 0xe09b
callq 0x4da1
movq %r13, %rdi
movq %r15, %rsi
leaq 0x6668(%rip), %rdx      # 0xb927
callq 0x4da1
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x6c8a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x9b08
movq %rbx, %rdi
callq 0x6cb0
movq %r13, %rdi
callq 0x3518
movq %rbp, %rdi
callq 0x3518
addq $0x10, %r15
jmp 0x529b
leaq 0x6668(%rip), %rdx      # 0xb96a
leaq 0x50(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x6bec
leaq 0x50(%rsp), %rdi
movq (%rdi), %rbx
leaq 0x1c8(%rsp), %rsi
callq 0x6c44
cmpq 0x50(%rsp), %rbx
je 0x551b
xorl %ebp, %ebp
cmpw $0x4, 0x1e(%rbx)
jne 0x551d
addq $0x10, %rbx
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x6b5e
movq 0x10(%rsp), %rdi
callq 0x9536
movq %rax, %r14
movq 0x10(%rsp), %rdi
callq 0x956c
movq %rax, %r15
leaq 0xf0(%rsp), %r13
xorl %ebx, %ebx
leaq 0x30(%rsp), %r12
leaq 0x50(%rsp), %rbp
cmpq %r15, %r14
je 0x551b
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
movb %bl, 0x60(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
movb %bl, 0x80(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
andq $0x0, 0x98(%rsp)
movb %bl, 0xa0(%rsp)
leaq 0xc0(%rsp), %rax
movq %rax, 0xb0(%rsp)
andq $0x0, 0xb8(%rsp)
movb %bl, 0xc0(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0xd0(%rsp)
andq $0x0, 0xd8(%rsp)
movb %bl, 0xe0(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
andq $0x0, 0x10(%r13)
movq %r12, %rdi
movq %r14, %rsi
leaq 0x8c6a(%rip), %rdx      # 0xe09b
callq 0x4da1
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3320
movq %r12, %rdi
callq 0x3518
movq %r12, %rdi
movq %r14, %rsi
leaq 0x64d1(%rip), %rdx      # 0xb927
callq 0x4da1
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
callq 0x3320
movq %r12, %rdi
callq 0x3518
movq %r12, %rdi
movq %r14, %rsi
leaq 0x64f4(%rip), %rdx      # 0xb971
callq 0x4da1
leaq 0xd0(%rsp), %rdi
movq %r12, %rsi
callq 0x3320
movq %r12, %rdi
callq 0x3518
movq %r12, %rdi
movq %r14, %rsi
leaq 0x64cf(%rip), %rdx      # 0xb976
callq 0x4da1
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0x3320
movq %r12, %rdi
callq 0x3518
movq %r12, %rdi
movq %r14, %rsi
leaq 0x64b2(%rip), %rdx      # 0xb983
callq 0x4da1
leaq 0xb0(%rsp), %rdi
movq %r12, %rsi
callq 0x3320
movq %r12, %rdi
callq 0x3518
movq %r14, %rdi
movq %r13, %rsi
callq 0x50bf
testl %eax, %eax
jne 0x553e
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x6cc6
movq %rbp, %rdi
callq 0x6cf6
addq $0x10, %r14
jmp 0x5380
xorl %ebp, %ebp
leaq 0x1c8(%rsp), %rdi
callq 0x6b18
movl %ebp, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50(%rsp), %rdi
callq 0x6cf6
jmp 0x5219
jmp 0x558b
jmp 0x558b
jmp 0x558b
jmp 0x558b
jmp 0x558b
jmp 0x558b
jmp 0x558b
jmp 0x558b
jmp 0x556d
jmp 0x558b
jmp 0x558b
jmp 0x557c
jmp 0x557c
jmp 0x557c
jmp 0x557c
jmp 0x557c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x30e0
jmp 0x55b6
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x6cf6
jmp 0x55b6
movq %rax, %rbx
jmp 0x55b6
movq %rax, %rbx
jmp 0x55ac
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x6cb0
leaq 0x10(%rsp), %rdi
callq 0x3518
leaq 0x30(%rsp), %rdi
callq 0x3518
leaq 0x1c8(%rsp), %rdi
callq 0x6b18
movq %rbx, %rdi
callq 0x3470