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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rsi
  lea    D1(%rip),%rdi
  call   <scanf@plt>
  cmpl   $0x0,0x10(%rsp)
  jle    L87
  mov    $0x0,%r12d
  lea    0x4(%rsp),%r15
  lea    0x16(%rsp),%r13
  lea    D5(%rip),%r14
  jmp    L68
L165:
  cmp    $0x2f,%al
  jne    L29
  mov    (%rsp),%ebp
  imul   0xc(%rsp),%ebp
  mov    0x4(%rsp),%ebx
  imul   0x8(%rsp),%ebx
  jmp    L29
L30:
  mov    0xc(%rsp),%ebx
  mov    0x8(%rsp),%eax
  mov    %ebx,%ebp
  imul   (%rsp),%ebp
  mov    %eax,%edx
  imul   0x4(%rsp),%edx
  sub    %edx,%ebp
  imul   %eax,%ebx
  jmp    L29
L51:
  mov    (%rsp),%ebp
  imul   0x4(%rsp),%ebp
  mov    0x8(%rsp),%ebx
  imul   0xc(%rsp),%ebx
  jmp    L29
L125:
  sub    $0x1,%ecx
  je     L80
L90:
  mov    %esi,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  jne    L125
  mov    %r8d,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  jne    L125
  mov    %esi,%eax
  cltd
  idiv   %ecx
  mov    %eax,%esi
  mov    %r8d,%eax
  cltd
  idiv   %ecx
  mov    %eax,%r8d
  jmp    L125
L80:
  mov    %esi,%ecx
  mov    %ebx,%edx
  mov    %ebp,%esi
  lea    D8(%rip),%rdi
  call   <printf@plt>
  add    $0x1,%r12d
  cmp    %r12d,0x10(%rsp)
  jle    L87
L68:
  lea    0x8(%rsp),%rcx
  mov    %rsp,%rsi
  lea    0xc(%rsp),%rax
  push   %rax
  push   %r13
  mov    %r15,%r9
  lea    0x27(%rsp),%r8
  mov    %r13,%rdx
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  movzbl 0x27(%rsp),%eax
  add    $0x10,%rsp
  cmp    $0x2d,%al
  je     L30
  jg     L165
  cmp    $0x2a,%al
  je     L51
  cmp    $0x2b,%al
  jne    L29
  mov    0xc(%rsp),%ebx
  mov    0x8(%rsp),%eax
  mov    %ebx,%ebp
  imul   (%rsp),%ebp
  mov    %eax,%edx
  imul   0x4(%rsp),%edx
  add    %edx,%ebp
  imul   %eax,%ebx
L29:
  mov    %ebx,%r8d
  mov    %ebp,%esi
  mov    $0x3e8,%ecx
  jmp    L90
L87:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L128
  mov    $0x0,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L128:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D1
type: string
name: read_data
arguments: data_tag: D5
type: string
name: read_data
arguments: data_tag: D8
type: string

tool: D1: %d

tool: D5: %d %c %d %c %d %c %d

tool: D8: %d/%d = %d/%d


assistant: ```c
int main() {
  char a[2];
  int i, j, k, n1, n2, d1, d2;
  int ans[4], loop;
  scanf("%d", &loop);
  for (i = 0; i < loop; i++) {
    scanf("%d %c %d %c %d %c %d", &n1, &a[0], &d1, &a[1], &n2, &a[0], &d2);
    switch (a[1]) {
    case '+':
      ans[0] = (n1 * d2 + n2 * d1);
      ans[1] = (d1 * d2);
      break;
    case '-':
      ans[0] = (n1 * d2 - n2 * d1);
      ans[1] = (d1 * d2);
      break;
    case '*':
      ans[0] = (n1 * n2);
      ans[1] = (d1 * d2);
      break;
    case '/':
      ans[0] = (n1 * d2);
      ans[1] = (n2 * d1);
      break;
    }
    ans[2] = ans[0];
    ans[3] = ans[1];
    for (j = 1000; j > 0; j--) {
      if (ans[2] % j == 0 && ans[3] % j == 0) {
        ans[2] = ans[2] / j;
        ans[3] = ans[3] / j;
      }
    }
    printf("%d/%d = %d/%d\n", ans[0], ans[1], ans[2], ans[3]);
  }
  return 0;
}
```