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

```asm
<calculator>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  movsbl (%rdi),%edi
  test   %dil,%dil
  je     L384
  xor    %r12d,%r12d
  xor    %ebp,%ebp
  xor    %r13d,%r13d
  jmp    L825
  nopl   0x0(%rax,%rax,1)
L305:
  lea    0x0(%rbp,%rbp,4),%eax
  mov    %r14,%rbx
  add    %eax,%eax
L169:
  movsbl (%rbx),%edx
  lea    -0x30(%rax,%rdx,1),%ebp
L1099:
  movsbl 0x1(%rbx),%edi
  lea    0x1(%rbx),%r14
  test   %dil,%dil
  je     L230
L825:
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L305
  movzbl (%r14),%eax
  cmp    $0x2a,%al
  je     L306
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  jne    L779
  movsbl 0x1(%r14),%edi
  cmp    $0x2,%r12d
  jne    L551
  sub    %ebp,%r13d
  mov    %r13d,%ebp
  test   %dil,%dil
  je     L230
  call   <isdigit@plt>
  test   %rax,%rax
  je     L1034
L86:
  movsbl 0x1(%r14),%r12d
  movzbl 0x2(%r14),%eax
  lea    0x2(%r14),%rbx
  sub    $0x30,%r12d
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L322
  movzbl 0x2(%r14),%eax
  cmp    $0x2a,%al
  jne    L1054
L396:
  add    %r12d,%ebp
L947:
  movsbl 0x1(%rbx),%edi
  test   %dil,%dil
  je     L667
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L692
  movzbl 0x1(%rbx),%eax
  lea    0x1(%rbx),%r15
  xor    %r12d,%r12d
  cmp    $0x2a,%al
  je     L856
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L676
  cmp    $0x23,%al
  je     L384
  movzbl 0x2(%rbx),%eax
  lea    0x2(%rbx),%r15
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L1084
  movzbl 0x2(%rbx),%eax
  cmp    $0x2a,%al
  je     L856
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L676
  mov    %r15,%rbx
  jmp    L198
  nop
L729:
  cmp    $0x3,%r12d
  je     L289
  cmp    $0x1,%r12d
  je     L741
  test   %dil,%dil
  jne    L264
  nopl   0x0(%rax)
L667:
  mov    %ebp,%r13d
L230:
  add    $0x8,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L306:
  movsbl 0x1(%r14),%edi
  lea    0x1(%r14),%r15
  cmp    $0x2,%r12d
  jne    L729
  sub    %ebp,%r13d
  mov    %r13d,%ebp
  test   %dil,%dil
  je     L230
L264:
  call   <isdigit@plt>
  test   %rax,%rax
  je     L822
  movsbl 0x1(%r14),%r12d
  movzbl 0x2(%r14),%eax
  lea    0x2(%r14),%rbx
  sub    $0x30,%r12d
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L585
  movzbl 0x2(%r14),%eax
  cmp    $0x2a,%al
  je     L1055
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  jne    L288
  imul   %r12d,%ebp
  mov    %rbx,%r15
  jmp    L959
  xchg   %ax,%ax
L551:
  cmp    $0x3,%r12d
  je     L337
  cmp    $0x1,%r12d
  je     L296
  test   %dil,%dil
  je     L667
  call   <isdigit@plt>
  test   %rax,%rax
  je     L1034
  jmp    L86
L779:
  mov    %r14,%rbx
L70:
  cmp    $0x23,%al
  jne    L1099
  cmp    $0x2,%r12d
  je     L260
  cmp    $0x3,%r12d
  je     L473
  add    %ebp,%r13d
  cmp    $0x1,%r12d
  cmovne %ebp,%r13d
  jmp    L230
  nop
L822:
  movzbl 0x1(%r14),%eax
  cmp    $0x2a,%al
  je     L398
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L676
  cmp    $0x23,%al
  je     L384
  movzbl 0x2(%r14),%eax
  lea    0x2(%r14),%rbx
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L387
  movzbl 0x2(%r14),%eax
  cmp    $0x2a,%al
  je     L1023
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L970
L198:
  mov    %ebp,%r13d
  mov    $0x3,%r12d
  xor    %ebp,%ebp
  jmp    L70
L1034:
  movzbl 0x1(%r14),%eax
  lea    0x1(%r14),%rbx
  cmp    $0x2a,%al
  je     L947
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L224
  cmp    $0x23,%al
  je     L667
  movzbl 0x2(%r14),%eax
  lea    0x2(%r14),%rbx
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L464
  movzbl 0x2(%r14),%eax
  cmp    $0x2a,%al
  je     L947
L806:
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  jne    L1073
L224:
  xor    %r12d,%r12d
L1058:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  lea    0x0(%rbp,%r12,1),%r13d
  test   %dil,%dil
  je     L230
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L719
  movzbl (%rbx),%eax
  cmp    $0x2a,%al
  je     L345
  mov    %eax,%edx
  xor    %r12d,%r12d
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L1038
  mov    $0x1,%r12d
  xor    %ebp,%ebp
  jmp    L70
L322:
  lea    (%r12,%r12,4),%eax
  mov    %ebp,%r13d
  mov    $0x1,%r12d
  add    %eax,%eax
  jmp    L169
L970:
  mov    %rbx,%r15
L676:
  xor    %ebp,%ebp
L959:
  movsbl 0x1(%r15),%edi
  test   %dil,%dil
  je     L667
  call   <isdigit@plt>
  test   %rax,%rax
  je     L389
  movsbl 0x1(%r15),%r12d
  movzbl 0x2(%r15),%eax
  lea    0x2(%r15),%rbx
  sub    $0x30,%r12d
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L322
  movzbl 0x2(%r15),%eax
  cmp    $0x2a,%al
  je     L396
L1054:
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L1058
  mov    %ebp,%r13d
  mov    %r12d,%ebp
  mov    $0x1,%r12d
  jmp    L70
  nopl   0x0(%rax,%rax,1)
L692:
  movsbl 0x1(%rbx),%r12d
  movzbl 0x2(%rbx),%eax
  lea    0x2(%rbx),%r15
  sub    $0x30,%r12d
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L245
  lea    (%r12,%r12,4),%eax
  mov    %r15,%rbx
  mov    %ebp,%r13d
  mov    $0x3,%r12d
  add    %eax,%eax
  jmp    L169
  nopl   0x0(%rax)
L719:
  xor    %eax,%eax
  mov    $0x1,%r12d
  jmp    L169
  nopl   (%rax)
L389:
  movzbl 0x1(%r15),%eax
  lea    0x1(%r15),%rbx
  cmp    $0x2a,%al
  je     L947
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L224
  cmp    $0x23,%al
  je     L667
  movzbl 0x2(%r15),%eax
  lea    0x2(%r15),%rbx
  test   %al,%al
  je     L667
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L739
L464:
  mov    %ebp,%r13d
  xor    %eax,%eax
  mov    $0x1,%r12d
  jmp    L169
  nopl   0x0(%rax)
L585:
  lea    (%r12,%r12,4),%eax
  mov    %ebp,%r13d
  mov    $0x3,%r12d
  add    %eax,%eax
  jmp    L169
L398:
  xor    %r12d,%r12d
L856:
  imul   %r12d,%ebp
  movsbl 0x1(%r15),%edi
  lea    0x1(%r15),%rbx
  mov    %ebp,%r13d
  test   %dil,%dil
  je     L230
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L131
  movzbl (%rbx),%eax
  xor    %r12d,%r12d
  cmp    $0x2a,%al
  je     L1047
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L970
  cmp    $0x23,%al
  je     L384
  movzbl 0x1(%rbx),%eax
  add    $0x2,%r15
  test   %al,%al
  je     L230
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L619
  movzbl 0x1(%rbx),%eax
  cmp    $0x2a,%al
  je     L532
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  je     L676
  mov    %r15,%rbx
  mov    $0x3,%r12d
  xor    %ebp,%ebp
  jmp    L70
L1084:
  mov    %r15,%rbx
L387:
  mov    %ebp,%r13d
L131:
  xor    %eax,%eax
  mov    $0x3,%r12d
  jmp    L169
L245:
  movzbl 0x2(%rbx),%eax
  cmp    $0x2a,%al
  je     L856
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  cmp    $0x41,%dl
  jne    L349
  imul   %r12d,%ebp
  jmp    L959
L384:
  xor    %r13d,%r13d
  jmp    L230
L1047:
  mov    %rbx,%r15
L532:
  mov    %r13d,%ebp
  jmp    L856
L345:
  mov    %r13d,%ebp
  jmp    L947
L1038:
  mov    %r13d,%ebp
  jmp    L1058
L1055:
  mov    %rbx,%r15
  jmp    L856
L288:
  mov    %ebp,%r13d
  mov    %r12d,%ebp
  mov    $0x3,%r12d
  jmp    L70
L349:
  mov    %ebp,%r13d
  mov    %r15,%rbx
  mov    %r12d,%ebp
  mov    $0x3,%r12d
  jmp    L70
L619:
  mov    %r15,%rbx
  xor    %eax,%eax
  mov    $0x3,%r12d
  jmp    L169
L739:
  movzbl 0x2(%r15),%eax
  cmp    $0x2a,%al
  jne    L806
  jmp    L947
L1073:
  mov    %ebp,%r13d
  mov    $0x1,%r12d
  xor    %ebp,%ebp
  jmp    L70
L1023:
  mov    %rbx,%r15
  xor    %r12d,%r12d
  jmp    L856
L260:
  sub    %ebp,%r13d
  jmp    L230
L473:
  imul   %ebp,%r13d
  jmp    L230
L741:
  add    %r13d,%ebp
  mov    %r14,%rbx
  jmp    L947
L289:
  mov    %ebp,%r12d
  mov    %r14,%r15
  mov    %r13d,%ebp
  jmp    L856
L337:
  imul   %r13d,%ebp
  mov    %r14,%r15
  jmp    L959
L296:
  mov    %ebp,%r12d
  mov    %r14,%rbx
  mov    %r13d,%ebp
  jmp    L1058
```

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