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

```asm
<generate_heightmap>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  xor    %edi,%edi
  push   %r14
  mov    %esi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  movss  %xmm0,0x10(%rsp)
  mov    %edx,0x18(%rsp)
  call   <time@plt>
  mov    %eax,%edi
  call   <srand@plt>
  xor    %eax,%eax
  call   <rand@plt>
  movslq %eax,%rbp
  cltd
  imul   $0x68db8bad,%rbp,%rbp
  sar    $0x2b,%rbp
  sub    %edx,%ebp
  imul   $0x1388,%ebp,%edx
  sub    %edx,%eax
  mov    %eax,%ebp
  xor    %eax,%eax
  call   <rand@plt>
  movslq %eax,%r12
  cltd
  imul   $0x68db8bad,%r12,%r12
  sar    $0x2b,%r12
  sub    %edx,%r12d
  imul   $0x1388,%r12d,%edx
  sub    %edx,%eax
  mov    %eax,%r12d
  xor    %eax,%eax
  call   <rand@plt>
  movslq %eax,%r13
  cltd
  imul   $0x68db8bad,%r13,%r13
  sar    $0x2b,%r13
  sub    %edx,%r13d
  imul   $0x1388,%r13d,%edx
  sub    %edx,%eax
  mov    %eax,%r13d
  xor    %eax,%eax
  call   <rand@plt>
  mov    %r13d,%ecx
  mov    %ebp,%esi
  lea    D0(%rip),%rdi
  movslq %eax,%rbx
  imul   $0x68db8bad,%rbx,%rbx
  sar    $0x2b,%rbx
  cltd
  sub    %edx,%ebx
  imul   $0x1388,%ebx,%edx
  sub    %edx,%eax
  mov    (%r15),%rdx
  mov    %eax,%ebx
  movslq %r14d,%rax
  shl    $0x2,%rax
  mov    %ebp,(%rdx)
  mov    %ebx,%r8d
  mov    %r12d,-0x4(%rdx,%rax,1)
  movslq 0x18(%rsp),%rdx
  mov    -0x8(%r15,%rdx,8),%rdx
  mov    %r13d,(%rdx)
  mov    %ebx,-0x4(%rdx,%rax,1)
  mov    %r12d,%edx
  call   <printf@plt>
  mov    0x18(%rsp),%edi
  lea    -0x1(%r14),%ecx
  mov    %ebx,%r8d
  mov    %r14d,0x2c(%rsp)
  mov    %ebp,%esi
  lea    -0x1(%rdi),%eax
  mov    $0x4,%edi
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %eax,%edx
  mov    %ecx,%eax
  sar    %edx
  shr    $0x1f,%eax
  add    %ecx,%eax
  movslq %edx,%rdx
  mov    %r13d,%ecx
  mov    (%r15,%rdx,8),%rdx
  sar    %eax
  cltq
  lea    (%rdx,%rax,4),%r14
  mov    %r12d,%edx
  call   <average@plt>
  mov    0x2c(%rsp),%edi
  mov    %eax,(%r14)
  mov    %edi,%r14d
  shr    $0x1f,%r14d
  mov    %r14d,%eax
  add    %edi,%eax
  sar    %eax
  mov    %eax,0x28(%rsp)
  cmp    $0x1,%edi
  jle    L54
  mov    0x18(%rsp),%edi
  mov    %eax,%r12d
  mov    %r12d,%ebp
  mov    %edi,%eax
  shr    $0x1f,%eax
  add    %edi,%eax
  sar    %eax
  mov    %eax,0x24(%rsp)
  nopl   0x0(%rax)
L81:
  mov    0x24(%rsp),%eax
  cltd
  idiv   %ebp
  mov    %eax,0x20(%rsp)
  test   %eax,%eax
  jle    L50
  mov    0x28(%rsp),%eax
  cltd
  idiv   %ebp
  mov    %eax,0xc(%rsp)
  test   %eax,%eax
  jle    L94
  lea    0x0(%rbp,%rbp,1),%eax
  movl   $0x0,0x1c(%rsp)
  mov    0x2c(%rsp),%r14d
  mov    %ebp,%r13d
  mov    %eax,0x14(%rsp)
  nopw   0x0(%rax,%rax,1)
L102:
  xor    %eax,%eax
  mov    %ebp,%ebx
  mov    %eax,%r12d
  nop
L59:
  movss  0x10(%rsp),%xmm0
  mov    0x18(%rsp),%edx
  mov    %ebp,%ecx
  mov    %ebx,%r9d
  mov    %r13d,%r8d
  mov    %r14d,%esi
  mov    %r15,%rdi
  add    $0x1,%r12d
  call   <diamond@plt>
  add    0x14(%rsp),%ebp
  cmp    0xc(%rsp),%r12d
  jne    L59
  addl   $0x1,0x1c(%rsp)
  mov    %ebx,%ebp
  mov    0x1c(%rsp),%eax
  add    0x14(%rsp),%r13d
  cmp    0x20(%rsp),%eax
  jne    L102
L94:
  xor    %r12d,%r12d
  lea    0x0(%rbp,%rbp,1),%ebx
  mov    %ebp,%r13d
  mov    %r12d,0x14(%rsp)
  nopl   0x0(%rax)
L63:
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jle    L73
  cmp    $0x1,%ebp
  je     L73
  mov    %ebp,%r14d
  xor    %r12d,%r12d
  nopl   0x0(%rax,%rax,1)
L12:
  movss  0x10(%rsp),%xmm0
  mov    %r14d,%esi
  mov    %ebp,%ecx
  mov    %r13d,%edx
  mov    %r15,%rdi
  add    $0x1,%r12d
  add    %ebx,%r14d
  call   <square@plt>
  cmp    0xc(%rsp),%r12d
  jne    L12
L73:
  addl   $0x1,0x14(%rsp)
  add    %ebx,%r13d
  mov    0x14(%rsp),%eax
  cmp    0x20(%rsp),%eax
  jne    L63
L50:
  cmp    $0x1,%ebp
  je     L54
  mov    %ebp,%eax
  shr    $0x1f,%eax
  add    %ebp,%eax
  sar    %eax
  sub    %eax,%ebp
  test   %ebp,%ebp
  jg     L81
L54:
  add    $0x38,%rsp
  mov    %r15,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: read_data
arguments: tag: D0
type: string

tool: D0: Seeds:
%d	%d
%d	%d


assistant: ```c
int **generate_heightmap(int **map, int width, int height, float roughness) {
  srand(time(NULL));
  int seed1, seed2, seed3, seed4;
  seed1 = rand() % 5000;
  seed2 = rand() % 5000;
  seed3 = rand() % 5000;
  seed4 = rand() % 5000;
  map[0][0] = seed1;
  map[0][width - 1] = seed2;
  map[height - 1][0] = seed3;
  map[height - 1][width - 1] = seed4;
  printf("Seeds:\n%d\t%d\n%d\t%d\n", seed1, seed2, seed3, seed4);
  map[(height - 1) / 2][(width - 1) / 2] = average(4, seed1, seed2, seed3, seed4);
  int length = width / 2;
  while (length > 0) {
    for (int y = 0; y < height / 2 / length; y++) {
      for (int x = 0; x < width / 2 / length; x++) {
        diamond(map, width, height, length + (x * 2 * length), length + (y * 2 * length), length, roughness);
      }
    }
    for (int y = 0; y < height / 2 / length; y++) {
      for (int x = 0; x < width / 2 / length; x++) {
        if (length > 1) {
          square(map, length + (x * 2 * length), length + (y * 2 * length), length, roughness);
        }
      }
    }
    if (length == 1)
      length = 0;
    length -= length / 2;
  }
  return map;
}
```