user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<diamond>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r13
  mov    %esi,0x14(%rsp)
  mov    %edx,%r15d
  mov    %ecx,%ebp
  mov    %r8d,%r12d
  mov    %r9d,%ebx
  movss  %xmm0,0xc(%rsp)
  cmp    %r9d,%r8d
  je     L5
L171:
  lea    (%r12,%rbx,1),%r14d
  sub    $0x1,%r15d
  cmp    %r15d,%r14d
  je     L44
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  mov    %edx,0x10(%rsp)
  mov    $0x0,%eax
  call   <should_add@plt>
  test   %eax,%eax
  je     L185
  movslq %ebp,%rsi
  mov    %rsi,%r10
  movslq %r14d,%rax
  lea    0x0(%r13,%rax,8),%r15
  mov    (%r15),%rdx
  lea    (%r14,%rbx,1),%eax
  cltq
  mov    0x0(%r13,%rax,8),%rdi
  lea    (%rbx,%rbp,1),%eax
  cltq
  mov    (%rdx,%rax,4),%ecx
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    (%rdx,%rax,4),%edx
  movslq %r12d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    (%rax,%rsi,4),%esi
  mov    %r10,0x18(%rsp)
  mov    (%rdi,%r10,4),%r8d
  mov    $0x4,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r15),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x10(%rsp),%xmm0
  mulss  0xc(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %edx,%xmm1
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    0x18(%rsp),%r10
  mov    %edx,(%rax,%r10,4)
L73:
  lea    (%rbx,%rbx,1),%eax
  mov    %eax,0x10(%rsp)
  cmp    %ebp,%ebx
  je     L109
L75:
  lea    (%rbx,%rbp,1),%r15d
  mov    0x14(%rsp),%eax
  sub    $0x1,%eax
  cmp    %eax,%r15d
  je     L181
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  mov    %edx,0x14(%rsp)
  mov    $0x0,%eax
  call   <should_add@plt>
  test   %eax,%eax
  je     L165
  movslq %r12d,%r12
  lea    0x0(%r13,%r12,8),%r12
  mov    (%r12),%rdx
  movslq %r15d,%rdi
  add    %ebx,%r15d
  movslq %r15d,%r15
  movslq %r14d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    %rdi,0x18(%rsp)
  mov    (%rax,%rdi,4),%ecx
  sub    0x10(%rsp),%r14d
  movslq %r14d,%r14
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    0x0(%r13,%r14,8),%rsi
  mov    (%rsi,%rax,4),%eax
  movslq %ebp,%rbp
  mov    (%rdx,%rbp,4),%esi
  mov    (%rdx,%r15,4),%r8d
  mov    %eax,%edx
  mov    $0x4,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r12),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x14(%rsp),%xmm0
  mulss  0xc(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %edx,%xmm1
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    0x18(%rsp),%rdi
  mov    %edx,(%rax,%rdi,4)
L34:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L5:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  mov    %edx,0x10(%rsp)
  mov    $0x0,%eax
  call   <should_add@plt>
  test   %eax,%eax
  je     L62
  mov    0x0(%r13),%rdx
  movslq %ebp,%rsi
  lea    (%rbx,%rbp,1),%eax
  cltq
  mov    (%rdx,%rax,4),%ecx
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    (%rdx,%rax,4),%edx
  movslq %r12d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    %rsi,%r14
  mov    (%rax,%rsi,4),%esi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    0x0(%r13),%rcx
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x10(%rsp),%xmm0
  mulss  0xc(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    %edx,(%rcx,%r14,4)
  jmp    L171
L62:
  mov    0x0(%r13),%rdx
  movslq %ebp,%rsi
  lea    (%rbx,%rbp,1),%eax
  cltq
  mov    (%rdx,%rax,4),%ecx
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    (%rdx,%rax,4),%edx
  movslq %r12d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    %rsi,%r14
  mov    (%rax,%rsi,4),%esi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    0x0(%r13),%rcx
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x10(%rsp),%xmm1
  mulss  0xc(%rsp),%xmm1
  subss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    %edx,(%rcx,%r14,4)
  jmp    L171
L44:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  mov    %edx,0x10(%rsp)
  mov    $0x0,%eax
  call   <should_add@plt>
  test   %eax,%eax
  je     L173
  movslq %r14d,%rax
  lea    0x0(%r13,%rax,8),%r15
  mov    (%r15),%rdx
  movslq %ebp,%rdi
  lea    (%rbx,%rbp,1),%eax
  cltq
  mov    (%rdx,%rax,4),%ecx
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    (%rdx,%rax,4),%edx
  movslq %r12d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    %rdi,0x18(%rsp)
  mov    (%rax,%rdi,4),%esi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r15),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x10(%rsp),%xmm0
  mulss  0xc(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %edx,%xmm1
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    0x18(%rsp),%rdi
  mov    %edx,(%rax,%rdi,4)
  jmp    L73
L173:
  movslq %r14d,%rax
  lea    0x0(%r13,%rax,8),%r15
  mov    (%r15),%rdx
  movslq %ebp,%rdi
  lea    (%rbx,%rbp,1),%eax
  cltq
  mov    (%rdx,%rax,4),%ecx
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    (%rdx,%rax,4),%edx
  movslq %r12d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    %rdi,0x18(%rsp)
  mov    (%rax,%rdi,4),%esi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r15),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ss %edx,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x10(%rsp),%xmm1
  mulss  0xc(%rsp),%xmm1
  subss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    0x18(%rsp),%rdi
  mov    %edx,(%rax,%rdi,4)
  jmp    L73
L185:
  movslq %ebp,%rsi
  mov    %rsi,%r11
  movslq %r14d,%rax
  lea    0x0(%r13,%rax,8),%r15
  mov    (%r15),%rdx
  lea    (%r14,%rbx,1),%eax
  cltq
  mov    0x0(%r13,%rax,8),%rdi
  lea    (%rbx,%rbp,1),%eax
  cltq
  mov    (%rdx,%rax,4),%ecx
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    (%rdx,%rax,4),%edx
  movslq %r12d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    (%rax,%rsi,4),%esi
  mov    %r11,0x18(%rsp)
  mov    (%rdi,%r11,4),%r8d
  mov    $0x4,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r15),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ss %edx,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x10(%rsp),%xmm1
  mulss  0xc(%rsp),%xmm1
  subss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    0x18(%rsp),%r11
  mov    %edx,(%rax,%r11,4)
  jmp    L73
L109:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  mov    %edx,0x18(%rsp)
  mov    $0x0,%eax
  call   <should_add@plt>
  test   %eax,%eax
  je     L0
  movslq %r12d,%rax
  lea    0x0(%r13,%rax,8),%r15
  movslq %r14d,%rax
  mov    0x0(%r13,%rax,8),%rcx
  mov    %r14d,%eax
  sub    0x10(%rsp),%eax
  cltq
  mov    0x0(%r13,%rax,8),%rdx
  movslq %ebp,%rax
  mov    (%r15),%rsi
  mov    (%rsi,%rax,4),%esi
  mov    (%rcx),%ecx
  mov    (%rdx),%edx
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r15),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x18(%rsp),%xmm0
  mulss  0xc(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %edx,%xmm1
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    %edx,(%rax)
  jmp    L75
L0:
  movslq %r12d,%rax
  lea    0x0(%r13,%rax,8),%r15
  movslq %r14d,%rax
  mov    0x0(%r13,%rax,8),%rcx
  mov    %r14d,%eax
  sub    0x10(%rsp),%eax
  cltq
  mov    0x0(%r13,%rax,8),%rdx
  movslq %ebp,%rax
  mov    (%r15),%rsi
  mov    (%rsi,%rax,4),%esi
  mov    (%rcx),%ecx
  mov    (%rdx),%edx
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r15),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ss %edx,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x18(%rsp),%xmm1
  mulss  0xc(%rsp),%xmm1
  subss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    %edx,(%rax)
  jmp    L75
L181:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  mov    %edx,0x14(%rsp)
  mov    $0x0,%eax
  call   <should_add@plt>
  test   %eax,%eax
  je     L47
  movslq %r15d,%r15
  movslq %r12d,%rax
  lea    0x0(%r13,%rax,8),%rdi
  movslq %r14d,%r14
  mov    0x0(%r13,%r14,8),%rax
  mov    (%rax,%r15,4),%ecx
  sub    %ebx,%r12d
  movslq %r12d,%r12
  mov    0x0(%r13,%r12,8),%rax
  mov    (%rax,%r15,4),%edx
  movslq %ebp,%rbp
  mov    %rdi,%rbx
  mov    (%rdi),%rax
  mov    (%rax,%rbp,4),%esi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%rbx),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x14(%rsp),%xmm0
  mulss  0xc(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %edx,%xmm1
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    %edx,(%rax,%r15,4)
  jmp    L34
L47:
  movslq %r15d,%r15
  movslq %r12d,%r12
  lea    0x0(%r13,%r12,8),%rbx
  movslq %r14d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    (%rax,%r15,4),%ecx
  sub    0x10(%rsp),%r14d
  movslq %r14d,%r14
  mov    0x0(%r13,%r14,8),%rax
  mov    (%rax,%r15,4),%edx
  movslq %ebp,%rbp
  mov    (%rbx),%rax
  mov    (%rax,%rbp,4),%esi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%rbx),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ss %edx,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x14(%rsp),%xmm1
  mulss  0xc(%rsp),%xmm1
  subss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    %edx,(%rax,%r15,4)
  jmp    L34
L165:
  movslq %r12d,%r12
  lea    0x0(%r13,%r12,8),%r12
  mov    (%r12),%rdx
  movslq %r15d,%rdi
  add    %ebx,%r15d
  movslq %r15d,%r15
  movslq %r14d,%rax
  mov    0x0(%r13,%rax,8),%rax
  mov    %rdi,0x18(%rsp)
  mov    (%rax,%rdi,4),%ecx
  sub    0x10(%rsp),%r14d
  movslq %r14d,%r14
  mov    %ebp,%eax
  sub    %ebx,%eax
  cltq
  mov    0x0(%r13,%r14,8),%rsi
  mov    (%rsi,%rax,4),%eax
  movslq %ebp,%rbp
  mov    (%rdx,%rbp,4),%esi
  mov    (%rdx,%r15,4),%r8d
  mov    %eax,%edx
  mov    $0x4,%edi
  mov    $0x0,%eax
  call   <average@plt>
  mov    %eax,%edx
  mov    (%r12),%rax
  pxor   %xmm0,%xmm0
  cvtsi2ss %edx,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x14(%rsp),%xmm1
  mulss  0xc(%rsp),%xmm1
  subss  %xmm1,%xmm0
  cvttss2si %xmm0,%edx
  mov    0x18(%rsp),%rdi
  mov    %edx,(%rax,%rdi,4)
  jmp    L34
```

assistant: ```c
void diamond(int **map, int width, int height, int x, int y, int length, float roughness) {
  int salt;
  if (y - length == 0) {
    salt = rand() % length;
    if (should_add()) {
      map[y - length][x] = average(3, map[y][x], map[y - length][x - length], map[y - length][x + length]) + (salt * roughness);
    } else {
      map[y - length][x] = average(3, map[y][x], map[y - length][x - length], map[y - length][x + length]) - (salt * roughness);
    }
  }
  if (y + length == height - 1) {
    salt = rand() % length;
    if (should_add()) {
      map[y + length][x] = average(3, map[y][x], map[y + length][x - length], map[y + length][x + length]) + (salt * roughness);
    } else {
      map[y + length][x] = average(3, map[y][x], map[y + length][x - length], map[y + length][x + length]) - (salt * roughness);
    }
  } else {
    salt = rand() % length;
    if (should_add()) {
      map[y + length][x] = average(4, map[y][x], map[y + length][x - length], map[y + length][x + length], map[y + 2 * length][x]) + (salt * roughness);
    } else {
      map[y + length][x] = average(4, map[y][x], map[y + length][x - length], map[y + length][x + length], map[y + 2 * length][x]) - (salt * roughness);
    }
  }
  if (x - length == 0) {
    salt = rand() % length;
    if (should_add()) {
      map[y][x - length] = average(3, map[y][x], map[y - length][x - length], map[y + length][x - length]) + (salt * roughness);
    } else {
      map[y][x - length] = average(3, map[y][x], map[y - length][x - length], map[y + length][x - length]) - (salt * roughness);
    }
  }
  if (x + length == width - 1) {
    salt = rand() % length;
    if (should_add()) {
      map[y][x + length] = average(3, map[y][x], map[y - length][x + length], map[y + length][x + length]) + (salt * roughness);
    } else {
      map[y][x + length] = average(3, map[y][x], map[y - length][x + length], map[y + length][x + length]) - (salt * roughness);
    }
  } else {
    salt = rand() % length;
    if (should_add()) {
      map[y][x + length] = average(4, map[y][x], map[y - length][x - length], map[y + length][x + length], map[y][x + 2 * length]) + (salt * roughness);
    } else {
      map[y][x + length] = average(4, map[y][x], map[y - length][x - length], map[y + length][x + length], map[y][x + 2 * length]) - (salt * roughness);
    }
  }
}
```