user: Translate the below assembly code into C programming language:

```asm
<calculator>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  movzbl (%rdi),%edi
  test   %dil,%dil
  je     L84
  movl   $0x0,0xc(%rsp)
  mov    $0x0,%ebp
  mov    $0x0,%r12d
  lea    D22(%rip),%r14
  mov    $0x0,%r15d
  lea    D2(%rip),%r13
  jmp    L77
L79:
  movzbl (%rbx),%eax
  cmp    $0x2a,%al
  je     L192
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  jne    L74
  mov    0xc(%rsp),%eax
  movslq (%r14,%rax,4),%rax
  add    %r14,%rax
  notrack jmp *%rax
L192:
  mov    0xc(%rsp),%eax
  movslq 0x0(%r13,%rax,4),%rax
  add    %r13,%rax
  notrack jmp *%rax
  mov    %ebp,%r12d
  movl   $0x3,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
  add    %ebp,%r12d
  movl   $0x3,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
  sub    %ebp,%r12d
  movl   $0x3,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
  imul   %ebp,%r12d
  mov    %r15d,%ebp
  jmp    L4
  mov    %r12d,%eax
  cltd
  idiv   %ebp
  mov    %eax,%r12d
  movl   $0x3,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
  mov    %ebp,%r12d
  movl   $0x1,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
  add    %ebp,%r12d
  mov    %r15d,%ebp
  jmp    L4
  sub    %ebp,%r12d
  movl   $0x1,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
  imul   %ebp,%r12d
  movl   $0x1,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
  mov    %r12d,%eax
  cltd
  idiv   %ebp
  mov    %eax,%r12d
  movl   $0x1,0xc(%rsp)
  mov    %r15d,%ebp
  jmp    L4
L74:
  cmp    $0x23,%al
  je     L85
L4:
  add    $0x1,%rbx
  movzbl (%rbx),%edi
  test   %dil,%dil
  je     L91
L77:
  movsbl %dil,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L79
  lea    0x0(%rbp,%rbp,4),%edx
  movsbl (%rbx),%eax
  lea    -0x30(%rax,%rdx,2),%ebp
  jmp    L4
L85:
  mov    0xc(%rsp),%eax
  lea    D27(%rip),%rdx
  movslq (%rdx,%rax,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  mov    %ebp,%r12d
  jmp    L91
  add    %ebp,%r12d
  jmp    L91
  sub    %ebp,%r12d
  jmp    L91
  imul   %ebp,%r12d
  jmp    L91
  mov    %r12d,%eax
  cltd
  idiv   %ebp
  mov    %eax,%r12d
  jmp    L91
L84:
  mov    $0x0,%r12d
L91:
  mov    %r12d,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int calculator(char *str) {
  int result;
  int num;
  enum { NONE, ADD, SUB, MUL, DIV } lastop;
  char *p;
  result = 0;
  num = 0;
  lastop = NONE;
  for (p = str; *p != '\0'; p++) {
    if (isdigit(*p)) {
      num = num * 10 + *p - '0';
    } else if (*p == '*') {
      switch (lastop) {
      case NONE:
        result = num;
        num = 0;
        break;
      case ADD:
        result += num;
        num = 0;
        break;
      case SUB:
        result -= num;
        num = 0;
        break;
      case MUL:
        result *= num;
        num = 0;
        break;
      case DIV:
        result /= num;
        num = 0;
        break;
      };
      lastop = MUL;
    } else if (*p == 'A' || *p == 'a') {
      switch (lastop) {
      case NONE:
        result = num;
        num = 0;
        break;
      case ADD:
        result += num;
        num = 0;
        break;
      case SUB:
        result -= num;
        num = 0;
        break;
      case MUL:
        result *= num;
        num = 0;
        break;
      case DIV:
        result /= num;
        num = 0;
        break;
      };
      lastop = ADD;
    } else if (*p == '#') {
      switch (lastop) {
      case NONE:
        result = num;
        num = 0;
        break;
      case ADD:
        result += num;
        num = 0;
        break;
      case SUB:
        result -= num;
        num = 0;
        break;
      case MUL:
        result *= num;
        num = 0;
        break;
      case DIV:
        result /= num;
        num = 0;
        break;
      };
      return (result);
    }
  }
  return (result);
}
```