user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<DrawlineBmp>:
  endbr64
  push   %rbp
  mov    %r8d,%r11d
  mov    %ecx,%r10d
  sub    %edx,%r8d
  push   %rbx
  mov    %r9d,%ebx
  sub    %esi,%ecx
  js     L103
  test   %r8d,%r8d
  js     L8
  test   %ecx,%ecx
  jne    L112
  test   %r8d,%r8d
  jne    L35
  lea    (%rdx,%rdx,4),%eax
  shl    $0x7,%eax
  add    %esi,%eax
  cltq
  mov    %r9w,(%rdi,%rax,2)
L79:
  pop    %rbx
  pop    %rbp
  ret
  xchg   %ax,%ax
L8:
  test   %ecx,%ecx
  jne    L15
  sub    %r11d,%edx
  pop    %rbx
  movzwl %r9w,%r9d
  xor    %ecx,%ecx
  mov    %edx,%r8d
  pop    %rbp
  mov    %r11d,%edx
  jmp    1060 <DrawVlineBmp@plt>
  xchg   %ax,%ax
L103:
  test   %r8d,%r8d
  js     L18
  je     L43
  mov    $0x280,%r11d
  mov    $0xffffffff,%r10d
L70:
  imul   %r10d,%ecx
  lea    (%rdx,%rdx,4),%eax
  shl    $0x7,%eax
  lea    0x1(%r8),%r9d
  add    %esi,%eax
  lea    0x1(%rcx),%ebp
  cmp    %ecx,%r8d
  jg     L119
  test   %ebp,%ebp
  jle    L79
  mov    %r9d,%edx
  mov    %ebp,%r9d
  mov    %edx,%ebp
  mov    %r11d,%edx
  mov    %r10d,%r11d
  mov    %edx,%r10d
L119:
  xor    %edx,%edx
  xor    %ecx,%ecx
  nopl   0x0(%rax,%rax,1)
L42:
  movslq %eax,%rsi
  add    %ebp,%edx
  mov    %bx,(%rdi,%rsi,2)
  cmp    %r9d,%edx
  jl     L143
  sub    %r9d,%edx
  add    %r10d,%eax
L143:
  add    $0x1,%ecx
  add    %r11d,%eax
  cmp    %r9d,%ecx
  jl     L42
  pop    %rbx
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L43:
  sub    %r10d,%esi
  pop    %rbx
  movzwl %r9w,%r9d
  xor    %r8d,%r8d
  mov    %esi,%ecx
  pop    %rbp
  mov    %r10d,%esi
  jmp    1070 <DrawHlineBmp@plt>
  xchg   %ax,%ax
L18:
  mov    $0xffffffff,%r10d
L32:
  mov    %edx,%r8d
  sub    %r11d,%r8d
  mov    $0xfffffd80,%r11d
  jmp    L70
  nopw   0x0(%rax,%rax,1)
L35:
  pop    %rbx
  movzwl %r9w,%r9d
  pop    %rbp
  jmp    1060 <DrawVlineBmp@plt>
  nopl   0x0(%rax,%rax,1)
L112:
  test   %r8d,%r8d
  jne    L134
  pop    %rbx
  movzwl %r9w,%r9d
  pop    %rbp
  jmp    1070 <DrawHlineBmp@plt>
L15:
  mov    $0x1,%r10d
  jmp    L32
L134:
  mov    $0x280,%r11d
  mov    $0x1,%r10d
  jmp    L70
```

assistant: ```c
void DrawlineBmp(unsigned short *buffer, int x1, int y1, int x2, int y2, unsigned short color) {
  int pixx, pixy;
  int x, y;
  int dx, dy;
  int sx, sy;
  int swaptmp;
  int idx;
  dx = x2 - x1;
  dy = y2 - y1;
  sx = (dx >= 0) ? 1 : -1;
  sy = (dy >= 0) ? 1 : -1;
  if (dx == 0) {
    if (dy > 0) {
      DrawVlineBmp(buffer, x1, y1, 0, dy, color);
      return;
    } else if (dy < 0) {
      DrawVlineBmp(buffer, x1, y2, 0, -dy, color);
      return;
    } else {
      idx = x1 + y1 * 640;
      buffer[idx] = color;
      return;
    }
  }
  if (dy == 0) {
    if (dx > 0) {
      DrawHlineBmp(buffer, x1, y1, dx, 0, color);
      return;
    } else if (dx < 0) {
      DrawHlineBmp(buffer, x2, y1, -dx, 0, color);
      return;
    }
  }
  dx = sx * dx + 1;
  dy = sy * dy + 1;
  pixx = 1;
  pixy = 640;
  pixx *= sx;
  pixy *= sy;
  if (dx < dy) {
    swaptmp = dx;
    dx = dy;
    dy = swaptmp;
    swaptmp = pixx;
    pixx = pixy;
    pixy = swaptmp;
  }
  x = 0;
  y = 0;
  idx = x1 + y1 * 640;
  for (; x < dx; x++, idx += pixx) {
    buffer[idx] = color;
    y += dy;
    if (y >= dx) {
      y -= dx;
      idx += pixy;
    }
  }
}
```