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

```asm
<ms_doy2md>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %edi,-0x54(%rbp)
  mov    %esi,-0x58(%rbp)
  mov    %rdx,-0x60(%rbp)
  mov    %rcx,-0x68(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x1f,-0x40(%rbp)
  movl   $0x1c,-0x3c(%rbp)
  movl   $0x1f,-0x38(%rbp)
  movl   $0x1e,-0x34(%rbp)
  movl   $0x1f,-0x30(%rbp)
  movl   $0x1e,-0x2c(%rbp)
  movl   $0x1f,-0x28(%rbp)
  movl   $0x1f,-0x24(%rbp)
  movl   $0x1e,-0x20(%rbp)
  movl   $0x1f,-0x1c(%rbp)
  movl   $0x1e,-0x18(%rbp)
  movl   $0x1f,-0x14(%rbp)
  cmpl   $0x707,-0x54(%rbp)
  jle    L144
  cmpl   $0x1388,-0x54(%rbp)
  jle    L99
L144:
  mov    -0x54(%rbp),%eax
  mov    %eax,%edx
  lea    D6(%rip),%rax
  mov    %rax,%rsi
  mov    $0x2,%edi
  call   <ms_log@plt>
  mov    $0xffffffff,%eax
  jmp    L24
L99:
  mov    -0x54(%rbp),%eax
  and    $0x3,%eax
  test   %eax,%eax
  jne    L88
  mov    -0x54(%rbp),%edx
  movslq %edx,%rax
  imul   $0x51eb851f,%rax,%rax
  shr    $0x20,%rax
  sar    $0x5,%eax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  imul   $0x64,%eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  test   %eax,%eax
  jne    L10
L88:
  mov    -0x54(%rbp),%edx
  movslq %edx,%rax
  imul   $0x51eb851f,%rax,%rax
  shr    $0x20,%rax
  sar    $0x7,%eax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  imul   $0x190,%eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  test   %eax,%eax
  jne    L137
L10:
  mov    $0x1,%eax
  jmp    L26
L137:
  mov    $0x0,%eax
L26:
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  je     L7
  mov    -0x3c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x3c(%rbp)
L7:
  mov    -0x44(%rbp),%eax
  add    $0x16d,%eax
  cmp    %eax,-0x58(%rbp)
  jg     L132
  cmpl   $0x0,-0x58(%rbp)
  jg     L17
L132:
  mov    -0x58(%rbp),%eax
  mov    %eax,%edx
  lea    D14(%rip),%rax
  mov    %rax,%rsi
  mov    $0x2,%edi
  call   <ms_log@plt>
  mov    $0xffffffff,%eax
  jmp    L24
L17:
  movl   $0x0,-0x48(%rbp)
  jmp    L146
L58:
  mov    -0x48(%rbp),%eax
  cltq
  mov    -0x40(%rbp,%rax,4),%eax
  sub    %eax,-0x58(%rbp)
  cmpl   $0x0,-0x58(%rbp)
  jg     L131
  mov    -0x48(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x60(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x48(%rbp),%eax
  cltq
  mov    -0x40(%rbp,%rax,4),%edx
  mov    -0x58(%rbp),%eax
  add    %eax,%edx
  mov    -0x68(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L63
L131:
  addl   $0x1,-0x48(%rbp)
L146:
  cmpl   $0xb,-0x48(%rbp)
  jle    L58
L63:
  mov    $0x0,%eax
L24:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L25
  call   <__stack_chk_fail@plt>
L25:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D6
data_type: string
name: unpack_data
arguments: label: D14
data_type: string

tool: D6: ms_doy2md(): year (%d) is out of range


tool: D14: ms_doy2md(): day-of-year (%d) is out of range


assistant: ```c
int ms_doy2md(int year, int jday, int *month, int *mday) {
  int idx;
  int leap;
  int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  if (year < 1800 || year > 5000) {
    ms_log(2, "ms_doy2md(): year (%d) is out of range\n", year);
    return -1;
  }
  leap = (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 1 : 0;
  if (leap)
    days[1]++;
  if (jday > 365 + leap || jday <= 0) {
    ms_log(2, "ms_doy2md(): day-of-year (%d) is out of range\n", jday);
    return -1;
  }
  for (idx = 0; idx < 12; idx++) {
    jday -= days[idx];
    if (jday <= 0) {
      *month = idx + 1;
      *mday = days[idx] + jday;
      break;
    }
  }
  return 0;
}
```