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

```asm
<CreateTestImage>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,(%rsp)
  cmp    $0x2,%ecx
  je     L198
  jg     L58
  test   %ecx,%ecx
  je     L118
  cmp    $0x1,%ecx
  jne    L170
  test   %edx,%edx
  jle    L170
  test   %esi,%esi
  jle    L170
  lea    -0x1(%rdx),%eax
  mov    %rdi,%r15
  lea    -0x1(%rsi),%r9d
  mov    %esi,%r8d
  lea    0x8(%rdi,%rax,8),%r10
  mov    %esi,%eax
  movdqa D8(%rip),%xmm0
  and    $0xfffffffc,%r8d
  shr    $0x2,%eax
  lea    -0x1(%rax),%edi
  add    $0x1,%rdi
  shl    $0x4,%rdi
L168:
  mov    (%r15),%rcx
  mov    %rcx,%rax
  lea    (%rdi,%rcx,1),%rdx
  cmp    $0x2,%r9d
  jbe    L289
  xchg   %ax,%ax
L184:
  movups %xmm0,(%rax)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L184
  mov    %r8d,%eax
  cmp    %r8d,%r12d
  je     L194
L246:
  movslq %eax,%rdx
  movl   $0x1,(%rcx,%rdx,4)
  lea    0x0(,%rdx,4),%rsi
  lea    0x1(%rax),%edx
  cmp    %edx,%r12d
  jle    L194
  add    $0x2,%eax
  movl   $0x1,0x4(%rcx,%rsi,1)
  cmp    %r12d,%eax
  jge    L194
  movl   $0x1,0x8(%rcx,%rsi,1)
L194:
  add    $0x8,%r15
  cmp    %r10,%r15
  jne    L168
L170:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L58:
  cmp    $0x3,%ecx
  jne    L170
  test   %edx,%edx
  jle    L126
  test   %esi,%esi
  jle    L126
  lea    -0x1(%rdx),%eax
  movslq %esi,%rbp
  mov    %rdi,%rbx
  lea    0x8(%rdi,%rax,8),%r13
  shl    $0x2,%rbp
L64:
  mov    (%rbx),%rdi
  mov    %rbp,%rdx
  xor    %esi,%esi
  add    $0x8,%rbx
  call   <memset@plt>
  cmp    %r13,%rbx
  jne    L64
L126:
  mov    %r14d,%eax
  xor    %r13d,%r13d
  imul   %r12d,%eax
  movslq %eax,%rbp
  cltd
  imul   $0x66666667,%rbp,%rbp
  sar    $0x22,%rbp
  sub    %edx,%ebp
  cmp    $0x9,%eax
  jle    L131
L224:
  xor    %eax,%eax
  add    $0x1,%r13d
  call   <rand@plt>
  cltd
  idiv   %r12d
  xor    %eax,%eax
  mov    %edx,%ebx
  call   <rand@plt>
  mov    (%rsp),%rdi
  cltd
  idiv   %r14d
  movslq %edx,%rax
  movslq %ebx,%rdx
  mov    (%rdi,%rax,8),%rax
  addl   $0x1,(%rax,%rdx,4)
  cmp    %ebp,%r13d
  jl     L224
L131:
  movl   $0xa,0xc(%rsp)
L265:
  xor    %eax,%eax
  mov    $0xfa,%ebx
  call   <rand@plt>
  cltd
  idiv   %r12d
  xor    %eax,%eax
  mov    %edx,%ebp
  call   <rand@plt>
  cltd
  idiv   %r14d
  mov    %edx,%r13d
  xchg   %ax,%ax
L42:
  xor    %eax,%eax
  call   <rand@plt>
  movslq %eax,%rdx
  mov    %eax,%ecx
  imul   $0xffffffff88888889,%rdx,%rdx
  sar    $0x1f,%ecx
  shr    $0x20,%rdx
  add    %eax,%edx
  sar    $0x4,%edx
  sub    %ecx,%edx
  imul   $0x1e,%edx,%edx
  sub    %edx,%eax
  lea    -0xf(%rbp,%rax,1),%r15d
  xor    %eax,%eax
  call   <rand@plt>
  mov    %eax,%ecx
  test   %r15d,%r15d
  js     L159
  cmp    %r15d,%r12d
  jle    L159
  cltq
  mov    %ecx,%esi
  imul   $0xffffffff88888889,%rax,%rax
  sar    $0x1f,%esi
  shr    $0x20,%rax
  add    %ecx,%eax
  sar    $0x4,%eax
  sub    %esi,%eax
  imul   $0x1e,%eax,%eax
  sub    %eax,%ecx
  lea    -0xf(%r13,%rcx,1),%eax
  test   %eax,%eax
  js     L159
  cmp    %eax,%r14d
  jle    L159
  mov    (%rsp),%rdi
  cltq
  movslq %r15d,%rdx
  mov    (%rdi,%rax,8),%rax
  addl   $0x1,(%rax,%rdx,4)
L159:
  sub    $0x1,%ebx
  jne    L42
  subl   $0x1,0xc(%rsp)
  jne    L265
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L118:
  test   %edx,%edx
  jle    L170
  test   %esi,%esi
  jle    L170
  lea    -0x1(%rdx),%eax
  movslq %esi,%rbx
  mov    %rdi,%r15
  lea    0x8(%rdi,%rax,8),%rbp
  shl    $0x2,%rbx
L17:
  mov    (%r15),%rdi
  mov    %rbx,%rdx
  xor    %esi,%esi
  add    $0x8,%r15
  call   <memset@plt>
  cmp    %r15,%rbp
  jne    L17
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L198:
  test   %edx,%edx
  jle    L170
  test   %esi,%esi
  jle    L170
  lea    0x1(%rdx),%r10d
  mov    $0x1,%r9d
  lea    0x1(%rsi),%r8d
L142:
  mov    (%rsp),%rax
  mov    %r9d,%esi
  mov    $0x1,%ecx
  mov    -0x8(%rax,%r9,8),%rdi
L316:
  mov    %ecx,%eax
  cltd
  idiv   %esi
  mov    %edx,-0x4(%rdi,%rcx,4)
  add    $0x1,%rcx
  cmp    %r8,%rcx
  jne    L316
  add    $0x1,%r9
  cmp    %r10,%r9
  jne    L142
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L289:
  xor    %eax,%eax
  jmp    L246
```

tool_calls: name: retrieve_data
arguments: data_label: D8
type_infered: byte[16]

tool: {"D8": [0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00]}

assistant: ```c
void CreateTestImage(int **img, int w, int h, int mode) {
  int x, y;
  switch (mode) {
  case 0:
    for (y = 0; y < h; y++) {
      for (x = 0; x < w; x++) {
        img[y][x] = 0;
      }
    }
    break;
  case 1:
    for (y = 0; y < h; y++) {
      for (x = 0; x < w; x++) {
        img[y][x] = 1;
      }
    }
    break;
  case 2:
    for (y = 0; y < h; y++) {
      for (x = 0; x < w; x++) {
        img[y][x] = (x + 1) % (y + 1);
      }
    }
    break;
  case 3:
    for (y = 0; y < h; y++) {
      for (x = 0; x < w; x++) {
        img[y][x] = 0;
      }
    }
    for (int i = 0; i < w * h / 10; i++) {
      x = rand() % w;
      y = rand() % h;
      img[y][x] += 1;
    }
    for (int i = 0; i < 10; i++) {
      x = rand() % w;
      y = rand() % h;
      for (int j = 0; j < 250; j++) {
        int xs = x + rand() % 30 - 15;
        int ys = y + rand() % 30 - 15;
        if (xs < 0 || xs >= w || ys < 0 || ys >= h)
          continue;
        img[ys][xs] += 1;
      }
    }
  }
}
```