user: 请从给定的汇编指令推导出C源代码:

```asm
<check_patients_waiting>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r12
  mov    %esi,%ebp
  lea    0x24(%rdi),%r13d
  test   %esi,%esi
  jne    L0
L23:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L6:
  sub    $0x1,%eax
  mov    %eax,0x0(%r13d)
  movl   $0x3,0x8(%ebx)
  addl   $0x3,0x4(%ebx)
  lea    0x2c(%r12),%edi
  mov    %rbx,%rsi
  call   <removeList@plt>
  lea    0x38(%r12),%edi
  mov    %rbx,%rsi
  call   <addList@plt>
L5:
  mov    0x8(%ebp),%rsi
  mov    %esi,%ebp
  test   %esi,%esi
  je     L23
L0:
  mov    0x0(%r13d),%eax
  mov    (%rsi),%rbx
  test   %eax,%eax
  jg     L6
  addl   $0x1,0x4(%ebx)
  jmp    L5
```

assistant: ```c
void check_patients_waiting(struct Village *village, struct List *list) {
  int i;
  struct Patient *p;
  void *__cil_tmp5;
  unsigned int __cil_tmp6;
  unsigned int __cil_tmp7;
  unsigned int __cil_tmp8;
  unsigned int __cil_tmp9;
  unsigned int __cil_tmp10;
  unsigned int __cil_tmp11;
  unsigned int __cil_tmp12;
  unsigned int __cil_tmp13;
  unsigned int __cil_tmp14;
  unsigned int __cil_tmp15;
  unsigned int __cil_tmp16;
  int __cil_tmp17;
  unsigned int __cil_tmp18;
  unsigned int __cil_tmp19;
  unsigned int __cil_tmp20;
  unsigned int __cil_tmp21;
  unsigned int __cil_tmp22;
  unsigned int __cil_tmp23;
  int __cil_tmp24;
  unsigned int __cil_tmp25;
  unsigned int __cil_tmp26;
  int __cil_tmp27;
  unsigned int __cil_tmp28;
  unsigned int __cil_tmp29;
  unsigned int __cil_tmp30;
  struct List *__cil_tmp31;
  unsigned int __cil_tmp32;
  unsigned int __cil_tmp33;
  unsigned int __cil_tmp34;
  struct List *__cil_tmp35;
  unsigned int __cil_tmp36;
  unsigned int __cil_tmp37;
  unsigned int __cil_tmp38;
  unsigned int __cil_tmp39;
  int __cil_tmp40;
  unsigned int __cil_tmp41;
  unsigned int __cil_tmp42;
  int *mem_43;
  struct Patient **mem_44;
  int *mem_45;
  int *mem_46;
  int *mem_47;
  int *mem_48;
  int *mem_49;
  int *mem_50;
  int *mem_51;
  int *mem_52;
  struct List **mem_53;
  {
    {
      while (1) {
      while_5_continue:;
        {
          __cil_tmp5 = (void *)0;
          __cil_tmp6 = (unsigned int)__cil_tmp5;
          __cil_tmp7 = (unsigned int)list;
          if (__cil_tmp7 != __cil_tmp6) {
          } else {
            goto while_5_break;
          }
        }
        __cil_tmp8 = 32 + 4;
        __cil_tmp9 = (unsigned int)village;
        __cil_tmp10 = __cil_tmp9 + __cil_tmp8;
        mem_43 = (int *)__cil_tmp10;
        i = *mem_43;
        mem_44 = (struct Patient **)list;
        p = *mem_44;
        if (i > 0) {
          {
            __cil_tmp11 = 32 + 4;
            __cil_tmp12 = (unsigned int)village;
            __cil_tmp13 = __cil_tmp12 + __cil_tmp11;
            __cil_tmp14 = 32 + 4;
            __cil_tmp15 = (unsigned int)village;
            __cil_tmp16 = __cil_tmp15 + __cil_tmp14;
            mem_45 = (int *)__cil_tmp16;
            __cil_tmp17 = *mem_45;
            mem_46 = (int *)__cil_tmp13;
            *mem_46 = __cil_tmp17 - 1;
            __cil_tmp18 = (unsigned int)p;
            __cil_tmp19 = __cil_tmp18 + 8;
            mem_47 = (int *)__cil_tmp19;
            *mem_47 = 3;
            __cil_tmp20 = (unsigned int)p;
            __cil_tmp21 = __cil_tmp20 + 4;
            __cil_tmp22 = (unsigned int)p;
            __cil_tmp23 = __cil_tmp22 + 8;
            mem_48 = (int *)__cil_tmp23;
            __cil_tmp24 = *mem_48;
            __cil_tmp25 = (unsigned int)p;
            __cil_tmp26 = __cil_tmp25 + 4;
            mem_49 = (int *)__cil_tmp26;
            __cil_tmp27 = *mem_49;
            mem_50 = (int *)__cil_tmp21;
            *mem_50 = __cil_tmp27 + __cil_tmp24;
            __cil_tmp28 = 32 + 12;
            __cil_tmp29 = (unsigned int)village;
            __cil_tmp30 = __cil_tmp29 + __cil_tmp28;
            __cil_tmp31 = (struct List *)__cil_tmp30;
            removeList(__cil_tmp31, p);
            __cil_tmp32 = 32 + 24;
            __cil_tmp33 = (unsigned int)village;
            __cil_tmp34 = __cil_tmp33 + __cil_tmp32;
            __cil_tmp35 = (struct List *)__cil_tmp34;
            addList(__cil_tmp35, p);
          }
        } else {
          __cil_tmp36 = (unsigned int)p;
          __cil_tmp37 = __cil_tmp36 + 4;
          __cil_tmp38 = (unsigned int)p;
          __cil_tmp39 = __cil_tmp38 + 4;
          mem_51 = (int *)__cil_tmp39;
          __cil_tmp40 = *mem_51;
          mem_52 = (int *)__cil_tmp37;
          *mem_52 = __cil_tmp40 + 1;
        }
        __cil_tmp41 = (unsigned int)list;
        __cil_tmp42 = __cil_tmp41 + 8;
        mem_53 = (struct List **)__cil_tmp42;
        list = *mem_53;
      }
    while_5_break:;
    }
    return;
  }
}
```