// File: /workspace/github_cpp_makefile_star2_O1/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 $0x238, %rsp            # imm = 0x238
movq %rdx, 0x50(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %rbx
leaq 0x1d8(%rsp), %r14
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x7f9c
movq (%rbx), %rax
leaq 0x60(%rsp), %rsi
movq %rax, (%rsi)
movq %rax, 0x8(%rsi)
movq %r14, %rdi
callq 0x8b24
cmpl $0x0, 0x228(%rsp)
je 0x5d52
leaq 0x60(%rsp), %rdi
callq 0x3360
leaq 0x6c4d(%rip), %rsi      # 0xc943
leaq 0x60(%rsp), %rdi
movl $0x22, %edx
callq 0x3310
movq 0x230(%rsp), %rsi
leaq 0x60(%rsp), %rdi
callq 0x31b0
movq %rax, %rbx
leaq 0x6c45(%rip), %rsi      # 0xc966
movl $0x3, %edx
movq %rax, %rdi
callq 0x3310
movl 0x228(%rsp), %eax
cmpq $0x11, %rax
ja 0x61ad
leaq 0x91fe(%rip), %rcx      # 0xef44
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x61b4
leaq 0x6a6c(%rip), %rdx      # 0xc7c5
leaq 0x60(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x8118
cmpw $0x3, 0x1e6(%rsp)
jne 0x6257
movq 0x60(%rsp), %rdi
movabsq $0xffffffffffff, %r14   # imm = 0xFFFFFFFFFFFF
movq 0x1e0(%rsp), %rax
andq %r14, %rax
movl 0x1d8(%rsp), %ecx
shlq $0x5, %rcx
addq %rax, %rcx
cmpq %rcx, %rdi
je 0x5f29
cmpw $0x4, 0x1e(%rdi)
jne 0x5f29
movq 0x18(%rdi), %r12
andq %r14, %r12
addq $0x10, %rdi
callq 0xab0a
movq %rax, 0x58(%rsp)
cmpq %r12, %rax
je 0x5f29
leaq 0x70(%rsp), %r15
leaq 0x18(%rsp), %rbx
leaq 0x90(%rsp), %r13
leaq 0x40(%rsp), %rbp
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
leaq 0x9022(%rip), %rdx      # 0xee1c
callq 0x57db
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
leaq 0x6b19(%rip), %rdx      # 0xc927
callq 0x57db
movq %r15, 0x60(%rsp)
movq 0x8(%rsp), %rax
cmpq %rbx, %rax
je 0x5e33
movq %rax, 0x60(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x5e3a
movups (%rbx), %xmm0
movups %xmm0, (%r15)
movq 0x10(%rsp), %rax
movq %rax, 0x68(%rsp)
movq %rbx, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq %r13, 0x80(%rsp)
movq 0x30(%rsp), %rax
cmpq %rbp, %rax
je 0x5e80
movq %rax, 0x80(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x90(%rsp)
jmp 0x5e89
movups (%rbp), %xmm0
movups %xmm0, (%r13)
movq 0x38(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %rbp, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0xb1e4
movq 0x80(%rsp), %rdi
cmpq %r13, %rdi
je 0x5ed5
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0x5eec
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5f03
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5f1a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
addq $0x10, %r12
cmpq 0x58(%rsp), %r12
jne 0x5deb
leaq 0x6a3a(%rip), %rdx      # 0xc96a
leaq 0x60(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x8118
cmpw $0x3, 0x1e6(%rsp)
jne 0x6257
movq 0x60(%rsp), %rdi
movq 0x1e0(%rsp), %rax
andq %r14, %rax
movl 0x1d8(%rsp), %ecx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %ebx, %ebx
cmpq %rcx, %rdi
je 0x622a
cmpw $0x4, 0x1e(%rdi)
jne 0x622a
andq 0x18(%rdi), %r14
addq $0x10, %rdi
callq 0xab0a
movq %rax, 0x28(%rsp)
cmpq %r14, %rax
je 0x622a
leaq 0x100(%rsp), %r13
leaq 0x18(%rsp), %rbx
xorl %r15d, %r15d
leaq 0x8(%rsp), %r12
leaq 0x60(%rsp), %rbp
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %r15, 0x68(%rsp)
movb %r15b, 0x70(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %r15, 0x88(%rsp)
movb %r15b, 0x90(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %r15, 0xa8(%rsp)
movb %r15b, 0xb0(%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %r15, 0xc8(%rsp)
movb %r15b, 0xd0(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq %r15, 0xe8(%rsp)
movb %r15b, 0xf0(%rsp)
movq %r15, 0x10(%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq %r12, %rdi
movq %r14, %rsi
leaq 0x8db5(%rip), %rdx      # 0xee1c
callq 0x57db
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x608e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x688c(%rip), %rdx      # 0xc927
callq 0x57db
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x60c7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x689d(%rip), %rdx      # 0xc971
callq 0x57db
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6100
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x6869(%rip), %rdx      # 0xc976
callq 0x57db
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6139
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x683d(%rip), %rdx      # 0xc983
callq 0x57db
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6172
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r14, %rdi
movq %r13, %rsi
callq 0x5c03
testl %eax, %eax
jne 0x624b
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x81a8
movq %rbp, %rdi
callq 0x81d8
addq $0x10, %r14
cmpq 0x28(%rsp), %r14
jne 0x5fba
xorl %ebx, %ebx
jmp 0x622a
leaq 0x6d8d(%rip), %r14      # 0xcf41
movq %r14, %rdi
callq 0x3150
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3310
leaq 0x68(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x3440
leaq 0xe0d8(%rip), %rdi      # 0x142b8
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x3330
movq (%rbx), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6207
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0xddca(%rip), %rsi      # 0x13fd8
leaq 0x60(%rsp), %rdi
callq 0x3170
leaq 0xd0(%rsp), %rdi
callq 0x3110
movl $0x1, %ebx
leaq 0x1d8(%rsp), %rdi
callq 0x8052
movl %ebx, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x60(%rsp), %rdi
callq 0x81d8
jmp 0x6225
leaq 0x6d48(%rip), %rdi      # 0xcfa6
leaq 0x6d4c(%rip), %rsi      # 0xcfb1
leaq 0x8a94(%rip), %rcx      # 0xed00
movl $0x4ee, %edx            # imm = 0x4EE
callq 0x31a0
jmp 0x6299
jmp 0x6299
jmp 0x62e0
jmp 0x6299
jmp 0x6299
jmp 0x628a
jmp 0x628a
jmp 0x628a
jmp 0x628a
jmp 0x628a
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x81d8
jmp 0x6301
movq %rax, %r14
jmp 0x6301
movq %rax, %r14
jmp 0x62c7
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x8172
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x62c7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6301
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x6301
movq %rax, %r14
movq 0xdcee(%rip), %rsi      # 0x13fd8
leaq 0x60(%rsp), %rdi
callq 0x3170
leaq 0xd0(%rsp), %rdi
callq 0x3110
leaq 0x1d8(%rsp), %rdi
callq 0x8052
movq %r14, %rdi
callq 0x34a0