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

```asm
<os_thread_create>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rcx,%rcx
  je     L23
  mov    %esi,%ebx
  mov    %rdx,%r12
  mov    %rcx,%r13
  mov    %r8,%r14
  cmp    $0x1,%edi
  je     L100
  cmp    $0x2,%edi
  jne    L1
  mov    D29(%rip),%rax
  mov    (%rax),%r15d
L47:
  lea    0x10(%rsp),%rbp
  mov    %rbp,%rdi
  call   <pthread_attr_init@plt>
  test   %eax,%eax
  jne    L18
  test   %r12,%r12
  je     L42
  mov    %r12,%rsi
  mov    %rbp,%rdi
  mov    $0xfffffffd,%r12d
  call   <pthread_attr_setstacksize@plt>
  test   %eax,%eax
  jne    L54
L42:
  mov    D2(%rip),%rax
  mov    %rbp,%rdi
  mov    $0xfffffffc,%r12d
  mov    (%rax),%esi
  call   <pthread_attr_setdetachstate@plt>
  test   %eax,%eax
  jne    L54
  mov    D32(%rip),%rax
  mov    %rbp,%rdi
  mov    $0xfffffffb,%r12d
  mov    (%rax),%esi
  call   <pthread_attr_setinheritsched@plt>
  test   %eax,%eax
  je     L157
L54:
  mov    %rbp,%rdi
  call   <pthread_attr_destroy@plt>
L65:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L38
  add    $0x28,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L1:
  mov    D21(%rip),%rax
  mov    (%rax),%r15d
  jmp    L47
  nopw   0x0(%rax,%rax,1)
L100:
  mov    D47(%rip),%rax
  mov    (%rax),%r15d
  jmp    L47
  nop
L157:
  mov    %r15d,%esi
  mov    %rbp,%rdi
  mov    $0xfffffffa,%r12d
  call   <pthread_attr_setschedpolicy@plt>
  test   %eax,%eax
  jne    L54
  lea    0x14(%rsp),%rsi
  mov    %rbp,%rdi
  mov    %ebx,0x14(%rsp)
  mov    $0xfffffff9,%r12d
  call   <pthread_attr_setschedparam@plt>
  test   %eax,%eax
  jne    L54
  lea    0xc(%rsp),%rdi
  mov    %r14,%rcx
  mov    %r13,%rdx
  mov    %rbp,%rsi
  call   <pthread_create@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  mov    $0xfffffff8,%eax
  cmovne %eax,%r12d
  jmp    L54
  nopw   0x0(%rax,%rax,1)
L18:
  mov    $0xfffffffe,%r12d
  jmp    L65
L23:
  mov    $0xffffffff,%r12d
  jmp    L65
L38:
  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;
}
```