// File: mh0fm4[P]SCDC/src/components/transport/transport.cc
// Function: scdc_transport_connection_pool::acquire_entry(bool)
scdc_transport_connection_pool_entry_t *scdc_transport_connection_pool::acquire_entry(bool async)
{
  SCDC_TRACE("acquire_entry:");

  pthread_mutex_lock(&pool->lock);

  while (pool->run && pool->total_entries.size() >= static_cast<unsigned>(max_connections)
#if THREAD_POOLING
    && pool->free_entries.size() <= 0
#endif
    ) pthread_cond_wait(&pool->cond, &pool->lock);

  if (!pool->run)
  {
    SCDC_TRACE("acquire_entry: stopped running");
    pthread_mutex_unlock(&pool->lock);
    return 0;
  }

#if !THREAD_POOLING
  /* cleanup dead entries */
  while (pool->dead_entries.size() > 0)
  {
    scdc_transport_connection_pool_entry_t *entry = pool->dead_entries.front();
    pool->dead_entries.pop_front();
    destroy_entry(entry);
  }
#endif

  scdc_transport_connection_pool_entry_t *entry;

#if THREAD_POOLING
  if (pool->free_entries.size() > 0)
  {
    entry = pool->free_entries.front();
    pool->free_entries.pop_front();

  } else
#endif
  {
    entry = create_entry(async);
    pool->total_entries.push_back(entry);
  }

  ++pool->naquired_entries;

  pthread_mutex_unlock(&pool->lock);

  SCDC_TRACE("acquire_entry: return: '" << entry << "'");

  return entry;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x97eee
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xc9f0
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
xorl %eax, %eax
testb $0x1, 0x58(%rcx)
movb %al, -0x29(%rbp)
je 0x97f58
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x80, %rdi
callq 0x99b90
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl %eax, %eax
movl %eax, %edx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x29(%rbp)
jb 0x97f58
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x98, %rdi
callq 0x99b90
cmpq $0x0, %rax
setbe %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x97f61
jmp 0x97f78
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x28, %rdi
movq 0x10(%rax), %rsi
callq 0xca50
jmp 0x97efb
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
testb $0x1, 0x58(%rax)
jne 0x97fa4
jmp 0x97f88
jmp 0x97f8a
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xc4c0
movq $0x0, -0x8(%rbp)
jmp 0x98049
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x98, %rdi
callq 0x99b90
cmpq $0x0, %rax
jbe 0x97ff2
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x98, %rdi
callq 0x99bc0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq 0x10(%rax), %rdi
addq $0x98, %rdi
callq 0x99bf0
jmp 0x98022
movq -0x28(%rbp), %rdi
movb -0x11(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x982c0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq 0x10(%rax), %rdi
addq $0x80, %rdi
leaq -0x20(%rbp), %rsi
callq 0x99c20
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
movq 0x78(%rcx), %rdx
addq $0x1, %rdx
movq %rdx, 0x78(%rcx)
movq 0x10(%rax), %rdi
callq 0xc4c0
jmp 0x98041
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)