// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x28(%rdi), %rbx
movq %rbx, %rdi
callq 0x1b620
testl %eax, %eax
jne 0x1e78d
testq %r15, %r15
je 0x1e573
movq %r15, 0x18(%rsp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
leaq 0x3c(%rsp), %rsi
movl $0x0, (%rsi)
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movl %eax, %ebp
testl %eax, %eax
jne 0x1e561
leaq 0x30(%rsp), %rsi
movq $0x0, (%rsi)
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, %ebp
testl %eax, %eax
jne 0x1e551
movq 0x30(%rsp), %rdi
movq %rdi, 0x28(%rsp)
testq %rdi, %rdi
movq %rbx, 0x20(%rsp)
je 0x1e4e6
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1fe0e
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1e505
movq (%rdi), %rax
callq *0x18(%rax)
xorl %eax, %eax
movq %rax, 0x28(%rsp)
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl $0x2, %ebp
testl %eax, %eax
je 0x1e591
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1e53c
callq 0x2c860
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
movq 0x20(%rsp), %rbx
je 0x1e551
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1e561
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1e578
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x1e578
movl $0x5, %ebp
movq %rbx, %rdi
callq 0x1b680
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rdi
callq 0x20f1c
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1feee
movq 0x8(%rsp), %r15
testq %r15, %r15
sete %r13b
je 0x1e6b9
leaq 0x8(%rsp), %rbx
movl $0x0, 0x8(%rsp)
movq (%r15), %rax
movq %r15, %rdi
movq %rbx, %rsi
callq *0x28(%rax)
testl %eax, %eax
je 0x1e610
xorl %r12d, %r12d
movl %eax, %ebp
testb %r12b, %r12b
je 0x1e6b9
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x1feee
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
movq 0x8(%rsp), %r15
testq %r15, %r15
sete %r13b
jne 0x1e5c1
jmp 0x1e6b9
movl 0x8(%rsp), %ecx
movq 0x50(%r14), %rdi
movq 0x58(%r14), %r8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x1e66d
movq (%rdx), %r9
movq %rdx, %rax
cmpl 0x8(%r9), %ecx
je 0x1e66d
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x1e66b
movl 0x8(%r9), %edi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x1e66d
movq %r10, %rax
cmpl %edi, %ecx
jne 0x1e641
jmp 0x1e66d
xorl %eax, %eax
testq %rax, %rax
je 0x1e685
cmpq $0x0, (%rax)
je 0x1e685
movl $0x2, %ebp
xorl %r12d, %r12d
jmp 0x1e5de
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x1e6a4
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
movb $0x1, %r12b
jmp 0x1e5de
movb $0x1, %r12b
leaq 0x40(%rsp), %rdi
movq %rbx, %rdx
callq 0x210ba
jmp 0x1e5de
testb $0x1, %r13b
jne 0x1e6d2
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
testb $0x1, %r13b
je 0x1e52d
leaq 0x50(%r14), %rax
movq %rax, 0x60(%rsp)
addq $0x60, %r14
xorl %r15d, %r15d
movq (%r14), %r14
testq %r14, %r14
je 0x1e73e
movq 0x10(%r14), %r13
testq %r13, %r13
je 0x1e6fd
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
movl $0x0, 0x8(%rsp)
movq (%r13), %rax
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq *0x28(%rax)
movl %eax, %ebp
movl 0x8(%rsp), %r12d
movl 0x3c(%rsp), %ebx
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
xorl %ebx, %r12d
orl %r12d, %ebp
movzbl %r15b, %r15d
movl $0x1, %eax
cmovel %eax, %r15d
jne 0x1e6e2
movl $0x4, %ebp
testb $0x1, %r15b
jne 0x1e52d
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r15
xorl %ebp, %ebp
cmpq %r15, %r14
je 0x1e52d
leaq 0x18(%rsp), %r12
movq 0x60(%rsp), %rdi
movq %r14, %rsi
callq 0x211ee
movq %rax, %rdi
movq %r12, %rsi
callq 0x1fffc
addq $0x4, %r14
cmpq %r15, %r14
jne 0x1e767
jmp 0x1e52d
movl %eax, %edi
callq 0x1d32d
jmp 0x1e81f
jmp 0x1e81f
jmp 0x1e81f
jmp 0x1e7d3
jmp 0x1e827
jmp 0x1e827
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1e7bc
movq (%rdi), %rax
callq *0x18(%rax)
movq $0x0, 0x28(%rsp)
jmp 0x1e852
jmp 0x1e81f
jmp 0x1e81f
movq %rbx, 0x20(%rsp)
movq %rax, %r14
jmp 0x1e852
jmp 0x1e827
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1e7ed
movq (%rdi), %rax
callq *0x18(%rax)
movq $0x0, 0x8(%rsp)
jmp 0x1e7ff
jmp 0x1e81f
jmp 0x1e7fc
movq %rax, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x18(%rax)
jmp 0x1e82a
jmp 0x1e81f
jmp 0x1e81f
movq %rax, %r14
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
jmp 0x1e82a
jmp 0x1e81f
movq %rax, %rdi
callq 0x2087b
movq %rax, %r14
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1e839
callq 0x2c860
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1e849
movq (%rdi), %rax
callq *0x18(%rax)
movq $0x0, 0x10(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1e870
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x1e870
jmp 0x1e81f
jmp 0x1e81f
movq %rbx, 0x20(%rsp)
movq %rax, %r14
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1e880
movq (%rdi), %rax
callq *0x18(%rax)
movq $0x0, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x1b680
jmp 0x1e8a4
jmp 0x1e81f
movq %rbx, 0x20(%rsp)
movq %rax, %r14
jmp 0x1e889
movq %rax, %r14
movq %r14, %rdi
callq 0x2ccc0
callq 0x2cd30
movl $0x2, %ebp
jmp 0x1e580
nop