user: Converte this assembly snippet into its equivalent C code:

```asm
<sim>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %edi,%edi
  je     L31
  mov    %edi,%r13d
  mov    %rdi,%rbx
  mov    $0x4,%r14d
  add    $0x20,%r13d
L21:
  test   %edx,%edx
  jne    L4
L28:
  mov    0x4c(%ebx),%rsi
  mov    %rbx,%rdi
  call   <check_patients_inside@plt>
  mov    0x40(%ebx),%rsi
  mov    %rbx,%rdi
  call   <check_patients_assess@plt>
  mov    0x34(%ebx),%rsi
  mov    %rbx,%rdi
  mov    %rax,%r12
  call   <check_patients_waiting@plt>
  mov    %rbx,%rdi
  call   <generate_patient@plt>
  test   %eax,%eax
  jne    L53
L31:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L53:
  lea    0x20(%rbx),%edi
  mov    %rax,%rsi
  call   <put_in_hosp@plt>
  jmp    L31
  nopl   (%rax)
L4:
  mov    0x8(%edx),%rdx
  mov    %edx,%r15d
  test   %edx,%edx
  je     L75
  mov    %r13d,%r12d
  nopw   0x0(%rax,%rax,1)
L13:
  mov    (%rdx),%rbp
  mov    %r12,%rdi
  mov    %rbp,%rsi
  call   <put_in_hosp@plt>
  mov    %rbp,%rsi
  xor    %edi,%edi
  call   <removeList@plt>
  mov    0x8(%r15d),%rdx
  mov    %edx,%r15d
  test   %edx,%edx
  jne    L13
L75:
  sub    $0x1,%r14d
  jne    L21
  jmp    L28
```

assistant: ```c
struct List *sim(struct Village *village) {
  int i;
  struct Patient *patient;
  struct Patient *p;
  struct List *l;
  struct List *vl;
  struct List *up;
  void *__cil_tmp8;
  unsigned int __cil_tmp9;
  unsigned int __cil_tmp10;
  void *__cil_tmp11;
  void *__cil_tmp12;
  unsigned int __cil_tmp13;
  unsigned int __cil_tmp14;
  unsigned int __cil_tmp15;
  unsigned int __cil_tmp16;
  void *__cil_tmp17;
  unsigned int __cil_tmp18;
  unsigned int __cil_tmp19;
  unsigned int __cil_tmp20;
  unsigned int __cil_tmp21;
  struct Hosp *__cil_tmp22;
  unsigned int __cil_tmp23;
  unsigned int __cil_tmp24;
  unsigned int __cil_tmp25;
  unsigned int __cil_tmp26;
  unsigned int __cil_tmp27;
  unsigned int __cil_tmp28;
  struct List *__cil_tmp29;
  unsigned int __cil_tmp30;
  unsigned int __cil_tmp31;
  unsigned int __cil_tmp32;
  unsigned int __cil_tmp33;
  struct List *__cil_tmp34;
  unsigned int __cil_tmp35;
  unsigned int __cil_tmp36;
  unsigned int __cil_tmp37;
  unsigned int __cil_tmp38;
  struct List *__cil_tmp39;
  void *__cil_tmp40;
  unsigned int __cil_tmp41;
  unsigned int __cil_tmp42;
  unsigned int __cil_tmp43;
  unsigned int __cil_tmp44;
  struct Hosp *__cil_tmp45;
  struct List **mem_46;
  struct Patient **mem_47;
  struct List **mem_48;
  struct List **mem_49;
  struct List **mem_50;
  struct List **mem_51;
  {
    {
      __cil_tmp8 = (void *)0;
      __cil_tmp9 = (unsigned int)__cil_tmp8;
      __cil_tmp10 = (unsigned int)village;
      if (__cil_tmp10 == __cil_tmp9) {
        {
          __cil_tmp11 = (void *)0;
          return ((struct List *)__cil_tmp11);
        }
      } else {
      }
    }
    i = 0;
    {
      while (1) {
      while_7_continue:;
        if (i < 4) {
        } else {
          goto while_7_break;
        }
        {
          __cil_tmp12 = (void *)0;
          __cil_tmp13 = (unsigned int)__cil_tmp12;
          __cil_tmp14 = (unsigned int)l;
          if (__cil_tmp14 != __cil_tmp13) {
            __cil_tmp15 = (unsigned int)l;
            __cil_tmp16 = __cil_tmp15 + 8;
            mem_46 = (struct List **)__cil_tmp16;
            l = *mem_46;
            {
              while (1) {
              while_8_continue:;
                {
                  __cil_tmp17 = (void *)0;
                  __cil_tmp18 = (unsigned int)__cil_tmp17;
                  __cil_tmp19 = (unsigned int)l;
                  if (__cil_tmp19 != __cil_tmp18) {
                  } else {
                    goto while_8_break;
                  }
                }
                {
                  mem_47 = (struct Patient **)l;
                  p = *mem_47;
                  __cil_tmp20 = (unsigned int)village;
                  __cil_tmp21 = __cil_tmp20 + 32;
                  __cil_tmp22 = (struct Hosp *)__cil_tmp21;
                  put_in_hosp(__cil_tmp22, p);
                  removeList(vl, p);
                  __cil_tmp23 = (unsigned int)l;
                  __cil_tmp24 = __cil_tmp23 + 8;
                  mem_48 = (struct List **)__cil_tmp24;
                  l = *mem_48;
                }
              }
            while_8_break:;
            }
          } else {
          }
        }
        i = i + 1;
      }
    while_7_break:;
    }
    {
      __cil_tmp25 = 36 + 8;
      __cil_tmp26 = 32 + __cil_tmp25;
      __cil_tmp27 = (unsigned int)village;
      __cil_tmp28 = __cil_tmp27 + __cil_tmp26;
      mem_49 = (struct List **)__cil_tmp28;
      __cil_tmp29 = *mem_49;
      check_patients_inside(village, __cil_tmp29);
      __cil_tmp30 = 24 + 8;
      __cil_tmp31 = 32 + __cil_tmp30;
      __cil_tmp32 = (unsigned int)village;
      __cil_tmp33 = __cil_tmp32 + __cil_tmp31;
      mem_50 = (struct List **)__cil_tmp33;
      __cil_tmp34 = *mem_50;
      up = check_patients_assess(village, __cil_tmp34);
      __cil_tmp35 = 12 + 8;
      __cil_tmp36 = 32 + __cil_tmp35;
      __cil_tmp37 = (unsigned int)village;
      __cil_tmp38 = __cil_tmp37 + __cil_tmp36;
      mem_51 = (struct List **)__cil_tmp38;
      __cil_tmp39 = *mem_51;
      check_patients_waiting(village, __cil_tmp39);
      patient = generate_patient(village);
    }
    {
      __cil_tmp40 = (void *)0;
      __cil_tmp41 = (unsigned int)__cil_tmp40;
      __cil_tmp42 = (unsigned int)patient;
      if (__cil_tmp42 != __cil_tmp41) {
        {
          __cil_tmp43 = (unsigned int)village;
          __cil_tmp44 = __cil_tmp43 + 32;
          __cil_tmp45 = (struct Hosp *)__cil_tmp44;
          put_in_hosp(__cil_tmp45, patient);
        }
      } else {
      }
    }
    return (up);
  }
}
```