user: Please show me the C implementation that matches the assembly code listed below:

```asm
<assign_id>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %edx,0x18(%rsp)
  test   %edx,%edx
  jle    L212
  mov    %esi,%ebx
  mov    %rcx,%r15
  lea    -0x1(%rdx),%r13d
  mov    %edx,%eax
  test   %esi,%esi
  jle    L286
  sub    $0x1,%eax
  movslq %esi,%rbp
  mov    %rcx,%r14
  mov    %rax,%r13
  lea    0x8(%rcx,%rax,8),%r12
  shl    $0x2,%rbp
  nopw   0x0(%rax,%rax,1)
L259:
  mov    (%r14),%rdi
  mov    %rbp,%rdx
  xor    %esi,%esi
  add    $0x8,%r14
  call   <memset@plt>
  cmp    %r12,%r14
  jne    L259
L286:
  mov    %r13d,%eax
  xor    %r9d,%r9d
  xor    %r10d,%r10d
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  lea    -0x1(%rbx),%eax
  mov    %r9d,%r15d
  mov    0x18(%rsp),%r11d
  mov    %eax,(%rsp)
  mov    0x10(%rsp),%r9
  mov    %ebx,%ecx
  xor    %r13d,%r13d
  mov    %r10d,%ebx
  nopw   0x0(%rax,%rax,1)
L329:
  test   %ecx,%ecx
  jle    L101
  movslq %r15d,%r12
  mov    (%rsp),%r14d
  xor    %ebp,%ebp
  add    %r9,%r12
  nopl   0x0(%rax)
L156:
  cmpb   $0x0,(%r12,%rbp,1)
  jne    L167
  mov    (%rdi,%r13,8),%r8
  lea    0x0(,%rbp,4),%rax
  lea    (%r8,%rax,1),%rdx
  mov    (%rdx),%esi
  test   %esi,%esi
  jne    L167
  test   %r13,%r13
  je     L163
  mov    -0x8(%rdi,%r13,8),%rsi
  mov    (%rsi,%rax,1),%esi
  test   %rbp,%rbp
  je     L416
  mov    -0x4(%r8,%rax,1),%r10d
  mov    %esi,%eax
  or     %r10d,%eax
  je     L28
  test   %esi,%esi
  setne  %al
  mov    %eax,%r8d
  cmp    %r10d,%esi
  jne    L111
  test   %al,%al
  je     L111
L108:
  mov    %esi,(%rdx)
  nopw   0x0(%rax,%rax,1)
L167:
  lea    0x1(%rbp),%rax
  cmp    %r14,%rbp
  je     L101
L85:
  mov    %rax,%rbp
  jmp    L156
L416:
  test   %esi,%esi
  jne    L108
  nopw   0x0(%rax,%rax,1)
L28:
  add    $0x1,%ebx
  lea    0x1(%rbp),%rax
  mov    %ebx,(%rdx)
  cmp    %r14,%rbp
  jne    L85
  cs nopw 0x0(%rax,%rax,1)
L101:
  add    $0x1,%r13
  add    %ecx,%r15d
  cmp    %r11,%r13
  jne    L329
  mov    %ebx,%r10d
  mov    %ecx,%ebx
  test   %r10d,%r10d
  je     L212
  mov    0x8(%rsp),%rax
  mov    %ecx,%r12d
  lea    -0x1(%rcx),%r14d
  xor    %r11d,%r11d
  and    $0xfffffffc,%r12d
  mov    $0x1,%ebp
  lea    0x8(%rdi,%rax,8),%r13
  mov    %ecx,%eax
  shr    $0x2,%eax
  lea    -0x1(%rax),%r9d
  add    $0x1,%r9
  shl    $0x4,%r9
  mov    %r9,%r15
  nop
L397:
  movd   %ebp,%xmm3
  mov    %rdi,%rcx
  xor    %edx,%edx
  pshufd $0x0,%xmm3,%xmm2
  xchg   %ax,%ax
L94:
  test   %ebx,%ebx
  jle    L220
  mov    (%rcx),%r8
  cmp    $0x2,%r14d
  jbe    L301
  mov    %r8,%rax
  lea    (%r15,%r8,1),%rsi
  pxor   %xmm1,%xmm1
L269:
  movdqu (%rax),%xmm0
  add    $0x10,%rax
  pcmpeqd %xmm2,%xmm0
  psubd  %xmm0,%xmm1
  cmp    %rsi,%rax
  jne    L269
  movdqa %xmm1,%xmm0
  psrldq $0x8,%xmm0
  paddd  %xmm0,%xmm1
  movdqa %xmm1,%xmm0
  psrldq $0x4,%xmm0
  paddd  %xmm0,%xmm1
  movd   %xmm1,%eax
  add    %eax,%edx
  mov    %r12d,%eax
  cmp    %ebx,%r12d
  je     L220
L147:
  movslq %eax,%r9
  cmp    %ebp,(%r8,%r9,4)
  lea    0x0(,%r9,4),%rsi
  sete   %r9b
  movzbl %r9b,%r9d
  add    %r9d,%edx
  lea    0x1(%rax),%r9d
  cmp    %ebx,%r9d
  jge    L220
  cmp    0x4(%r8,%rsi,1),%ebp
  jne    L234
  add    $0x1,%edx
L234:
  add    $0x2,%eax
  cmp    %ebx,%eax
  jge    L220
  cmp    %ebp,0x8(%r8,%rsi,1)
  jne    L220
  add    $0x1,%edx
  nopl   0x0(%rax,%rax,1)
L220:
  add    $0x8,%rcx
  cmp    %r13,%rcx
  jne    L94
  test   %edx,%edx
  je     L316
  add    $0x1,%r11d
  mov    0x18(%rsp),%r8d
  mov    %ebx,%ecx
  mov    %ebp,%edx
  mov    %r11d,%esi
  mov    %r10d,0x10(%rsp)
  mov    %r11d,0x8(%rsp)
  mov    %rdi,(%rsp)
  call   <replace_obj_id@plt>
  mov    0x10(%rsp),%r10d
  mov    0x8(%rsp),%r11d
  mov    (%rsp),%rdi
L316:
  add    $0x1,%ebp
  cmp    %r10d,%ebp
  jle    L397
L180:
  add    $0x38,%rsp
  mov    %r11d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L163:
  test   %rbp,%rbp
  je     L28
  mov    -0x4(%r8,%rax,1),%r10d
  xor    %r8d,%r8d
  test   %r10d,%r10d
  je     L28
L111:
  test   %r10d,%r10d
  jne    L232
  test   %r8b,%r8b
  jne    L108
L232:
  test   %r10d,%r10d
  setne  %al
  test   %esi,%esi
  jne    L117
  test   %al,%al
  je     L167
  mov    %r10d,(%rdx)
  jmp    L167
L301:
  xor    %eax,%eax
  jmp    L147
L212:
  xor    %r11d,%r11d
  jmp    L180
L117:
  test   %al,%al
  je     L167
  test   %r8b,%r8b
  je     L167
  mov    %r9,0x28(%rsp)
  mov    %r11,0x20(%rsp)
  cmp    %esi,%r10d
  jle    L149
  mov    %esi,(%rdx)
  mov    0x18(%rsp),%r8d
  mov    %r10d,%edx
  mov    %ecx,0x1c(%rsp)
  mov    %rdi,0x10(%rsp)
  call   <replace_obj_id@plt>
  mov    0x10(%rsp),%rdi
  mov    0x1c(%rsp),%ecx
  mov    0x20(%rsp),%r11
  mov    0x28(%rsp),%r9
  jmp    L167
L149:
  mov    %r10d,(%rdx)
  mov    0x18(%rsp),%r8d
  mov    %esi,%edx
  mov    %r10d,%esi
  mov    %ecx,0x1c(%rsp)
  mov    %rdi,0x10(%rsp)
  call   <replace_obj_id@plt>
  mov    0x28(%rsp),%r9
  mov    0x20(%rsp),%r11
  mov    0x1c(%rsp),%ecx
  mov    0x10(%rsp),%rdi
  jmp    L167
```

assistant: ```c
int assign_id(unsigned char *img, int width, int height, int **obj_id) {
  int x, y, s;
  int count, val = 0;
  for (y = 0; y < height; y++) {
    for (x = 0; x < width; x++) {
      obj_id[y][x] = 0;
    }
  }
  for (y = 0; y < height; y++) {
    for (x = 0; x < width; x++) {
      if (img[x + y * width] == 0 && obj_id[y][x] == 0) {
        int u = 0, l = 0;
        if (y > 0)
          u = obj_id[y - 1][x];
        if (x > 0)
          l = obj_id[y][x - 1];
        if (u == 0 && l == 0) {
          obj_id[y][x] = ++val;
        } else if (u == l && u != 0) {
          obj_id[y][x] = u;
        } else if (u != 0 && l == 0) {
          obj_id[y][x] = u;
        } else if (u == 0 && l != 0) {
          obj_id[y][x] = l;
        } else if (u != 0 && l != 0) {
          if (u < l) {
            obj_id[y][x] = u;
            replace_obj_id(obj_id, u, l, width, height);
          } else {
            obj_id[y][x] = l;
            replace_obj_id(obj_id, l, u, width, height);
          }
        }
      }
    }
  }
  count = 0;
  for (s = 1; s <= val; s++) {
    int n = 0;
    for (y = 0; y < height; y++) {
      for (x = 0; x < width; x++) {
        if (obj_id[y][x] == s)
          n += 1;
      }
    }
    if (n > 0) {
      count += 1;
      replace_obj_id(obj_id, count, s, width, height);
    }
  }
  return count;
}
```