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

```asm
<define_mode>:
  endbr64
  push   %r15
  lea    (%rdi,%rdx,1),%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rdx,%rdx
  je     L185
  mov    %rdi,%rbx
  mov    %rdx,%r13
  mov    %ecx,%r14d
  mov    %rsi,%r12
  mov    %rdi,%rbp
  jmp    L377
L201:
  movb   $0x4b,0x0(%rbp)
L63:
  add    $0x1,%rbp
  add    $0x4,%r12
  cmp    %rbp,%r15
  je     L308
L377:
  cmpl   $0xff,(%r12)
  jg     L201
  movb   $0x42,0x0(%rbp)
  mov    (%r12),%edi
  call   <in_alpha@plt>
  test   %rax,%rax
  je     L330
  movb   $0x41,0x0(%rbp)
L330:
  mov    (%r12),%eax
  test   %r14d,%r14d
  je     L336
  cmp    $0x5b,%eax
  jne    L336
  movb   $0x41,0x0(%rbp)
  mov    (%r12),%eax
  nopw   0x0(%rax,%rax,1)
L336:
  sub    $0x30,%eax
  cmp    $0x9,%eax
  ja     L63
  movb   $0x4e,0x0(%rbp)
  add    $0x1,%rbp
  add    $0x4,%r12
  cmp    %rbp,%r15
  jne    L377
  nopl   0x0(%rax)
L308:
  xor    %edx,%edx
  mov    $0x1,%r8d
  jmp    L142
  nopw   0x0(%rax,%rax,1)
L224:
  lea    0x1(%rdx),%rdi
L251:
  cmp    %rdi,%r13
  je     L376
L163:
  mov    %rdi,%rdx
L142:
  movzbl (%rbx,%rdx,1),%ecx
  cmp    $0x4e,%cl
  jne    L224
  test   %rdx,%rdx
  je     L109
  cmpb   $0x4e,-0x1(%rbx,%rdx,1)
  lea    0x1(%rdx),%rdi
  je     L251
  cmp    %rdx,%r13
  jbe    L251
L41:
  lea    0x1(%rdx),%rdi
  xor    %esi,%esi
  mov    %rdi,%rax
  jmp    L192
  nopl   (%rax)
L406:
  add    $0x1,%esi
  cmp    %rax,%r13
  jbe    L285
  movzbl (%rbx,%rax,1),%ecx
  add    $0x1,%rax
L192:
  cmp    $0x4e,%cl
  je     L406
  lea    -0x1(%rsi),%eax
  cmp    $0x4,%eax
  ja     L251
L320:
  movslq %esi,%rax
  test   %esi,%esi
  lea    (%rbx,%rdx,1),%rsi
  cmovle %r8,%rax
  mov    %eax,%r9d
  test   %eax,%eax
  je     L251
  xor    %eax,%eax
L28:
  mov    %eax,%ecx
  add    $0x1,%eax
  movb   $0x41,(%rsi,%rcx,1)
  cmp    %r9d,%eax
  jb     L28
  cmp    %rdi,%r13
  jne    L163
  xchg   %ax,%ax
L376:
  xor    %eax,%eax
  mov    $0x1,%r10d
  jmp    L12
  nopw   0x0(%rax,%rax,1)
L312:
  lea    0x1(%rax),%r9
L307:
  cmp    %rdx,%rax
  je     L185
L298:
  mov    %r9,%rax
L12:
  movzbl (%rbx,%rax,1),%esi
  cmp    $0x41,%sil
  jne    L312
  test   %rax,%rax
  je     L90
  cmpb   $0x41,-0x1(%rbx,%rax,1)
  lea    0x1(%rax),%r9
  je     L307
  cmp    %rax,%rdi
  jbe    L307
L282:
  lea    0x1(%rax),%r9
  xor    %r8d,%r8d
  mov    %r9,%rcx
  jmp    L132
  nop
L356:
  add    $0x1,%r8d
  cmp    %rcx,%rdi
  jbe    L183
  movzbl (%rbx,%rcx,1),%esi
  add    $0x1,%rcx
L132:
  cmp    $0x41,%sil
  je     L356
  lea    -0x1(%r8),%ecx
  cmp    $0x4,%ecx
  ja     L307
L188:
  movslq %r8d,%rcx
  test   %r8d,%r8d
  lea    (%rbx,%rax,1),%r8
  cmovle %r10,%rcx
  mov    %ecx,%r11d
  test   %ecx,%ecx
  je     L307
  xor    %ecx,%ecx
L123:
  mov    %ecx,%esi
  add    $0x1,%ecx
  movb   $0x42,(%r8,%rsi,1)
  cmp    %r11d,%ecx
  jb     L123
  cmp    %rdx,%rax
  jne    L298
L185:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L109:
  movzbl (%rbx),%ecx
  jmp    L41
  nopl   0x0(%rax,%rax,1)
L90:
  movzbl (%rbx),%esi
  jmp    L282
  nopl   0x0(%rax,%rax,1)
L183:
  cmp    $0x5,%r8d
  jg     L307
  jmp    L188
  nopl   0x0(%rax)
L285:
  cmp    $0x5,%esi
  jg     L251
  jmp    L320
```

assistant: ```c
void define_mode(char mode[], const int jisdata[], const size_t length, const int gs1) {
  size_t i;
  int mlen, j;
  for (i = 0; i < length; i++) {
    if (jisdata[i] > 0xff) {
      mode[i] = 'K';
    } else {
      mode[i] = 'B';
      if (in_alpha(jisdata[i])) {
        mode[i] = 'A';
      }
      if (gs1 && (jisdata[i] == '[')) {
        mode[i] = 'A';
      }
      if ((jisdata[i] >= '0') && (jisdata[i] <= '9')) {
        mode[i] = 'N';
      }
    }
  }
  for (i = 0; i < length; i++) {
    if (mode[i] == 'N') {
      if (((i != 0) && (mode[i - 1] != 'N')) || (i == 0)) {
        mlen = 0;
        while (((mlen + i) < length) && (mode[mlen + i] == 'N')) {
          mlen++;
        };
        if (mlen < 6) {
          for (j = 0; j < mlen; j++) {
            mode[i + j] = 'A';
          }
        }
      }
    }
  }
  for (i = 0; i < length; i++) {
    if (mode[i] == 'A') {
      if (((i != 0) && (mode[i - 1] != 'A')) || (i == 0)) {
        mlen = 0;
        while (((mlen + i) < length) && (mode[mlen + i] == 'A')) {
          mlen++;
        };
        if (mlen < 6) {
          for (j = 0; j < mlen; j++) {
            mode[i + j] = 'B';
          }
        }
      }
    }
  }
}
```