user: 请将以下的汇编代码转换成C语言代码:

```asm
<assign_id>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,(%rsp)
  mov    %edx,0x18(%rsp)
  test   %edx,%edx
  jle    L303
  mov    0x18(%rsp),%eax
  lea    -0x1(%rsi),%r15d
  mov    %esi,%ebp
  mov    %rcx,%rbx
  lea    0x4(,%r15,4),%r9
  mov    %rcx,%r13
  sub    $0x1,%eax
  mov    %r9,%r12
  lea    0x8(%rcx,%rax,8),%r14
  nopl   (%rax)
L18:
  test   %ebp,%ebp
  jle    L43
  mov    (%rbx),%rdi
  mov    %r12,%rdx
  xor    %esi,%esi
  call   <memset@plt>
L43:
  add    $0x8,%rbx
  cmp    %r14,%rbx
  jne    L18
  xor    %r11d,%r11d
  mov    0x18(%rsp),%eax
  mov    %r12,0x8(%rsp)
  xor    %esi,%esi
  mov    %r14,0x10(%rsp)
  mov    %r11d,%r14d
  mov    (%rsp),%r11
  mov    %r13,%r10
  mov    %ebp,%ecx
  xor    %r13d,%r13d
  mov    %rax,%r9
  mov    %esi,%ebp
  nopl   0x0(%rax)
L167:
  movslq %ebp,%r12
  xor    %ebx,%ebx
  add    %r11,%r12
  test   %ecx,%ecx
  jle    L21
L13:
  cmpb   $0x0,(%r12,%rbx,1)
  jne    L202
  mov    (%r10,%r13,8),%rdi
  lea    0x0(,%rbx,4),%rax
  lea    (%rdi,%rax,1),%rdx
  mov    (%rdx),%esi
  test   %esi,%esi
  jne    L202
  test   %r13,%r13
  je     L317
  mov    -0x8(%r10,%r13,8),%rsi
  mov    (%rsi,%rax,1),%esi
  test   %rbx,%rbx
  je     L37
  mov    -0x4(%rdi,%rax,1),%eax
  mov    %esi,%edi
  or     %eax,%edi
  je     L348
  test   %esi,%esi
  setne  %dil
  mov    %edi,%r8d
  cmp    %eax,%esi
  jne    L101
  test   %dil,%dil
  je     L101
L45:
  mov    %esi,(%rdx)
  nopl   0x0(%rax)
L202:
  lea    0x1(%rbx),%rax
  cmp    %rbx,%r15
  je     L21
L75:
  mov    %rax,%rbx
  jmp    L13
L37:
  test   %esi,%esi
  jne    L45
  nopw   0x0(%rax,%rax,1)
L348:
  add    $0x1,%r14d
  lea    0x1(%rbx),%rax
  mov    %r14d,(%rdx)
  cmp    %rbx,%r15
  jne    L75
  nopl   0x0(%rax,%rax,1)
L21:
  add    $0x1,%r13
  add    %ecx,%ebp
  cmp    %r9,%r13
  jne    L167
  mov    %r14d,%r11d
  mov    0x8(%rsp),%r9
  mov    0x10(%rsp),%r14
  mov    %ecx,%ebp
  xor    %r12d,%r12d
  mov    $0x1,%ebx
  test   %r11d,%r11d
  je     L303
  mov    %r12d,%esi
  mov    %r9,%r15
  mov    %r11d,%r13d
  mov    %r10,%r12
  nopl   0x0(%rax,%rax,1)
L68:
  mov    %r12,%r8
  xor    %edx,%edx
  nopl   (%rax)
L295:
  test   %ebp,%ebp
  jle    L159
  mov    (%r8),%rax
  lea    (%rax,%r15,1),%rdi
  nopl   0x0(%rax,%rax,1)
L231:
  xor    %ecx,%ecx
  cmp    %ebx,(%rax)
  sete   %cl
  add    $0x4,%rax
  add    %ecx,%edx
  cmp    %rax,%rdi
  jne    L231
L159:
  add    $0x8,%r8
  cmp    %r14,%r8
  jne    L295
  test   %edx,%edx
  je     L243
  mov    0x18(%rsp),%r8d
  add    $0x1,%esi
  mov    %ebp,%ecx
  mov    %ebx,%edx
  mov    %r12,%rdi
  mov    %esi,(%rsp)
  call   <replace_obj_id@plt>
  mov    (%rsp),%esi
L243:
  add    $0x1,%ebx
  cmp    %r13d,%ebx
  jle    L68
  mov    %esi,%r12d
L312:
  add    $0x38,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L317:
  test   %rbx,%rbx
  je     L348
  mov    -0x4(%rdi,%rax,1),%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  je     L348
L101:
  test   %eax,%eax
  jne    L176
  test   %r8b,%r8b
  jne    L45
L176:
  test   %eax,%eax
  setne  %dil
  test   %esi,%esi
  jne    L337
  test   %dil,%dil
  je     L337
  mov    %eax,(%rdx)
  jmp    L202
L337:
  test   %r8b,%r8b
  je     L202
  test   %dil,%dil
  je     L202
  mov    %r11,0x28(%rsp)
  mov    %r9,0x20(%rsp)
  cmp    %eax,%esi
  jge    L284
  mov    %esi,(%rdx)
  mov    0x18(%rsp),%r8d
  mov    %r10,%rdi
  mov    %eax,%edx
  mov    %ecx,0x1c(%rsp)
  mov    %r10,(%rsp)
  call   <replace_obj_id@plt>
  mov    (%rsp),%r10
  mov    0x1c(%rsp),%ecx
  mov    0x20(%rsp),%r9
  mov    0x28(%rsp),%r11
  jmp    L202
L284:
  mov    %eax,(%rdx)
  mov    0x18(%rsp),%r8d
  mov    %esi,%edx
  mov    %r10,%rdi
  mov    %eax,%esi
  mov    %ecx,0x1c(%rsp)
  mov    %r10,(%rsp)
  call   <replace_obj_id@plt>
  mov    0x28(%rsp),%r11
  mov    0x20(%rsp),%r9
  mov    0x1c(%rsp),%ecx
  mov    (%rsp),%r10
  jmp    L202
L303:
  xor    %r12d,%r12d
  jmp    L312
```

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