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

```asm
<ibitmap_clip>:
  endbr64
  push   %r15
  mov    %rsi,%rax
  mov    %r9d,%r15d
  sar    $0x2,%r9d
  push   %r14
  sar    %r15d
  and    $0x1,%r9d
  mov    0x4(%r8),%r11d
  push   %r13
  and    $0x1,%r15d
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x8(%rdi),%ebx
  mov    0xc(%rdi),%esi
  mov    (%rdi),%r12d
  mov    0x4(%rdi),%r13d
  mov    (%rax),%ebp
  mov    %rdx,-0x10(%rsp)
  mov    0x4(%rax),%r10d
  mov    0x8(%rax),%r14d
  mov    (%rcx),%edi
  mov    %rcx,-0x8(%rsp)
  mov    %ebx,-0x1c(%rsp)
  mov    (%r8),%ecx
  mov    %esi,-0x18(%rsp)
  mov    0xc(%rax),%ebx
  mov    (%rdx),%esi
  mov    0x8(%r8),%eax
  mov    %r9d,-0x14(%rsp)
  mov    0xc(%r8),%edx
  cmp    -0x1c(%rsp),%r12d
  jge    L401
  cmp    -0x18(%rsp),%r13d
  jge    L401
  cmp    %r14d,%ebp
  jge    L401
  cmp    %ebx,%r10d
  jge    L401
  cmp    %eax,%ebp
  jge    L419
  cmp    %edx,%r10d
  jge    L419
  cmp    %ecx,%r14d
  jle    L419
  cmp    %r11d,%ebx
  jle    L419
  cmp    %esi,%r12d
  jle    L177
  mov    %r12d,%r9d
  sub    %esi,%r9d
  test   %r15d,%r15d
  jne    L249
  add    %r9d,%ecx
  mov    %r12d,%esi
L177:
  cmp    %edi,%r13d
  jle    L146
L297:
  mov    %r13d,%r9d
  sub    %edi,%r9d
  mov    -0x14(%rsp),%edi
  test   %edi,%edi
  jne    L6
  add    %r9d,%r11d
  mov    %r13d,%edi
L146:
  mov    %eax,%r12d
  mov    %edx,%r9d
  sub    %ecx,%r12d
  sub    %r11d,%r9d
  mov    %r12d,%r13d
  or     %r9d,%r13d
  js     L104
  mov    -0x1c(%rsp),%r13d
  add    %esi,%r12d
  cmp    %r13d,%r12d
  jle    L312
  sub    %r13d,%r12d
  test   %r15d,%r15d
  jne    L147
  sub    %r12d,%eax
L312:
  mov    -0x18(%rsp),%r13d
  add    %edi,%r9d
  cmp    %r13d,%r9d
  jle    L251
L51:
  mov    -0x14(%rsp),%r12d
  sub    %r13d,%r9d
  test   %r12d,%r12d
  jne    L45
  sub    %r9d,%edx
L251:
  cmp    %eax,%ecx
  setge  %r12b
  cmp    %edx,%r11d
  setge  %r9b
  or     %r9b,%r12b
  jne    L227
  cmp    %ebp,%ecx
  jl     L412
  cmp    %r10d,%r11d
  jl     L49
  mov    %r11d,%r10d
L237:
  cmp    %r14d,%eax
  jle    L149
  sub    %r14d,%eax
  add    %esi,%eax
  test   %r15d,%r15d
  cmovne %eax,%esi
  mov    %r14d,%eax
  cmp    %ebx,%edx
  jg     L244
  mov    %edx,%ebx
L130:
  cmp    %ecx,%eax
  jle    L425
  cmp    %r10d,%ebx
  jle    L425
L41:
  mov    -0x10(%rsp),%rdx
  mov    %esi,(%rdx)
  mov    -0x8(%rsp),%rsi
  mov    %edi,(%rsi)
  mov    %ecx,(%r8)
  mov    %r10d,0x4(%r8)
  mov    %ebx,0xc(%r8)
  mov    %eax,0x8(%r8)
  xor    %eax,%eax
L144:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L412:
  mov    %ebp,%r9d
  sub    %ecx,%r9d
  mov    %ebp,%ecx
  add    %esi,%r9d
  test   %r15d,%r15d
  cmove  %r9d,%esi
  cmp    %ebp,%eax
  setle  %r9b
  cmp    %r10d,%r11d
  jl     L28
  mov    %r11d,%r10d
L132:
  test   %r9b,%r9b
  jne    L324
  test   %r12b,%r12b
  je     L237
L324:
  mov    $0xfffffffb,%eax
  jmp    L144
  nopl   (%rax)
L49:
  xor    %r9d,%r9d
L28:
  cmp    %r10d,%edx
  mov    %r10d,%ebp
  setle  %r12b
  sub    %r11d,%ebp
  mov    -0x14(%rsp),%r11d
  add    %edi,%ebp
  test   %r11d,%r11d
  cmove  %ebp,%edi
  jmp    L132
  nopw   0x0(%rax,%rax,1)
L244:
  mov    -0x14(%rsp),%r9d
  sub    %ebx,%edx
  add    %edi,%edx
  test   %r9d,%r9d
  cmovne %edx,%edi
  jmp    L130
  nopl   0x0(%rax)
L149:
  cmp    %ebx,%edx
  jg     L244
  mov    %edx,%ebx
  jmp    L41
  nopl   0x0(%rax,%rax,1)
L6:
  sub    %r9d,%edx
  mov    %r13d,%edi
  jmp    L146
  nopl   0x0(%rax,%rax,1)
L249:
  sub    %r9d,%eax
  mov    %r12d,%esi
  cmp    %edi,%r13d
  jle    L146
  jmp    L297
  nopl   0x0(%rax)
L45:
  add    %r9d,%r11d
  jmp    L251
  nopl   0x0(%rax,%rax,1)
L147:
  mov    -0x18(%rsp),%r13d
  add    %edi,%r9d
  add    %r12d,%ecx
  cmp    %r13d,%r9d
  jle    L251
  jmp    L51
  nopl   0x0(%rax)
L401:
  mov    $0xffffffff,%eax
  jmp    L144
  nopw   0x0(%rax,%rax,1)
L419:
  mov    $0xfffffffe,%eax
  jmp    L144
L104:
  mov    $0xfffffffd,%eax
  jmp    L144
L227:
  mov    $0xfffffffc,%eax
  jmp    L144
L425:
  mov    $0xfffffffa,%eax
  jmp    L144
```

assistant: ```c
int ibitmap_clip(const int *clipdst, const int *clipsrc, int *x, int *y, int *rectsrc, int clip) {
  int dcl = clipdst[0];
  int dct = clipdst[1];
  int dcr = clipdst[2];
  int dcb = clipdst[3];
  int scl = clipsrc[0];
  int sct = clipsrc[1];
  int scr = clipsrc[2];
  int scb = clipsrc[3];
  int dx = *x;
  int dy = *y;
  int sl = rectsrc[0];
  int st = rectsrc[1];
  int sr = rectsrc[2];
  int sb = rectsrc[3];
  int hflip, vflip;
  int w, h, d;
  hflip = (clip & 2) ? 1 : 0;
  vflip = (clip & 4) ? 1 : 0;
  if (dcr <= dcl || dcb <= dct || scr <= scl || scb <= sct)
    return -1;
  if (sr <= scl || sb <= sct || sl >= scr || st >= scb)
    return -2;
  if (dx < dcl) {
    d = dcl - dx;
    dx = dcl;
    if (!hflip)
      sl += d;
    else
      sr -= d;
  }
  if (dy < dct) {
    d = dct - dy;
    dy = dct;
    if (!vflip)
      st += d;
    else
      sb -= d;
  }
  w = sr - sl;
  h = sb - st;
  if (w < 0 || h < 0)
    return -3;
  if (dx + w > dcr) {
    d = dx + w - dcr;
    if (!hflip)
      sr -= d;
    else
      sl += d;
  }
  if (dy + h > dcb) {
    d = dy + h - dcb;
    if (!vflip)
      sb -= d;
    else
      st += d;
  }
  if (sl >= sr || st >= sb)
    return -4;
  if (sl < scl) {
    d = scl - sl;
    sl = scl;
    if (!hflip)
      dx += d;
  }
  if (st < sct) {
    d = sct - st;
    st = sct;
    if (!vflip)
      dy += d;
  }
  if (sl >= sr || st >= sb)
    return -5;
  if (sr > scr) {
    d = sr - scr;
    sr = scr;
    if (hflip)
      dx += d;
  }
  if (sb > scb) {
    d = sb - scb;
    sb = scb;
    if (vflip)
      dy += d;
  }
  if (sl >= sr || st >= sb)
    return -6;
  *x = dx;
  *y = dy;
  rectsrc[0] = sl;
  rectsrc[1] = st;
  rectsrc[2] = sr;
  rectsrc[3] = sb;
  return 0;
}
```