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

```asm
<spctrn>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rcx,%r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x58,%rsp
  lea    0x2c(%rsp),%r15
  movsd  %xmm1,0x18(%rsp)
  lea    0x2a(%rsp),%rdx
  movapd %xmm2,%xmm1
  lea    0x28(%rsp),%rsi
  movapd %xmm3,%xmm2
  lea    0x40(%rsp),%r9
  mov    %r15,%rcx
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  lea    0x30(%rsp),%r8
  movsd  %xmm3,0x10(%rsp)
  movsd  %xmm1,0x8(%rsp)
  call   <spcspx@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  je     L56
L4:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L91
  add    $0x58,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L56:
  lea    0x5(%rbx),%r14
  mov    $0x3,%edx
  lea    D15(%rip),%rsi
  mov    %r14,%rdi
  call   <strncmp@plt>
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm2
  test   %rax,%rax
  je     L75
  movzbl 0x2a(%rsp),%eax
  cmp    $0x77,%al
  je     L79
  cmp    $0x61,%al
  je     L6
  mov    %al,0x5(%rbx)
  movb   $0x32,0x6(%rbx)
L75:
  movsd  0x30(%rsp),%xmm0
  mov    %rbp,%r8
  mov    %r15,%rcx
  mov    %rbx,%rdi
  lea    0x29(%rsp),%rdx
  lea    0x2b(%rsp),%rsi
  lea    0x38(%rsp),%r9
  call   <spcxps@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L4
  movzbl 0x2b(%rsp),%eax
  cmp    0x2a(%rsp),%al
  jne    L106
  movzbl 0x29(%rsp),%edx
  movb   $0x3f,0x7(%rbx)
  cmp    %dl,%al
  je     L28
  mov    %dl,0x7(%rbx)
L9:
  movsd  0x38(%rsp),%xmm0
  mulsd  0x40(%rsp),%xmm0
  mulsd  0x18(%rsp),%xmm0
  movsd  %xmm0,0x0(%r13)
  jmp    L4
  nopl   0x0(%rax,%rax,1)
L106:
  mov    $0x2,%r12d
  jmp    L4
  nopl   0x0(%rax,%rax,1)
L79:
  lea    D23(%rip),%rsi
  mov    %r14,%rdi
  call   <strcpy@plt>
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm2
  jmp    L75
  nopl   0x0(%rax,%rax,1)
L28:
  lea    D22(%rip),%rsi
  mov    %r14,%rdi
  call   <strcpy@plt>
  jmp    L9
  nopl   0x0(%rax)
L6:
  lea    D38(%rip),%rsi
  mov    %r14,%rdi
  movsd  %xmm2,0x10(%rsp)
  movsd  %xmm1,0x8(%rsp)
  call   <strcpy@plt>
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm2
  jmp    L75
L91:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D15
type_infered: string
name: disassemble_data
arguments: tag: D23
type_infered: string
name: disassemble_data
arguments: tag: D22
type_infered: string
name: disassemble_data
arguments: tag: D38
type_infered: string

tool: D15: ???

tool: D23: GRI

tool: D22:     

tool: D38: GRA

assistant: ```c
int spctrn(const char ctypeS1[9], double crvalS1, double cdeltS1, double restfrq, double restwav, char ctypeS2[9], double *crvalS2, double *cdeltS2) {
  char ptype1, ptype2, xtype1, xtype2;
  int restreq, status;
  double crvalX, dS2dX, dXdS1;
  if (status = spcspx(ctypeS1, crvalS1, restfrq, restwav, &ptype1, &xtype1, &restreq, &crvalX, &dXdS1)) {
    return status;
  }
  if (strncmp(ctypeS2 + 5, "???", 3)) {
    if (xtype1 == 'w') {
      strcpy(ctypeS2 + 5, "GRI");
    } else if (xtype1 == 'a') {
      strcpy(ctypeS2 + 5, "GRA");
    } else {
      ctypeS2[5] = xtype1;
      ctypeS2[6] = '2';
    }
  }
  if (status = spcxps(ctypeS2, crvalX, restfrq, restwav, &xtype2, &ptype2, &restreq, crvalS2, &dS2dX)) {
    return status;
  }
  if (xtype2 != xtype1) {
    return 2;
  }
  if (ctypeS2[7] = '?') {
    if (ptype2 == xtype2) {
      strcpy(ctypeS2 + 5, "    ");
    } else {
      ctypeS2[7] = ptype2;
    }
  }
  *cdeltS2 = dS2dX * dXdS1 * cdeltS1;
  return 0;
}
```