user: 请将以下的汇编代码转换成C语言代码:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  lea    -0x40(%rbp),%rsi
  push   %r13
  push   %r12
  push   %rbx
  lea    D2(%rip),%rbx
  mov    %rbx,%rdi
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <scanf@plt>
  mov    -0x40(%rbp),%eax
  lea    -0x3c(%rbp),%rsi
  mov    %rsi,-0x50(%rbp)
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  je     L87
L32:
  mov    -0x50(%rbp),%rsi
  mov    %rbx,%rdi
  mov    %rsp,-0x48(%rbp)
  call   <scanf@plt>
  movslq -0x3c(%rbp),%rax
  mov    %rsp,%rcx
  mov    %rax,%rsi
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rdi
  and    $0xfffffffffffffff0,%rdx
  sub    %rdi,%rcx
  cmp    %rcx,%rsp
  je     L116
L128:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L128
L116:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L9
  orq    $0x0,-0x8(%rsp,%rdx,1)
L9:
  mov    %rax,%rdx
  mov    %rsp,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%r15
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L23
L107:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L107
L23:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L24
L71:
  mov    %rsp,%r14
  mov    %r15,%r12
  xor    %r13d,%r13d
  test   %esi,%esi
  jle    L58
  nopw   0x0(%rax,%rax,1)
L155:
  mov    %r12,%rsi
  mov    %rbx,%rdi
  add    $0x4,%r12
  call   <scanf@plt>
  mov    -0x3c(%rbp),%esi
  movl   $0x0,(%r14,%r13,4)
  add    $0x1,%r13
  cmp    %r13d,%esi
  jg     L155
  test   %esi,%esi
  jle    L58
  movslq %esi,%r11
  xor    %r10d,%r10d
  xor    %r8d,%r8d
  jmp    L164
  cs nopw 0x0(%rax,%rax,1)
L33:
  add    $0x1,%r10
  cmp    %r10,%r11
  je     L172
L164:
  cmpl   $0x1,(%r14,%r10,4)
  mov    %r10d,%ecx
  je     L33
  mov    (%r15,%r10,4),%r9d
  movl   $0x1,(%r14,%r10,4)
  lea    0x1(%r9,%r10,1),%eax
  jmp    L21
  nopw   0x0(%rax,%rax,1)
L63:
  cltq
  movl   $0x1,(%r14,%rax,4)
  add    (%r15,%rax,4),%edi
  movl   $0x1,(%r14,%r10,4)
  mov    %edi,%eax
  add    $0x1,%eax
L21:
  cltd
  add    $0x1,%r8d
  idiv   %esi
  movslq %edx,%rax
  cmpl   $0x1,(%r14,%rax,4)
  mov    %rax,%rdi
  jne    L63
  cmp    %r10d,%eax
  jne    L213
  jmp    L33
  cs nopw 0x0(%rax,%rax,1)
L79:
  movslq %edx,%rax
  mov    (%r15,%rax,4),%r9d
L213:
  lea    0x1(%r9,%rcx,1),%eax
  sub    $0x1,%r8d
  cltd
  idiv   %esi
  mov    %edx,%ecx
  cmp    %edi,%edx
  jne    L79
  add    $0x1,%r10
  cmp    %r10,%r11
  jne    L164
L172:
  mov    %r8d,%esi
  lea    D12(%rip),%rdi
  call   <printf@plt>
  mov    -0x40(%rbp),%eax
  mov    -0x48(%rbp),%rsp
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  jne    L32
L87:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L132
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L58:
  xor    %r8d,%r8d
  jmp    L172
L24:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L71
L132:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D2
type: string
name: retrieve_data
arguments: tag: D12
type: string

tool: D2: %d

tool: D12: %d


assistant: ```c
int main(void) {
  int t, n, count, k, j, i;
  scanf("%d", &t);
  while (t--) {
    count = 0;
    scanf("%d", &n);
    int ar[n], visit[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &ar[i]);
      visit[i] = 0;
    }
    for (i = 0; i < n; i++) {
      j = i;
      k = i;
      if (visit[i] != 1)
        while (1) {
          visit[i] = 1;
          j = (j + ar[j] + 1) % n;
          count++;
          if (visit[j] == 1)
            break;
          visit[j] = 1;
        }
      while (k != j) {
        k = (k + ar[k] + 1) % n;
        count--;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}
```