// File: /workspace/github_cpp_makefile_star2_O2/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 0x1e168
testq %r15, %r15
je 0x1c46f
movq %r15, 0x8(%rsp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
leaq 0x3c(%rsp), %rsi
andl $0x0, (%rsi)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, %ebp
testl %eax, %eax
jne 0x1c5d3
leaq 0x28(%rsp), %rsi
andq $0x0, (%rsi)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, %ebp
testl %eax, %eax
jne 0x1c5c9
movq 0x28(%rsp), %rdi
movq %rdi, 0x30(%rsp)
testq %rdi, %rdi
je 0x1c431
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1d538
leaq 0x30(%rsp), %rdi
callq 0x1d5ae
andq $0x0, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
testl %eax, %eax
je 0x1c477
pushq $0x2
popq %rbp
jmp 0x1c5b5
pushq $0x5
popq %rbp
jmp 0x1c5dd
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1d5be
leaq 0x50(%r14), %r15
movq %rsp, %r12
pushq $0x2
popq %rbp
movq 0x10(%rsp), %r13
testq %r13, %r13
je 0x1c503
andl $0x0, (%rsp)
movq (%r13), %rax
movq %r13, %rdi
movq %r12, %rsi
callq *0x28(%rax)
testl %eax, %eax
jne 0x1c501
movq %r15, %rdi
movq %r12, %rsi
callq 0x1e76a
testq %rax, %rax
jne 0x1c503
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x1d604
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1d622
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1c4e9
movq (%rdi), %rax
callq *0x18(%rax)
movq (%rsp), %rax
movq %rax, 0x10(%rsp)
andq $0x0, (%rsp)
movq %r12, %rdi
callq 0x1d6f8
jmp 0x1c490
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
callq 0x1d6f8
testq %r13, %r13
jne 0x1c5b5
addq $0x60, %r14
xorl %ebp, %ebp
movq %rsp, %r13
movq (%r14), %r14
testq %r14, %r14
je 0x1c576
movl 0x8(%r14), %eax
movl %eax, 0x10(%rsp)
movq 0x10(%r14), %rdi
movq %rdi, 0x18(%rsp)
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x18(%rsp), %rdi
andl $0x0, (%rsp)
movq (%rdi), %rax
movq %r13, %rsi
callq *0x28(%rax)
testl %eax, %eax
je 0x1c559
xorl %r12d, %r12d
jmp 0x1c567
movl 0x3c(%rsp), %eax
cmpl %eax, (%rsp)
sete %r12b
orb %r12b, %bpl
leaq 0x18(%rsp), %rdi
callq 0x1d74c
testb %r12b, %r12b
je 0x1c51f
testb $0x1, %bpl
je 0x1c583
pushq $0x4
jmp 0x1c469
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r13
leaq 0x8(%rsp), %r12
cmpq %r13, %r14
je 0x1c5b3
movq %r15, %rdi
movq %r14, %rsi
callq 0x1eb5a
movq %rax, %rdi
movq %r12, %rsi
callq 0x1d708
addq $0x4, %r14
jmp 0x1c592
xorl %ebp, %ebp
leaq 0x40(%rsp), %rdi
callq 0x1e82a
leaq 0x20(%rsp), %rdi
callq 0x1d5ae
leaq 0x28(%rsp), %rdi
callq 0x1d73c
leaq 0x8(%rsp), %rdi
callq 0x1d74c
movq %rbx, %rdi
callq 0x19680
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c62d
jmp 0x1c624
jmp 0x1c62d
movq %rax, %r14
leaq 0x30(%rsp), %rdi
jmp 0x1c658
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x1d74c
jmp 0x1c649
jmp 0x1c62d
movq %rax, %r14
movq %rsp, %rdi
callq 0x1d6f8
jmp 0x1c63f
movq %rax, %r14
jmp 0x1c65d
jmp 0x1c63c
jmp 0x1c63c
movq %rax, %r14
jmp 0x1c649
movq %rax, %r14
jmp 0x1c667
movq %rax, %r14
jmp 0x1c671
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x1d6f8
leaq 0x40(%rsp), %rdi
callq 0x1e82a
leaq 0x20(%rsp), %rdi
callq 0x1d5ae
leaq 0x28(%rsp), %rdi
callq 0x1d73c
leaq 0x8(%rsp), %rdi
callq 0x1d74c
movq %rbx, %rdi
callq 0x19680
movq %r14, %rdi
callq 0x28cb0
callq 0x28d20
pushq $0x2
popq %rbp
jmp 0x1c5e5
movq %rax, %r14
jmp 0x1c679
nop