// File: /workspace/github_c_makefile_star2_O0/bhk[P]tooltree/monoglot/./xpio_c.c
// Function: XPQueue_wakeChildWaiters
static int
XPQueue_wakeChildWaiters(XPQueue *me, lua_State *L, int ndxReady, int ndxWaiters)
{
   int nTop = lua_gettop(L);
   int numReady = lengthOf(L, ndxReady);
   int numWaiting = 0;

   ndxReady = lua_absindex(L, ndxReady);
   ndxWaiters = lua_absindex(L, ndxWaiters);

   // enumerate waiters (process -> task)
   lua_pushvalue(L, ndxWaiters);
   for (lua_pushnil(L); lua_next(L, -2) != 0; lua_pop(L, 1)) {
      // xpproc is at -2;  task is at -1

      if (xpproc_isExited(L, -2)) {
         // put task in ready[]
         lua_pushvalue(L, -1);
         lua_rawseti(L, ndxReady, ++numReady);

         // mark task as not pending
         lua_pushnil(L);
         lua_setfield(L, -2, "_dequeue");

         // remove task from childWaiters
         lua_pushvalue(L, -2);
         lua_pushnil(L);
         lua_rawset(L, ndxWaiters);
      } else {
         ++numWaiting;
      }
      //printf("... wcw loop: %d, %d\n", numReady, numWaiting);
   }

   //printf("wakeChildWaiters: numWaiting=%d numReady=%d\n", numWaiting, numReady);

   {
      //int cnt = 0;
      lua_pushvalue(L, ndxWaiters);
      for (lua_pushnil(L); lua_next(L, -2) != 0; lua_pop(L, 1)) {
         //++cnt;
      }
      //printf("wakeChildWaiters: %d waiters left\n", cnt);
   }

   lua_settop(L, nTop);
   return numWaiting;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movl %edx, 0x14(%rsp)
movl %ecx, 0x10(%rsp)
movq 0x18(%rsp), %rdi
callq 0x7470
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x5170
movl %eax, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x7410
movl %eax, 0x14(%rsp)
movq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0x7410
movl %eax, 0x10(%rsp)
movq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0x7930
movq 0x18(%rsp), %rdi
callq 0x8440
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x9e50
cmpl $0x0, %eax
je 0x5f08
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6350
cmpl $0x0, %eax
je 0x5ee7
movq 0x18(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7930
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
movl 0x8(%rsp), %edx
addl $0x1, %edx
movl %edx, 0x8(%rsp)
callq 0x92d0
movq 0x18(%rsp), %rdi
callq 0x8440
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x22361(%rip), %rdx     # 0x2821a
callq 0x9120
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7930
movq 0x18(%rsp), %rdi
callq 0x8440
movq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0x91e0
jmp 0x5ef2
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x5ef4
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x74a0
jmp 0x5e4a
movq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0x7930
movq 0x18(%rsp), %rdi
callq 0x8440
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x9e50
cmpl $0x0, %eax
je 0x5f47
jmp 0x5f36
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x74a0
jmp 0x5f20
movq 0x18(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x74a0
movl 0x4(%rsp), %eax
addq $0x28, %rsp
retq
nop