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

```asm
<os_thread_create>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rcx,%rcx
  je     L151
  mov    %esi,%r12d
  mov    %rdx,%rbx
  mov    %rcx,%rbp
  mov    %r8,%r13
  cmp    $0x1,%edi
  je     L28
  cmp    $0x2,%edi
  je     L83
  mov    D33(%rip),%rax
  mov    (%rax),%r14d
  jmp    L107
L28:
  mov    D28(%rip),%rax
  mov    (%rax),%r14d
L107:
  lea    0x10(%rsp),%rdi
  call   <pthread_attr_init@plt>
  test   %eax,%eax
  jne    L87
  test   %rbx,%rbx
  je     L54
  lea    0x10(%rsp),%rdi
  mov    %rbx,%rsi
  call   <pthread_attr_setstacksize@plt>
  mov    $0xfffffffd,%ebx
  test   %eax,%eax
  jne    L135
L54:
  lea    0x10(%rsp),%rdi
  mov    D16(%rip),%rax
  mov    (%rax),%esi
  call   <pthread_attr_setdetachstate@plt>
  mov    $0xfffffffc,%ebx
  test   %eax,%eax
  je     L159
L135:
  lea    0x10(%rsp),%rdi
  call   <pthread_attr_destroy@plt>
L97:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L17
  mov    %ebx,%eax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L83:
  mov    D41(%rip),%rax
  mov    (%rax),%r14d
  jmp    L107
L159:
  lea    0x10(%rsp),%rdi
  mov    D39(%rip),%rax
  mov    (%rax),%esi
  call   <pthread_attr_setinheritsched@plt>
  mov    $0xfffffffb,%ebx
  test   %eax,%eax
  jne    L135
  lea    0x10(%rsp),%rdi
  mov    %r14d,%esi
  call   <pthread_attr_setschedpolicy@plt>
  mov    $0xfffffffa,%ebx
  test   %eax,%eax
  jne    L135
  mov    %r12d,0x14(%rsp)
  lea    0x14(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  call   <pthread_attr_setschedparam@plt>
  mov    $0xfffffff9,%ebx
  test   %eax,%eax
  jne    L135
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    %r13,%rcx
  mov    %rbp,%rdx
  call   <pthread_create@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  mov    $0xfffffff8,%eax
  cmovne %eax,%ebx
  jmp    L135
L151:
  mov    $0xffffffff,%ebx
  jmp    L97
L87:
  mov    $0xfffffffe,%ebx
  jmp    L97
L17:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int os_thread_create(int policy, int priority, size_t stack_size, void *(*start)(void *), void *arg) {
  int ret;
  pthread_t tid;
  pthread_attr_t attr;
  struct sched_param params;
  if (start == NULL) {
    return -1;
  }
  switch (policy) {
  case 1:
    policy = SCHED_FIFO;
    break;
  case 2:
    policy = SCHED_RR;
    break;
  case 0:
  default:
    policy = SCHED_OTHER;
    break;
  }
  ret = pthread_attr_init(&attr);
  if (ret != 0) {
    return -2;
  }
  if (stack_size > 0) {
    ret = pthread_attr_setstacksize(&attr, stack_size);
    if (ret != 0) {
      ret = -3;
      goto out;
    }
  }
  ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  if (0 != ret) {
    ret = -4;
    goto out;
  }
  ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
  if (0 != ret) {
    ret = -5;
    goto out;
  }
  ret = pthread_attr_setschedpolicy(&attr, policy);
  if (0 != ret) {
    ret = -6;
    goto out;
  }
  params.sched_priority = priority;
  ret = pthread_attr_setschedparam(&attr, &params);
  if (0 != ret) {
    ret = -7;
    goto out;
  }
  ret = pthread_create(&tid, &attr, start, arg);
  if (0 != ret) {
    ret = -8;
    goto out;
  }
out:
  pthread_attr_destroy(&attr);
  return ret;
}
```