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

```asm
<longest_bitonic_sequence>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %esi,-0x64(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  movslq %esi,%rax
  mov    %rsp,%rsi
  mov    %rax,-0x58(%rbp)
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rdi
  and    $0xfffffffffffffff0,%rdx
  sub    %rdi,%rsi
  cmp    %rsi,%rsp
  je     L133
L84:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L84
L133:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L117
L92:
  mov    %rax,%rdi
  lea    0x3(%rsp),%r12
  mov    %rsp,%rsi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rdi
  mov    %r12,%r8
  and    $0xfffffffffffffffc,%r12
  and    $0xfffffffffffffff0,%rdx
  sub    %rdi,%rsi
  mov    %r12,-0x50(%rbp)
  shr    $0x2,%r8
  cmp    %rsi,%rsp
  je     L108
L62:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L62
L108:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L13
L193:
  mov    %rax,%rdx
  mov    %rsp,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rbx
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rdx
  cmp    %rsi,%rsp
  je     L55
L45:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L45
L55:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L134
  orq    $0x0,-0x8(%rsp,%rdx,1)
L134:
  lea    0x3(%rsp),%rdi
  mov    (%r15),%edx
  movl   $0x1,0x0(,%r8,4)
  mov    %rdi,%rax
  and    $0xfffffffffffffffc,%rdi
  shr    $0x2,%rax
  mov    %rdi,%r13
  mov    %edx,0x0(,%rax,4)
  mov    -0x64(%rbp),%eax
  lea    -0x1(%rax),%ecx
  mov    %ecx,-0x68(%rbp)
  lea    -0x2(%rax),%ecx
  mov    %ecx,-0x6c(%rbp)
  cmp    $0x1,%eax
  jle    L152
  mov    -0x50(%rbp),%rax
  lea    0x4(%r15),%r8
  mov    $0x1,%r12d
  lea    0x4(%rax),%r14
  mov    %ecx,%eax
  lea    0x8(%r15,%rax,4),%rax
  mov    %rax,-0x60(%rbp)
  nopl   (%rax)
L199:
  mov    (%r8),%edx
  mov    %r12d,%esi
  mov    %r13,%rdi
  mov    %r8,-0x48(%rbp)
  call   <lower_bound@plt>
  mov    -0x48(%rbp),%r8
  cmp    %r12d,%eax
  je     L165
  mov    (%r8),%edx
  cltq
  mov    %r12d,(%r14)
  add    $0x4,%r8
  add    $0x4,%r14
  mov    %edx,0x0(%r13,%rax,4)
  cmp    -0x60(%rbp),%r8
  jne    L199
L154:
  movslq -0x68(%rbp),%rax
  movl   $0x1,(%rbx,%rax,4)
L39:
  movslq -0x6c(%rbp),%r14
  mov    $0x1,%r12d
  nopw   0x0(%rax,%rax,1)
L66:
  mov    (%r15,%r14,4),%edx
  mov    %r12d,%esi
  mov    %r13,%rdi
  call   <lower_bound@plt>
  cmp    %r12d,%eax
  je     L118
  mov    (%r15,%r14,4),%edx
  mov    %r12d,(%rbx,%r14,4)
  cltq
  sub    $0x1,%r14
  mov    %edx,0x0(%r13,%rax,4)
  test   %r14d,%r14d
  jns    L66
L229:
  mov    -0x64(%rbp),%eax
  xor    %r14d,%r14d
  xor    %edi,%edi
  test   %eax,%eax
  jle    L215
  nopl   0x0(%rax)
L125:
  mov    -0x50(%rbp),%rax
  mov    (%rbx,%r14,4),%esi
  add    (%rax,%r14,4),%esi
  add    $0x1,%r14
  sub    $0x1,%esi
  call   <max@plt>
  mov    %eax,%edi
  cmp    %r14,-0x58(%rbp)
  jne    L125
L215:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L207
  lea    -0x28(%rbp),%rsp
  mov    %edi,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L117:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L92
L13:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L193
  xchg   %ax,%ax
L118:
  mov    (%r15,%r14,4),%edx
  lea    0x1(%r12),%eax
  movslq %r12d,%rsi
  mov    %eax,(%rbx,%r14,4)
  sub    $0x1,%r14
  mov    %edx,0x0(%r13,%rsi,4)
  test   %r14d,%r14d
  js     L229
  mov    %eax,%r12d
  jmp    L66
  nopw   0x0(%rax,%rax,1)
L165:
  mov    (%r8),%edx
  lea    0x1(%r12),%eax
  movslq %r12d,%rsi
  add    $0x4,%r8
  mov    %eax,(%r14)
  add    $0x4,%r14
  mov    %edx,0x0(%r13,%rsi,4)
  cmp    -0x60(%rbp),%r8
  je     L154
  mov    %eax,%r12d
  jmp    L199
L152:
  movslq -0x68(%rbp),%rax
  mov    -0x6c(%rbp),%edx
  movl   $0x1,(%rbx,%rax,4)
  test   %edx,%edx
  js     L229
  jmp    L39
L207:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int longest_bitonic_sequence(int v[], int n) {
  int lis[n];
  int lds[n];
  int tail[n], tailSize;
  int i;
  tail[0] = v[0];
  tailSize = 1;
  lis[0] = 1;
  for (i = 1; i < n; ++i) {
    int idx = lower_bound(tail, tailSize, v[i]);
    if (idx == tailSize)
      tail[tailSize++] = v[i];
    else
      tail[idx] = v[i];
    lis[i] = tailSize;
  }
  tailSize = 1;
  lds[n - 1] = 1;
  for (int i = n - 2; i >= 0; --i) {
    int idx = lower_bound(tail, tailSize, v[i]);
    if (idx == tailSize)
      tail[tailSize++] = v[i];
    else
      tail[idx] = v[i];
    lds[i] = tailSize;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    ans = max(ans, lis[i] + lds[i] - 1);
  return ans;
}
```