// File: /workspace/github_c_makefile_star2_O1/wtarreau[P]httpterm/httpterm.c
// Function: process_runnable_tasks
int process_runnable_tasks() {
  int next_time;
  struct task *t, *tnext;

  next_time = TIME_ETERNITY; /* set the timer to wait eternally first */

  /* look for expired tasks and add them to the run queue.
   */
  tnext = ((struct task *)LIST_HEAD(wait_queue[0]))->next;
  while ((t = tnext) != LIST_HEAD(wait_queue[0])) { /* we haven't looped ? */
      tnext = t->next;
      if (t->state & TASK_RUNNING)
	  continue;
      
      if (tv_iseternity(&t->expire))
	  continue;

      /* wakeup expired entries. It doesn't matter if they are
       * already running because of a previous event
       */
      if (tv_cmp_ms(&t->expire, &now) <= 0) {
	  task_wakeup(&rq, t);
      }
      else {
	  /* first non-runnable task. Use its expiration date as an upper bound */
	  int temp_time = tv_remain(&now, &t->expire);
	  if (temp_time)
	      next_time = temp_time;
	  break;
      }
  }

  /* process each task in the run queue now. Each task may be deleted
   * since we only use the run queue's head. Note that any task can be
   * woken up by any other task and it will be processed immediately
   * after as it will be queued on the run queue's head.
   */
  while ((t = rq) != NULL) {
      int temp_time;

      task_sleep(&rq, t);
      temp_time = t->process(t);
      next_time = MINTIME(temp_time, next_time);
  }
  return next_time;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x735b(%rip), %r14      # 0xd240
leaq 0x7354(%rip), %r13      # 0xd240
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %r13, %r14
je 0x5fe5
movq 0x7486(%rip), %rbx      # 0xd388
movq %r14, %rbp
movq (%r14), %r14
movl 0x20(%rbp), %r12d
testb $0x1, %r12b
jne 0x5f46
movq 0x28(%rbp), %rdx
testq %rdx, %rdx
jne 0x5f22
cmpq $0x0, 0x30(%rbp)
je 0x5f46
movq %rdx, 0x8(%rsp)
leaq 0x28(%rbp), %rdi
movq %rdi, 0x10(%rsp)
leaq 0x74c9(%rip), %rsi      # 0xd400
callq 0x6044
testl %eax, %eax
jg 0x5f67
cmpl $0x1, %r12d
jne 0x5f4b
movq %rbx, %rbp
jmp 0x5f5d
movq %rbx, 0x10(%rbp)
movl $0x1, 0x20(%rbp)
movq %rbp, 0x742b(%rip)      # 0xd388
movq %rbp, %rbx
cmpq %r13, %r14
jne 0x5f02
jmp 0x5fe5
leaq 0x7492(%rip), %rdi      # 0xd400
movq 0x10(%rsp), %rsi
callq 0x6044
xorl %r15d, %r15d
testl %eax, %eax
js 0x5f83
xorl %edx, %edx
jmp 0x5fdc
movq 0x8(%rsp), %rax
subq 0x7471(%rip), %rax      # 0xd400
imulq $0x3e8, %rax, %rsi      # imm = 0x3E8
movq 0x30(%rbp), %rdx
movq 0x7467(%rip), %rax      # 0xd408
movq %rdx, %rcx
subq %rax, %rcx
jle 0x5fbb
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
movq %rcx, %rax
imulq %rdx
jmp 0x5fcb
subq %rdx, %rax
movabsq $-0x20c49ba5e353f7cf, %rcx # imm = 0xDF3B645A1CAC0831
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
addq %rsi, %rdx
cmpl $0x1, %edx
sbbl %r15d, %r15d
orl %edx, %r15d
movq 0x739c(%rip), %rdi      # 0xd388
testq %rdi, %rdi
je 0x6032
cmpl $0x1, 0x20(%rdi)
jne 0x6009
movq 0x10(%rdi), %rax
movq %rax, 0x7386(%rip)      # 0xd388
movl $0x0, 0x20(%rdi)
callq *0x38(%rdi)
movl %eax, %ecx
cmpl %eax, %r15d
cmovll %r15d, %eax
testl %ecx, %ecx
cmovsl %r15d, %eax
testl %r15d, %r15d
cmovsl %ecx, %eax
movq 0x7360(%rip), %rdi      # 0xd388
movl %eax, %r15d
testq %rdi, %rdi
jne 0x5ff1
jmp 0x6035
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq