// File: /workspace/github_cpp_makefile_star2_O3/tdv[P]boss/boss/src/service_registry/service_registry.cpp
// Function: Boss::ServiceRegistry::AddService(Boss::IServiceInfo*)
RetCode BOSS_CALL ServiceRegistry::AddService(IServiceInfo *service)
  {
    try
    {
      std::lock_guard<std::recursive_mutex> Lock(Mtx);
      if (!service)
        return Status::InvalidArgument;
      IServiceInfoPtr Info(service);
      ServiceId SrvId = 0;
      RetCode Res = Info->GetServiceId(&SrvId);
      if (Res != Status::Ok)
        return Res;
      RefObjPtr<IEnum> ClassIdsEnum;
      Res = Info->GetClassIds(ClassIdsEnum.GetPPtr());
      if (Res != Status::Ok)
        return Res;
      EnumHelper<IEntityId> ClassIdsEnumHelper(ClassIdsEnum);
      typedef std::vector<ClassId> ClassIdPool;
      ClassIdPool ClassIds;
      if (ClassIdsEnum->Reset() != Status::Ok)
        return Status::Fail;
      for (auto i = ClassIdsEnumHelper.First() ; i.Get() ; i = ClassIdsEnumHelper.Next())
      {
        ClassId ClsId = 0;
        Res = i->GetId(&ClsId);
        if (Res != Status::Ok)
          return Res;
        if (Services.find(ClsId) != std::end(Services))
          return Status::Fail;
        ClassIds.push_back(ClsId);
      }
      auto Pred = [&] (decltype(*ServicePool::const_iterator()) &info)
        {
          ServiceId Id = 0;
          return info.second->GetServiceId(&Id) == Status::Ok && Id == SrvId;
        };
      bool Exists = false;
      for (auto Iter : Services)
      {
        if (Pred(Iter))
        {
          Exists = true;
          break;
        }
      }
      if (Exists)
        return Status::AlreadyExists;
      for (auto const &i : ClassIds)
        Services[i] = Info;
    }
    catch (...)
    {
      return Status::Fail;
    }
    return Status::Ok;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x28(%rdi), %rbx
movq %rbx, %rdi
callq 0x19620
testl %eax, %eax
jne 0x1c619
testq %r15, %r15
je 0x1c59d
movq %r15, 0x18(%rsp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
leaq 0x2c(%rsp), %rsi
movl $0x0, (%rsi)
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, %ebp
testl %eax, %eax
jne 0x1c5ec
leaq 0x20(%rsp), %rsi
movq $0x0, (%rsi)
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, %ebp
testl %eax, %eax
jne 0x1c5dc
movq 0x20(%rsp), %rdi
movq %rdi, 0x8(%rsp)
testq %rdi, %rdi
je 0x1c3ff
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1daa6
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1c41e
movq (%rdi), %rax
callq *0x18(%rax)
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl $0x2, %ebp
testl %eax, %eax
jne 0x1c5ba
leaq 0x10(%rsp), %rdi
callq 0x1eb34
movq %rsp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x1db86
movq (%rsp), %r15
testq %r15, %r15
je 0x1c4ee
leaq 0x50(%r14), %r12
movq %rsp, %r13
movl $0x0, (%rsp)
movq (%r15), %rax
movq %r15, %rdi
movq %r13, %rsi
callq *0x28(%rax)
movl %eax, %ebp
testl %eax, %eax
jne 0x1c5b1
movq %r12, %rdi
movq %r13, %rsi
callq 0x1eac6
testq %rax, %rax
jne 0x1c5ac
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x1c4c2
movl (%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x1c4cf
leaq 0x30(%rsp), %rdi
movq %r13, %rdx
callq 0x1ece4
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0x1db86
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movq (%rsp), %r15
testq %r15, %r15
jne 0x1c475
leaq 0x50(%r14), %rax
movq %rax, 0x50(%rsp)
addq $0x60, %r14
xorl %r15d, %r15d
movq %rsp, %r12
movq (%r14), %r14
testq %r14, %r14
je 0x1c555
movq 0x10(%r14), %r13
testq %r13, %r13
je 0x1c51c
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
movl $0x0, (%rsp)
movq (%r13), %rax
movq %r13, %rdi
movq %r12, %rsi
callq *0x28(%rax)
testl %eax, %eax
je 0x1c538
xorl %ebp, %ebp
jmp 0x1c546
movl 0x2c(%rsp), %eax
cmpl %eax, (%rsp)
sete %bpl
orb %bpl, %r15b
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
testb %bpl, %bpl
je 0x1c501
movl $0x4, %ebp
testb $0x1, %r15b
jne 0x1c5ba
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %r15
cmpq %r15, %r14
je 0x1c615
leaq 0x18(%rsp), %r12
movq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x1ee18
movq %rax, %rdi
movq %r12, %rsi
callq 0x1dc94
addq $0x4, %r14
cmpq %r15, %r14
jne 0x1c578
xorl %ebp, %ebp
jmp 0x1c5ba
movq %rbx, %rdi
callq 0x19680
movl $0x5, %ebp
jmp 0x1c604
movl $0x2, %ebp
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movq 0x30(%rsp), %r14
testq %r14, %r14
je 0x1c5cc
movq %r14, %rdi
callq 0x29fe0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1c5dc
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1c5ec
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1c5fc
movq (%rdi), %rax
callq *0x18(%rax)
movq %rbx, %rdi
callq 0x19680
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x1c5bf
movl %eax, %edi
callq 0x1b2b1
jmp 0x1c6d3
jmp 0x1c6d3
jmp 0x1c6d3
jmp 0x1c673
jmp 0x1c69b
jmp 0x1c69b
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1c648
movq (%rdi), %rax
callq *0x18(%rax)
movq $0x0, 0x8(%rsp)
jmp 0x1c6bd
jmp 0x1c6d3
jmp 0x1c6d3
jmp 0x1c69b
jmp 0x1c68b
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1c68e
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x1c68e
jmp 0x1c6d3
jmp 0x1c68b
movq %rax, %r14
jmp 0x1c6bd
jmp 0x1c6d3
movq %rax, %r14
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
jmp 0x1c69e
jmp 0x1c6d3
movq %rax, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
jmp 0x1c69e
jmp 0x1c6d3
movq %rax, %r14
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6ad
callq 0x29fe0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6bd
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6de
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x1c6de
jmp 0x1c6d3
jmp 0x1c6d3
movq %rax, %rdi
callq 0x1e4f5
movq %rax, %r14
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6f5
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x1c6f5
jmp 0x1c6d3
movq %rax, %r14
movq %rbx, %rdi
callq 0x19680
jmp 0x1c702
movq %rax, %r14
movq %r14, %rdi
callq 0x2a440
callq 0x2a4b0
movl $0x2, %ebp
jmp 0x1c604
nop