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

```asm
<os_thread_create>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %rdx,-0x30(%rbp)
  mov    %rcx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x38(%rbp)
  jne    L23
  mov    $0xffffffff,%eax
  jmp    L13
L23:
  cmpl   $0x1,-0x24(%rbp)
  je     L80
  cmpl   $0x2,-0x24(%rbp)
  je     L14
  jmp    L205
L80:
  mov    D29(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L134
L14:
  mov    D42(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L134
L205:
  mov    D48(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x24(%rbp)
  nop
L134:
  lea    -0x14(%rbp),%rax
  mov    %rax,%rdi
  call   <pthread_attr_init@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L129
  mov    $0xfffffffe,%eax
  jmp    L13
L129:
  cmpq   $0x0,-0x30(%rbp)
  je     L58
  mov    -0x30(%rbp),%rdx
  lea    -0x14(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <pthread_attr_setstacksize@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L58
  movl   $0xfffffffd,-0xc(%rbp)
  jmp    L69
L58:
  mov    D40(%rip),%rax
  mov    (%rax),%edx
  lea    -0x14(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <pthread_attr_setdetachstate@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L132
  movl   $0xfffffffc,-0xc(%rbp)
  jmp    L69
L132:
  mov    D19(%rip),%rax
  mov    (%rax),%edx
  lea    -0x14(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <pthread_attr_setinheritsched@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L119
  movl   $0xfffffffb,-0xc(%rbp)
  jmp    L69
L119:
  mov    -0x24(%rbp),%edx
  lea    -0x14(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <pthread_attr_setschedpolicy@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L160
  movl   $0xfffffffa,-0xc(%rbp)
  jmp    L69
L160:
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  lea    -0x10(%rbp),%rdx
  lea    -0x14(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <pthread_attr_setschedparam@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L22
  movl   $0xfffffff9,-0xc(%rbp)
  jmp    L69
L22:
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  lea    -0x14(%rbp),%rsi
  lea    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <pthread_create@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L180
  movl   $0xfffffff8,-0xc(%rbp)
  jmp    L69
L180:
  nop
L69:
  lea    -0x14(%rbp),%rax
  mov    %rax,%rdi
  call   <pthread_attr_destroy@plt>
  mov    -0xc(%rbp),%eax
L13:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L102
  call   <__stack_chk_fail@plt>
L102:
  leave
  ret
```

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;
}
```