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

```asm
<os_alloc_assoc_set_pid>:
  endbr64
  push   %r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  xor    %esi,%esi
  push   %rbx
  sub    $0x120,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  movl   $0x0,0x4(%rsp)
  call   <_pqos_cap_get@plt>
  mov    0x8(%rsp),%rdi
  lea    0x4(%rsp),%rsi
  call   <resctrl_alloc_get_grps_num@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L10
  cmp    %ebp,0x4(%rsp)
  jbe    L68
  xor    %eax,%eax
  call   <resctrl_lock_exclusive@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  je     L92
L10:
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L101
  add    $0x120,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L92:
  lea    0x10(%rsp),%r14
  mov    $0x100,%edx
  mov    %r13d,%edi
  mov    %r14,%rsi
  call   <resctrl_mon_assoc_get_pid@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L78
  cmp    $0x3,%eax
  je     L78
  mov    %r13d,%edx
  lea    D1(%rip),%rsi
  mov    $0x2,%edi
  call   <log_printf@plt>
  mov    %ebp,%esi
  mov    %r13d,%edi
  call   <resctrl_alloc_assoc_set_pid@plt>
  mov    %eax,%r12d
L107:
  xor    %eax,%eax
  call   <resctrl_lock_release@plt>
  jmp    L10
  nopw   0x0(%rax,%rax,1)
L78:
  mov    %ebp,%esi
  mov    %r13d,%edi
  call   <resctrl_alloc_assoc_set_pid@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L107
  test   %ebx,%ebx
  jne    L107
  mov    %r14,%rsi
  mov    %r13d,%edi
  call   <resctrl_mon_assoc_set_pid@plt>
  test   %eax,%eax
  je     L107
  mov    %r13d,%edx
  lea    D29(%rip),%rsi
  mov    $0x2,%edi
  call   <log_printf@plt>
  jmp    L107
  nopw   0x0(%rax,%rax,1)
L68:
  mov    %r13d,%edx
  lea    D4(%rip),%rsi
  mov    $0x4,%edi
  mov    $0x2,%r12d
  call   <log_printf@plt>
  jmp    L10
L101:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D1
datatype: string
name: retrieve_data
arguments: tag: D29
datatype: string
name: retrieve_data
arguments: tag: D4
datatype: string

tool: D1: WARN: Failed to obtain monitoring group assignment for task %d


tool: D29: WARN: Could not assign task %d back to monitoring group


tool: D4: ERROR: COS out of bounds for task %d


assistant: ```c
int os_alloc_assoc_set_pid(const pid_t task, const unsigned class_id) {
  int ret;
  unsigned max_cos = 0;
  int ret_mon;
  char mon_group[256];
  const struct pqos_cap *cap;
  _pqos_cap_get(&cap, NULL);
  ret = resctrl_alloc_get_grps_num(cap, &max_cos);
  if (ret != 0)
    return ret;
  if (class_id >= max_cos) {
    log_printf((1 << 2),
               "ERROR: "
               "COS out of bounds for task %d\n",
               (int)task);
    return 2;
  }
  ret = resctrl_lock_exclusive();
  if (ret != 0)
    return ret;
  ret_mon = resctrl_mon_assoc_get_pid(task, mon_group, sizeof(mon_group));
  if (ret_mon != 0 && ret_mon != 3)
    log_printf((1 << 1),
               "WARN: "
               "Failed to obtain monitoring group assignment for "
               "task %d\n",
               task);
  ret = resctrl_alloc_assoc_set_pid(task, class_id);
  if (ret != 0)
    goto os_alloc_assoc_set_pid_exit;
  if (ret_mon == 0) {
    ret_mon = resctrl_mon_assoc_set_pid(task, mon_group);
    if (ret_mon != 0)
      log_printf((1 << 1),
                 "WARN: "
                 "Could not assign task %d back to monitoring "
                 "group\n",
                 task);
  }
os_alloc_assoc_set_pid_exit:
  resctrl_lock_release();
  return ret;
}
```