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

```asm
<calculate>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %esi,%esi
  jle    L139
  mov    %rdi,%rbp
  lea    -0x1(%rsi),%eax
  lea    0x8(%rdi,%rax,8),%r12
  lea    D67(%rip),%r13
  lea    D110(%rip),%r14
  lea    D40(%rip),%r15
  jmp    L167
L170:
  mov    %rbx,%rdi
  call   <atof@plt>
  call   <push@plt>
L263:
  add    $0x8,%rbp
  cmp    %r12,%rbp
  je     L139
L167:
  mov    0x0(%rbp),%rbx
  mov    %rbx,%rdi
  call   <isnumfmt@plt>
  test   %rax,%rax
  jne    L170
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L15
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L135
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L193
  lea    D65(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L264
  lea    D23(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L27
  lea    D27(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L223
  lea    D82(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L256
  lea    D39(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L209
  call   <pop@plt>
  call   <sin@plt>
  call   <push@plt>
  jmp    L263
L15:
  call   <pop@plt>
  movq   %xmm0,%rbx
  mov    $0x0,%eax
  call   <pop@plt>
  movq   %rbx,%xmm2
  addsd  %xmm0,%xmm2
  movapd %xmm2,%xmm0
  call   <push@plt>
  jmp    L263
L135:
  call   <pop@plt>
  movq   %xmm0,%rbx
  mov    $0x0,%eax
  call   <pop@plt>
  movq   %rbx,%xmm3
  mulsd  %xmm0,%xmm3
  movapd %xmm3,%xmm0
  call   <push@plt>
  jmp    L263
L193:
  call   <swap@plt>
  mov    $0x0,%eax
  call   <pop@plt>
  movq   %xmm0,%rbx
  mov    $0x0,%eax
  call   <pop@plt>
  movapd %xmm0,%xmm1
  movq   %rbx,%xmm0
  subsd  %xmm1,%xmm0
  call   <push@plt>
  jmp    L263
L264:
  call   <pop@plt>
  movq   %xmm0,%rbx
  ucomisd D31(%rip),%xmm0
  jp     L202
  jne    L202
  mov    $0x0,%eax
  call   <pop@plt>
  pxor   %xmm0,%xmm0
  call   <push@plt>
  lea    D48(%rip),%rdi
  call   <puts@plt>
  jmp    L263
L202:
  mov    $0x0,%eax
  call   <pop@plt>
  movq   %rbx,%xmm7
  divsd  %xmm7,%xmm0
  call   <push@plt>
  jmp    L263
L27:
  call   <pop@plt>
  movsd  %xmm0,0x8(%rsp)
  ucomisd D31(%rip),%xmm0
  jp     L33
  jne    L33
  mov    $0x0,%eax
  call   <pop@plt>
  pxor   %xmm0,%xmm0
  call   <push@plt>
  lea    D48(%rip),%rdi
  call   <puts@plt>
  jmp    L263
L33:
  mov    $0x0,%eax
  call   <pop@plt>
  cvttsd2si %xmm0,%eax
  cvttsd2si 0x8(%rsp),%ecx
  cltd
  idiv   %ecx
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  call   <push@plt>
  jmp    L263
L223:
  call   <pop@plt>
  movq   %xmm0,%rbx
  mov    $0x0,%eax
  call   <pop@plt>
  movq   %rbx,%xmm1
  call   <pow@plt>
  call   <push@plt>
  jmp    L263
L256:
  call   <pop@plt>
  call   <exp@plt>
  call   <push@plt>
  jmp    L263
L209:
  mov    %rbx,%rsi
  lea    D51(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L263
L139:
  mov    $0x0,%eax
  call   <gettop@plt>
  movq   %xmm0,%rbx
  mov    $0x0,%eax
  call   <clearstack@plt>
  movq   %rbx,%xmm0
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D67
datatype: string
name: unpack_data
arguments: data_label: D110
datatype: string
name: unpack_data
arguments: data_label: D40
datatype: string
name: unpack_data
arguments: data_label: D65
datatype: string
name: unpack_data
arguments: data_label: D23
datatype: string
name: unpack_data
arguments: data_label: D27
datatype: string
name: unpack_data
arguments: data_label: D82
datatype: string
name: unpack_data
arguments: data_label: D39
datatype: string
name: unpack_data
arguments: data_label: D31
datatype: f64
name: unpack_data
arguments: data_label: D48
datatype: string
name: unpack_data
arguments: data_label: D51
datatype: string

tool: D67: +

tool: D110: *

tool: D40: -

tool: D65: /

tool: D23: %

tool: D27: pow

tool: D82: exp

tool: D39: sin

tool: D31: 0

tool: D48: Error: divisor is 0

tool: D51: Error: unknown token %s


assistant: ```c
double calculate(char *tokens[], int len) {
  char *t;
  int i;
  for (i = 0; i < len; i++) {
    t = tokens[i];
    if (isnumfmt(t)) {
      push(atof(t));
    } else if (!strcmp(t, "+")) {
      push(pop() + pop());
    } else if (!strcmp(t, "*")) {
      push(pop() * pop());
    } else if (!strcmp(t, "-")) {
      swap();
      push(pop() - pop());
    } else if (!strcmp(t, "/")) {
      double tmp = pop();
      if (tmp != 0) {
        push(pop() / tmp);
      } else {
        pop();
        push(0.0);
        printf("Error: divisor is 0\n");
      }
    } else if (!strcmp(t, "%")) {
      double tmp = pop();
      if (tmp != 0) {
        push((int)pop() % (int)tmp);
      } else {
        pop();
        push(0.0);
        printf("Error: divisor is 0\n");
      }
    } else if (!strcmp(t, "pow")) {
      double tmp = pop();
      push(pow(pop(), tmp));
    } else if (!strcmp(t, "exp")) {
      push(exp(pop()));
    } else if (!strcmp(t, "sin")) {
      push(sin(pop()));
    } else {
      printf("Error: unknown token %s\n", t);
    }
  }
  double rt = gettop();
  clearstack();
  return rt;
}
```