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

```asm
<ecdsa_sig_to_der>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  movl   $0x30,(%rax)
  addq   $0x4,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  addq   $0x4,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  movl   $0x2,(%rax)
  addq   $0x4,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  addq   $0x4,-0x20(%rbp)
  movl   $0x0,-0x24(%rbp)
  jmp    L88
L111:
  addl   $0x1,-0x24(%rbp)
L88:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L79
  cmpl   $0x1f,-0x24(%rbp)
  jle    L111
L79:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0x7f,%eax
  jle    L22
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  addq   $0x4,-0x20(%rbp)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L22
L1:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  addq   $0x4,-0x20(%rbp)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  addl   $0x1,-0x24(%rbp)
L22:
  cmpl   $0x1f,-0x24(%rbp)
  jle    L1
  mov    -0x20(%rbp),%rax
  movl   $0x2,(%rax)
  addq   $0x4,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  addq   $0x4,-0x20(%rbp)
  movl   $0x20,-0x24(%rbp)
  jmp    L36
L45:
  addl   $0x1,-0x24(%rbp)
L36:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L112
  cmpl   $0x3f,-0x24(%rbp)
  jle    L45
L112:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0x7f,%eax
  jle    L116
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  addq   $0x4,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L116
L11:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  addq   $0x4,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,(%rax)
  addl   $0x1,-0x24(%rbp)
L116:
  cmpl   $0x3f,-0x24(%rbp)
  jle    L11
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  add    %edx,%eax
  lea    0x4(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  add    $0x2,%eax
  pop    %rbp
  ret
```

assistant: ```c
int ecdsa_sig_to_der(const uint8_t *sig, uint8_t *der) {
  int i;
  uint8_t *p = der, *len, *len1, *len2;
  *p = 0x30;
  p++;
  *p = 0x00;
  len = p;
  p++;
  *p = 0x02;
  p++;
  *p = 0x00;
  len1 = p;
  p++;
  i = 0;
  while (sig[i] == 0 && i < 32) {
    i++;
  }
  if (sig[i] >= 0x80) {
    *p = 0x00;
    p++;
    *len1 = *len1 + 1;
  }
  while (i < 32) {
    *p = sig[i];
    p++;
    *len1 = *len1 + 1;
    i++;
  }
  *p = 0x02;
  p++;
  *p = 0x00;
  len2 = p;
  p++;
  i = 32;
  while (sig[i] == 0 && i < 64) {
    i++;
  }
  if (sig[i] >= 0x80) {
    *p = 0x00;
    p++;
    *len2 = *len2 + 1;
  }
  while (i < 64) {
    *p = sig[i];
    p++;
    *len2 = *len2 + 1;
    i++;
  }
  *len = *len1 + *len2 + 4;
  return *len + 2;
}
```