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

```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,0x1c(%rsp)
  mov    $0x0,%ebp
  test   %edx,%edx
  jle    L379
  mov    %esi,%r12d
  mov    %rcx,%r15
  mov    0x1c(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x8(%rcx,%rax,8),%r14
  lea    -0x1(%rsi),%eax
  mov    %rax,0x20(%rsp)
  lea    0x4(,%rax,4),%rsi
  jmp    L31
L246:
  mov    (%rcx),%rdx
  movl   $0x0,(%rdx,%rax,1)
  add    $0x4,%rax
  cmp    %rsi,%rax
  jne    L246
L63:
  add    $0x8,%rcx
  cmp    %r14,%rcx
  je     L243
L31:
  mov    $0x0,%eax
  test   %r12d,%r12d
  jg     L246
  jmp    L63
L243:
  mov    0x1c(%rsp),%eax
  mov    %rax,0x8(%rsp)
  movl   $0x0,0x18(%rsp)
  mov    $0x0,%r13d
  mov    $0x0,%eax
  mov    %r14,0x28(%rsp)
  mov    %eax,%r14d
  mov    %r12d,0x4(%rsp)
  mov    0x20(%rsp),%r12
  jmp    L343
L9:
  test   %esi,%esi
  setne  %cl
  test   %edi,%edi
  jne    L43
  test   %cl,%cl
  je     L43
  mov    %esi,(%rdx)
  jmp    L15
L43:
  test   %cl,%cl
  je     L15
  test   %al,%al
  je     L15
  cmp    %esi,%edi
  jge    L175
  mov    %edi,(%rdx)
  mov    0x1c(%rsp),%r8d
  mov    0x4(%rsp),%ecx
  mov    %esi,%edx
  mov    %edi,%esi
  mov    %r15,%rdi
  call   <replace_obj_id@plt>
  jmp    L15
L175:
  mov    %esi,(%rdx)
  mov    0x1c(%rsp),%r8d
  mov    0x4(%rsp),%ecx
  mov    %edi,%edx
  mov    %r15,%rdi
  call   <replace_obj_id@plt>
  jmp    L15
L368:
  add    $0x1,%r13
  mov    0x4(%rsp),%edi
  add    %edi,0x18(%rsp)
  cmp    0x8(%rsp),%r13
  je     L25
L343:
  mov    0x18(%rsp),%ebp
  mov    $0x0,%ebx
  movslq %ebp,%rbp
  add    0x10(%rsp),%rbp
  cmpl   $0x0,0x4(%rsp)
  jg     L196
  jmp    L368
L25:
  mov    %r14d,%eax
  mov    %r14d,0x18(%rsp)
  mov    0x28(%rsp),%r14
  mov    0x4(%rsp),%r12d
  test   %eax,%eax
  jle    L317
  mov    $0x0,%ebp
  mov    $0x1,%ebx
  mov    0x20(%rsp),%rax
  lea    0x4(,%rax,4),%r13
  jmp    L344
L317:
  mov    $0x0,%ebp
L379:
  mov    %ebp,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L173:
  mov    (%rdi),%rax
  lea    0x0(%r13,%rax,1),%rsi
L132:
  cmp    %ebx,(%rax)
  sete   %cl
  movzbl %cl,%ecx
  add    %ecx,%edx
  add    $0x4,%rax
  cmp    %rsi,%rax
  jne    L132
L99:
  add    $0x8,%rdi
  cmp    %r14,%rdi
  je     L64
L10:
  test   %r12d,%r12d
  jg     L173
  jmp    L99
L64:
  test   %edx,%edx
  jg     L37
L395:
  add    $0x1,%ebx
  cmp    0x18(%rsp),%ebx
  jg     L379
L344:
  mov    %r15,%rdi
  mov    $0x0,%edx
  jmp    L10
L37:
  add    $0x1,%ebp
  mov    0x1c(%rsp),%r8d
  mov    %r12d,%ecx
  mov    %ebx,%edx
  mov    %ebp,%esi
  mov    %r15,%rdi
  call   <replace_obj_id@plt>
  jmp    L395
L348:
  mov    %esi,%edi
  test   %ebx,%ebx
  jg     L172
L365:
  add    $0x1,%r14d
  mov    %r14d,(%rdx)
L15:
  lea    0x1(%rbx),%rax
  cmp    %r12,%rbx
  je     L368
  mov    %rax,%rbx
L196:
  cmpb   $0x0,0x0(%rbp,%rbx,1)
  jne    L15
  mov    (%r15,%r13,8),%rcx
  lea    0x0(,%rbx,4),%rax
  lea    (%rcx,%rax,1),%rdx
  mov    (%rdx),%esi
  test   %esi,%esi
  jne    L15
  test   %r13d,%r13d
  jle    L348
  mov    -0x8(%r15,%r13,8),%rdi
  mov    (%rdi,%rax,1),%edi
  test   %ebx,%ebx
  jle    L358
L172:
  mov    -0x4(%rcx,%rax,1),%esi
  mov    %edi,%eax
  or     %esi,%eax
  je     L365
  test   %edi,%edi
  setne  %al
  cmp    %esi,%edi
  jne    L163
  test   %al,%al
  je     L163
  mov    %edi,(%rdx)
  jmp    L15
L358:
  test   %edi,%edi
  je     L365
  setne  %al
L163:
  test   %esi,%esi
  jne    L9
  test   %al,%al
  je     L9
  mov    %edi,(%rdx)
  jmp    L15
```

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