user: Translate the below assembly code into C programming language:

```asm
<__imlib_CalcApoints>:
  endbr64
  push   %r15
  mov    %ecx,%r15d
  push   %r14
  mov    %edi,%r14d
  push   %r13
  mov    %r8d,%r13d
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x18,%rsp
  movl   $0x0,0x8(%rsp)
  test   %esi,%esi
  jns    L190
  movl   $0x1,0x8(%rsp)
  neg    %ebp
L190:
  lea    0x0(,%rbp,4),%edi
  call   <malloc@plt>
  lea    (%rbx,%r15,1),%ecx
  mov    %rax,%r12
  cmp    %ebp,%ecx
  jle    L148
  cmp    %ebx,%ebp
  jge    L160
  mov    %ebp,%ecx
  mov    %ebp,%ebx
  xor    %r15d,%r15d
L148:
  test   %r13d,%r13d
  jne    L164
  xor    %r8d,%r8d
  test   %ebx,%ebx
  jle    L12
  lea    -0x1(%rbx),%edx
  mov    %r12,%rax
  lea    0x4(%r12,%rdx,4),%rdx
  cs nopw 0x0(%rax,%rax,1)
L173:
  movl   $0x40004000,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L173
  mov    %ebx,%r8d
L12:
  cmp    %ecx,%ebp
  jle    L161
  sub    %ebx,%r14d
  mov    %ebp,%r9d
  sub    %r15d,%r14d
  sub    %ebx,%r9d
  mov    %r14d,%eax
  sub    %r15d,%r9d
  shl    $0x10,%eax
  cltd
  idiv   %r9d
  mov    %eax,%edi
  mov    %r9d,%eax
  shl    $0xe,%eax
  cltd
  idiv   %r14d
  lea    0x1(%rax),%esi
  test   %r9d,%r9d
  jle    L161
  movslq %r8d,%rdx
  lea    -0x1(%r9),%eax
  mov    %esi,%r11d
  add    %rdx,%rax
  shl    $0x10,%r11d
  lea    (%r12,%rdx,4),%rcx
  lea    0x4(%r12,%rax,4),%r10
  mov    $0x100,%eax
  nopw   0x0(%rax,%rax,1)
L81:
  mov    %r13d,%ebx
  mov    %eax,%edx
  add    $0x4,%rcx
  add    %edi,%r13d
  movzbl %bh,%ebx
  sub    %ebx,%edx
  imul   %esi,%edx
  sar    $0x8,%edx
  or     %r11d,%edx
  mov    %edx,-0x4(%rcx)
  cmp    %r10,%rcx
  jne    L81
  add    %r9d,%r8d
L161:
  test   %r15d,%r15d
  jle    L144
  movslq %r8d,%r8
  lea    -0x1(%r15),%edx
  add    %r8,%rdx
  lea    (%r12,%r8,4),%rax
  lea    0x4(%r12,%rdx,4),%rdx
  nopl   (%rax)
L196:
  movl   $0x40004000,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L196
L144:
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  je     L85
  mov    %ebp,%edx
  sar    %edx
  lea    -0x1(%rdx),%eax
  je     L85
  cltq
  movslq %ebp,%rbp
  sub    %rax,%rbp
  lea    -0x4(%r12,%rbp,4),%rdx
  nopl   (%rax)
L61:
  mov    (%rdx),%esi
  mov    (%r12,%rax,4),%ecx
  add    $0x4,%rdx
  mov    %esi,(%r12,%rax,4)
  sub    $0x1,%rax
  mov    %ecx,-0x4(%rdx)
  cmp    $0xffffffff,%eax
  jne    L61
L85:
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L164:
  test   %ebx,%ebx
  jle    L197
  movslq %ebx,%rdx
  mov    %r12,%rdi
  xor    %esi,%esi
  mov    %ecx,0xc(%rsp)
  shl    $0x2,%rdx
  call   <memset@plt>
  mov    0xc(%rsp),%ecx
  mov    %ebx,%edi
L185:
  cmp    %ecx,%ebp
  jle    L58
  mov    %r14d,%eax
  mov    %ebp,%r8d
  sub    %ebx,%eax
  sub    %ebx,%r8d
  sub    %r15d,%eax
  sub    %r15d,%r8d
  shl    $0x10,%eax
  cltd
  idiv   %r8d
  test   %r8d,%r8d
  jle    L58
  movslq %edi,%rsi
  lea    -0x1(%r8),%edx
  sub    $0x1,%r14d
  xor    %r9d,%r9d
  add    %rsi,%rdx
  lea    (%r12,%rsi,4),%rcx
  lea    0x4(%r12,%rdx,4),%r11
  xor    %edx,%edx
  nopl   0x0(%rax,%rax,1)
L128:
  mov    %edx,%r13d
  movzbl %dh,%esi
  sar    $0x10,%r13d
  add    %ebx,%r13d
  cmp    %r14d,%r13d
  cmovge %r9d,%esi
  add    $0x4,%rcx
  add    %eax,%edx
  mov    %esi,-0x4(%rcx)
  cmp    %rcx,%r11
  jne    L128
  add    %r8d,%edi
L58:
  test   %r15d,%r15d
  jle    L144
  movslq %r15d,%rdx
  movslq %edi,%rdi
  xor    %esi,%esi
  shl    $0x2,%rdx
  lea    (%r12,%rdi,4),%rdi
  call   <memset@plt>
  jmp    L144
  nopl   0x0(%rax,%rax,1)
L160:
  mov    %ebp,%r15d
  mov    %ebp,%ecx
  sub    %ebx,%r15d
  jmp    L148
  nopl   (%rax)
L197:
  xor    %edi,%edi
  jmp    L185
```

assistant: ```c
int *__imlib_CalcApoints(int s, int d, int b1, int b2, int up) {
  int *p, i, j = 0, rv = 0;
  if (d < 0) {
    rv = 1;
    d = -d;
  }
  p = malloc(d * sizeof(int));
  if (d < (b1 + b2)) {
    if (d < b1) {
      b1 = d;
      b2 = 0;
    } else
      b2 = d - b1;
  }
  if (up) {
    int val, inc;
    for (i = 0; i < b1; i++)
      p[j++] = 0;
    if (d > (b1 + b2)) {
      int ss, dd;
      ss = s - b1 - b2;
      dd = d - b1 - b2;
      val = 0;
      inc = (ss << 16) / dd;
      for (i = 0; i < dd; i++) {
        p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
        if (((val >> 16) + b1) >= (s - 1))
          p[j - 1] = 0;
        val += inc;
      }
    }
    for (i = 0; i < b2; i++)
      p[j++] = 0;
  } else {
    int val, inc;
    for (i = 0; i < b1; i++)
      p[j++] = (1 << (16 + 14)) + (1 << 14);
    if (d > (b1 + b2)) {
      int ss, dd, ap, Cp;
      ss = s - b1 - b2;
      dd = d - b1 - b2;
      val = 0;
      inc = (ss << 16) / dd;
      Cp = ((dd << 14) / ss) + 1;
      for (i = 0; i < dd; i++) {
        ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
        p[j] = ap | (Cp << 16);
        j++;
        val += inc;
      }
    }
    for (i = 0; i < b2; i++)
      p[j++] = (1 << (16 + 14)) + (1 << 14);
  }
  if (rv) {
    for (i = d / 2; --i >= 0;) {
      int tmp = p[i];
      p[i] = p[d - i - 1];
      p[d - i - 1] = tmp;
    }
  }
  return p;
}
```