// File: /workspace/github_cpp_makefile_star2_O3/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 0x8506
movq (%rbx), %rax
leaq 0x60(%rsp), %rsi
movq %rax, (%rsi)
movq %rax, 0x8(%rsi)
movq %r14, %rdi
callq 0x9096
cmpl $0x0, 0x228(%rsp)
je 0x6348
leaq 0x60(%rsp), %rdi
callq 0x3360
leaq 0x6657(%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 0x664f(%rip), %rsi      # 0xc966
movl $0x3, %edx
movq %rax, %rdi
callq 0x3310
movl 0x228(%rsp), %eax
cmpq $0x11, %rax
ja 0x67a3
leaq 0x8c08(%rip), %rcx      # 0xef44
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x67aa
leaq 0x6476(%rip), %rdx      # 0xc7c5
leaq 0x60(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x868e
cmpw $0x3, 0x1e6(%rsp)
jne 0x684d
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 0x651f
cmpw $0x4, 0x1e(%rdi)
jne 0x651f
movq 0x18(%rdi), %r12
andq %r14, %r12
addq $0x10, %rdi
callq 0xa89a
movq %rax, 0x58(%rsp)
cmpq %r12, %rax
je 0x651f
leaq 0x70(%rsp), %r15
leaq 0x18(%rsp), %rbx
leaq 0x90(%rsp), %r13
leaq 0x40(%rsp), %rbp
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
leaq 0x8a2c(%rip), %rdx      # 0xee1c
callq 0x5dd1
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
leaq 0x6523(%rip), %rdx      # 0xc927
callq 0x5dd1
movq %r15, 0x60(%rsp)
movq 0x8(%rsp), %rax
cmpq %rbx, %rax
je 0x6429
movq %rax, 0x60(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x6430
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 0x6476
movq %rax, 0x80(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x90(%rsp)
jmp 0x647f
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 0xaf70
movq 0x80(%rsp), %rdi
cmpq %r13, %rdi
je 0x64cb
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0x64e2
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x64f9
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6510
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
addq $0x10, %r12
cmpq 0x58(%rsp), %r12
jne 0x63e1
leaq 0x6444(%rip), %rdx      # 0xc96a
leaq 0x60(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x868e
cmpw $0x3, 0x1e6(%rsp)
jne 0x684d
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 0x6820
cmpw $0x4, 0x1e(%rdi)
jne 0x6820
andq 0x18(%rdi), %r14
addq $0x10, %rdi
callq 0xa89a
movq %rax, 0x28(%rsp)
cmpq %r14, %rax
je 0x6820
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 0x87bf(%rip), %rdx      # 0xee1c
callq 0x5dd1
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6684
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x6296(%rip), %rdx      # 0xc927
callq 0x5dd1
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x66bd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x62a7(%rip), %rdx      # 0xc971
callq 0x5dd1
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x66f6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x6273(%rip), %rdx      # 0xc976
callq 0x5dd1
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x672f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
movq %r14, %rsi
leaq 0x6247(%rip), %rdx      # 0xc983
callq 0x5dd1
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x3330
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6768
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r14, %rdi
movq %r13, %rsi
callq 0x61f9
testl %eax, %eax
jne 0x6841
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x871e
movq %rbp, %rdi
callq 0x874e
addq $0x10, %r14
cmpq 0x28(%rsp), %r14
jne 0x65b0
xorl %ebx, %ebx
jmp 0x6820
leaq 0x6797(%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 0xdae2(%rip), %rdi      # 0x142b8
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x3330
movq (%rbx), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x67fd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0xd7d4(%rip), %rsi      # 0x13fd8
leaq 0x60(%rsp), %rdi
callq 0x3170
leaq 0xd0(%rsp), %rdi
callq 0x3110
movl $0x1, %ebx
leaq 0x1d8(%rsp), %rdi
callq 0x85bc
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 0x874e
jmp 0x681b
leaq 0x6752(%rip), %rdi      # 0xcfa6
leaq 0x6756(%rip), %rsi      # 0xcfb1
leaq 0x849e(%rip), %rcx      # 0xed00
movl $0x4ee, %edx            # imm = 0x4EE
callq 0x31a0
jmp 0x688f
jmp 0x688f
jmp 0x68d6
jmp 0x688f
jmp 0x688f
jmp 0x6880
jmp 0x6880
jmp 0x6880
jmp 0x6880
jmp 0x6880
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x874e
jmp 0x68f7
movq %rax, %r14
jmp 0x68f7
movq %rax, %r14
jmp 0x68bd
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x86e8
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x68bd
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x68f7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x68f7
movq %rax, %r14
movq 0xd6f8(%rip), %rsi      # 0x13fd8
leaq 0x60(%rsp), %rdi
callq 0x3170
leaq 0xd0(%rsp), %rdi
callq 0x3110
leaq 0x1d8(%rsp), %rdi
callq 0x85bc
movq %r14, %rdi
callq 0x34a0