user: 请从给定的汇编指令推导出C源代码：

```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,-0x5c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  movslq %esi,%rax
  mov    %rsp,%rsi
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rdi
  and    $0xfffffffffffffff0,%rdx
  sub    %rdi,%rsi
  cmp    %rsi,%rsp
  je     L139
L44:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L44
L139:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L186
L9:
  mov    %rax,%rdi
  lea    0x3(%rsp),%r13
  mov    %rsp,%rsi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rdi
  mov    %r13,%r8
  and    $0xfffffffffffffffc,%r13
  and    $0xfffffffffffffff0,%rdx
  sub    %rdi,%rsi
  mov    %r13,-0x58(%rbp)
  shr    $0x2,%r8
  cmp    %rsi,%rsp
  je     L98
L8:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L8
L98:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L102
L121:
  mov    %rax,%rdx
  mov    %rsp,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%r12
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rdx
  cmp    %rsi,%rsp
  je     L188
L4:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L4
L188:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L65
  orq    $0x0,-0x8(%rsp,%rdx,1)
L65:
  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    -0x5c(%rbp),%eax
  lea    -0x1(%rax),%ecx
  mov    %ecx,-0x60(%rbp)
  lea    -0x2(%rax),%ecx
  mov    %ecx,-0x64(%rbp)
  cmp    $0x1,%eax
  jle    L193
  mov    -0x58(%rbp),%rax
  lea    0x4(%r15),%r8
  mov    $0x1,%ebx
  lea    0x4(%rax),%r14
  mov    %ecx,%eax
  lea    0x8(%r15,%rax,4),%rax
  mov    %rax,-0x50(%rbp)
  jmp    L210
  nopw   0x0(%rax,%rax,1)
L155:
  mov    (%r8),%edx
  cltq
  mov    %edx,0x0(%r13,%rax,4)
L212:
  mov    %ebx,(%r14)
  add    $0x4,%r8
  add    $0x4,%r14
  cmp    -0x50(%rbp),%r8
  je     L46
L210:
  mov    (%r8),%edx
  mov    %ebx,%esi
  mov    %r13,%rdi
  mov    %r8,-0x48(%rbp)
  call   <lower_bound@plt>
  mov    -0x48(%rbp),%r8
  cmp    %ebx,%eax
  jne    L155
  mov    (%r8),%edx
  movslq %ebx,%rax
  add    $0x1,%ebx
  mov    %edx,0x0(%r13,%rax,4)
  jmp    L212
  nopl   0x0(%rax)
L186:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L9
L102:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L121
  cs nopw 0x0(%rax,%rax,1)
L46:
  movslq -0x60(%rbp),%rax
  movl   $0x1,(%r12,%rax,4)
L156:
  movslq -0x64(%rbp),%rbx
  mov    $0x1,%r14d
  jmp    L0
  nopl   0x0(%rax,%rax,1)
L119:
  mov    (%r15,%rbx,4),%edx
  mov    %r14d,(%r12,%rbx,4)
  cltq
  sub    $0x1,%rbx
  mov    %edx,0x0(%r13,%rax,4)
  test   %ebx,%ebx
  js     L123
L0:
  mov    (%r15,%rbx,4),%edx
  mov    %r14d,%esi
  mov    %r13,%rdi
  call   <lower_bound@plt>
  cmp    %r14d,%eax
  jne    L119
  mov    (%r15,%rbx,4),%edx
  movslq %r14d,%rax
  add    $0x1,%r14d
  mov    %r14d,(%r12,%rbx,4)
  sub    $0x1,%rbx
  mov    %edx,0x0(%r13,%rax,4)
  test   %ebx,%ebx
  jns    L0
L123:
  mov    -0x5c(%rbp),%eax
  test   %eax,%eax
  jle    L254
  mov    -0x60(%rbp),%ebx
  xor    %r14d,%r14d
  mov    $0x1,%esi
  xor    %edi,%edi
  shl    $0x2,%rbx
  jmp    L35
  nopl   0x0(%rax)
L145:
  mov    -0x58(%rbp),%rax
  mov    0x4(%rax,%r14,1),%esi
  add    $0x4,%r14
L35:
  add    (%r12,%r14,1),%esi
  sub    $0x1,%esi
  call   <max@plt>
  mov    %eax,%edi
  cmp    %r14,%rbx
  jne    L145
L208:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L57
  lea    -0x28(%rbp),%rsp
  mov    %edi,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L254:
  xor    %edi,%edi
  jmp    L208
L193:
  movslq -0x60(%rbp),%rax
  mov    -0x64(%rbp),%edx
  movl   $0x1,(%r12,%rax,4)
  test   %edx,%edx
  js     L123
  jmp    L156
L57:
  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;
}
```