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

```asm
<__imlib_CalcApoints>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %esi,-0x48(%rbp)
  mov    %edx,-0x4c(%rbp)
  mov    %ecx,-0x50(%rbp)
  mov    %r8d,-0x54(%rbp)
  movl   $0x0,-0x3c(%rbp)
  movl   $0x0,-0x38(%rbp)
  cmpl   $0x0,-0x48(%rbp)
  jns    L169
  movl   $0x1,-0x38(%rbp)
  negl   -0x48(%rbp)
L169:
  mov    -0x48(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x4c(%rbp),%edx
  mov    -0x50(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x48(%rbp)
  jge    L59
  mov    -0x48(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  jge    L42
  mov    -0x48(%rbp),%eax
  mov    %eax,-0x4c(%rbp)
  movl   $0x0,-0x50(%rbp)
  jmp    L59
L42:
  mov    -0x48(%rbp),%eax
  sub    -0x4c(%rbp),%eax
  mov    %eax,-0x50(%rbp)
L59:
  cmpl   $0x0,-0x54(%rbp)
  je     L157
  movl   $0x0,-0x40(%rbp)
  jmp    L227
L23:
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x3c(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x40(%rbp)
L227:
  mov    -0x40(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  jl     L23
  mov    -0x4c(%rbp),%edx
  mov    -0x50(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x48(%rbp)
  jle    L149
  mov    -0x44(%rbp),%eax
  sub    -0x4c(%rbp),%eax
  sub    -0x50(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x48(%rbp),%eax
  sub    -0x4c(%rbp),%eax
  sub    -0x50(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x0,-0x34(%rbp)
  mov    -0x18(%rbp),%eax
  shl    $0x10,%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %eax,-0x10(%rbp)
  movl   $0x0,-0x40(%rbp)
  jmp    L111
L74:
  mov    -0x34(%rbp),%eax
  sar    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x3c(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  movzbl %cl,%eax
  mov    %eax,(%rdx)
  mov    -0x34(%rbp),%eax
  sar    $0x10,%eax
  mov    %eax,%edx
  mov    -0x4c(%rbp),%eax
  add    %eax,%edx
  mov    -0x44(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,%edx
  jl     L229
  mov    -0x3c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
L229:
  mov    -0x10(%rbp),%eax
  add    %eax,-0x34(%rbp)
  addl   $0x1,-0x40(%rbp)
L111:
  mov    -0x40(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L74
L149:
  movl   $0x0,-0x40(%rbp)
  jmp    L82
L99:
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x3c(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x40(%rbp)
L82:
  mov    -0x40(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jl     L99
  jmp    L58
L157:
  movl   $0x0,-0x40(%rbp)
  jmp    L112
L93:
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x3c(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x40004000,(%rax)
  addl   $0x1,-0x40(%rbp)
L112:
  mov    -0x40(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  jl     L93
  mov    -0x4c(%rbp),%edx
  mov    -0x50(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x48(%rbp)
  jle    L55
  mov    -0x44(%rbp),%eax
  sub    -0x4c(%rbp),%eax
  sub    -0x50(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x48(%rbp),%eax
  sub    -0x4c(%rbp),%eax
  sub    -0x50(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  movl   $0x0,-0x30(%rbp)
  mov    -0x2c(%rbp),%eax
  shl    $0x10,%eax
  cltd
  idivl  -0x28(%rbp)
  mov    %eax,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  shl    $0xe,%eax
  cltd
  idivl  -0x2c(%rbp)
  add    $0x1,%eax
  mov    %eax,-0x20(%rbp)
  movl   $0x0,-0x40(%rbp)
  jmp    L126
L178:
  mov    -0x30(%rbp),%eax
  sar    $0x8,%eax
  movzbl %al,%edx
  mov    $0x100,%eax
  sub    %edx,%eax
  imul   -0x20(%rbp),%eax
  sar    $0x8,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  shl    $0x10,%eax
  mov    -0x3c(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  or     -0x1c(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x3c(%rbp)
  mov    -0x24(%rbp),%eax
  add    %eax,-0x30(%rbp)
  addl   $0x1,-0x40(%rbp)
L126:
  mov    -0x40(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L178
L55:
  movl   $0x0,-0x40(%rbp)
  jmp    L11
L148:
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x3c(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x40004000,(%rax)
  addl   $0x1,-0x40(%rbp)
L11:
  mov    -0x40(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jl     L148
L58:
  cmpl   $0x0,-0x38(%rbp)
  je     L236
  mov    -0x48(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x40(%rbp)
  jmp    L134
L124:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x48(%rbp),%eax
  sub    -0x40(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x40(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x48(%rbp),%eax
  sub    -0x40(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
L134:
  subl   $0x1,-0x40(%rbp)
  cmpl   $0x0,-0x40(%rbp)
  jns    L124
L236:
  mov    -0x8(%rbp),%rax
  leave
  ret
```

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;
}
```