user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    -0x40(%rbp),%rsi
  lea    D5(%rip),%rdi
  call   <scanf@plt>
  mov    -0x40(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  je     L157
  lea    D5(%rip),%r14
  jmp    L31
L84:
  mov    %rsi,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L130
  orq    $0x0,-0x8(%rsp,%rdx,1)
L130:
  mov    %rsp,%r13
  test   %eax,%eax
  jle    L121
  mov    %r13,%r12
  mov    $0x0,%ebx
L90:
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <scanf@plt>
  add    $0x1,%ebx
  mov    -0x3c(%rbp),%eax
  add    $0x4,%r12
  cmp    %ebx,%eax
  jg     L90
L121:
  lea    -0x1(%rax),%ecx
  test   %ecx,%ecx
  jle    L115
  mov    $0x0,%r9d
  mov    $0x0,%eax
  jmp    L77
L112:
  add    $0x2,%r9d
  mov    %edi,%eax
  jmp    L172
L110:
  test   %eax,%eax
  je     L111
  mov    %edi,%eax
  jmp    L172
L111:
  add    $0x2,%r9d
  mov    $0x1,%eax
  jmp    L172
L71:
  mov    %edi,%eax
L172:
  cmp    %ecx,%eax
  jge    L3
L77:
  movslq %eax,%rdx
  lea    0x0(%r13,%rdx,4),%rdx
  mov    (%rdx),%esi
  lea    0x1(%rax),%edi
  cmp    0x4(%rdx),%esi
  je     L71
  mov    -0x4(%rdx),%edx
  test   %eax,%eax
  setg   %r8b
  cmp    %edx,%esi
  jne    L183
  test   %r8b,%r8b
  jne    L112
L183:
  cmp    %edx,%esi
  je     L110
  test   %r8b,%r8b
  je     L110
  add    $0x1,%r9d
  mov    %edi,%eax
  jmp    L172
L115:
  mov    $0x0,%r9d
L3:
  mov    %r9d,%esi
  lea    D11(%rip),%rdi
  call   <printf@plt>
  mov    %r15,%rsp
  mov    -0x40(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  je     L157
L31:
  mov    %rsp,%r15
  lea    -0x3c(%rbp),%rsi
  mov    %r14,%rdi
  call   <scanf@plt>
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rdx
  lea    0xf(,%rdx,4),%rdx
  mov    %rdx,%rsi
  and    $0xfffffffffffffff0,%rsi
  and    $0xfffffffffffff000,%rdx
  mov    %rsp,%rcx
  sub    %rdx,%rcx
L102:
  cmp    %rcx,%rsp
  je     L84
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L102
L157:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L182
  mov    $0x0,%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L182:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D5
datatype: string
name: parse_data
arguments: data_tag: D11
datatype: string

tool: D5: %d

tool: D11: %d


assistant: ```c
int main() {
  int t;
  int i, j, flag, n, count;
  scanf("%d", &t);
  while (t--) {
    count = 0;
    scanf("%d", &n);
    int arr[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &arr[i]);
    }
    for (i = 0; i < n - 1; i++) {
      if (arr[i] != arr[i + 1]) {
        if (arr[i] == arr[i - 1] && i > 0)
          count += 2;
        else if (arr[i] != arr[i - 1] && i > 0)
          count += 1;
        else if (i == 0)
          count += 2;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}
```