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

```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     L3
  jg     L131
  test   %ecx,%ecx
  je     L93
  cmp    $0x1,%ecx
  jne    L67
  test   %edx,%edx
  jle    L67
  mov    (%rsp),%r15
  lea    -0x1(%rdx),%eax
  lea    0x8(%r15,%rax,8),%rcx
  lea    -0x1(%rsi),%eax
  lea    0x4(,%rax,4),%rsi
L54:
  test   %r12d,%r12d
  jle    L0
  mov    (%r15),%rax
  lea    (%rsi,%rax,1),%rdx
  nopl   0x0(%rax,%rax,1)
L116:
  movl   $0x1,(%rax)
  add    $0x4,%rax
  cmp    %rax,%rdx
  jne    L116
L0:
  add    $0x8,%r15
  cmp    %rcx,%r15
  jne    L54
L67:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L131:
  cmp    $0x3,%ecx
  jne    L67
  test   %edx,%edx
  jle    L187
  mov    (%rsp),%rdi
  lea    -0x1(%rdx),%eax
  lea    0x8(%rdi,%rax,8),%rbp
  lea    -0x1(%rsi),%eax
  mov    %rdi,%rbx
  lea    0x4(,%rax,4),%r13
L125:
  test   %r12d,%r12d
  jle    L9
  mov    (%rbx),%rdi
  mov    %r13,%rdx
  xor    %esi,%esi
  call   <memset@plt>
L9:
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L125
L187:
  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    L167
L19:
  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     L19
L167:
  movl   $0xa,0xc(%rsp)
L145:
  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
L184:
  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     L76
  cmp    %r15d,%r12d
  jle    L76
  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     L76
  cmp    %eax,%r14d
  jle    L76
  mov    (%rsp),%rdi
  cltq
  movslq %r15d,%rdx
  mov    (%rdi,%rax,8),%rax
  addl   $0x1,(%rax,%rdx,4)
L76:
  sub    $0x1,%ebx
  jne    L184
  subl   $0x1,0xc(%rsp)
  jne    L145
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L93:
  test   %edx,%edx
  jle    L67
  mov    (%rsp),%r15
  lea    -0x1(%rdx),%eax
  lea    0x8(%r15,%rax,8),%rbx
  lea    -0x1(%rsi),%eax
  lea    0x4(,%rax,4),%rbp
L158:
  test   %r12d,%r12d
  jle    L244
  mov    (%r15),%rdi
  mov    %rbp,%rdx
  xor    %esi,%esi
  call   <memset@plt>
L244:
  add    $0x8,%r15
  cmp    %r15,%rbx
  jne    L158
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L3:
  test   %edx,%edx
  jle    L67
  lea    0x1(%rdx),%r10d
  mov    $0x1,%r9d
  lea    0x1(%rsi),%r8d
L241:
  mov    %r9d,%esi
  test   %r12d,%r12d
  jle    L261
  mov    (%rsp),%rax
  mov    $0x1,%ecx
  mov    -0x8(%rax,%r9,8),%rdi
  nop
L39:
  mov    %ecx,%eax
  cltd
  idiv   %esi
  mov    %edx,-0x4(%rdi,%rcx,4)
  add    $0x1,%rcx
  cmp    %r8,%rcx
  jne    L39
L261:
  add    $0x1,%r9
  cmp    %r10,%r9
  jne    L241
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

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