user: What is the c source code of the assembly code below?

```asm
<define_mode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x2c(%rbp)
  movq   $0x0,-0x8(%rbp)
  jmp    L313
L326:
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0xff,%eax
  jle    L287
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x4b,(%rax)
  jmp    L71
L287:
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x42,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <in_alpha@plt>
  test   %rax,%rax
  je     L106
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x41,(%rax)
L106:
  cmpl   $0x0,-0x2c(%rbp)
  je     L143
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0x5b,%eax
  jne    L143
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x41,(%rax)
L143:
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0x2f,%eax
  jle    L71
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0x39,%eax
  jg     L71
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x4e,(%rax)
L71:
  addq   $0x1,-0x8(%rbp)
L313:
  mov    -0x8(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jb     L326
  movq   $0x0,-0x8(%rbp)
  jmp    L194
L133:
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x4e,%al
  jne    L321
  cmpq   $0x0,-0x8(%rbp)
  je     L260
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x4e,%al
  jne    L162
L260:
  cmpq   $0x0,-0x8(%rbp)
  jne    L321
L162:
  movl   $0x0,-0x10(%rbp)
  jmp    L33
L145:
  addl   $0x1,-0x10(%rbp)
L33:
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x28(%rbp)
  jbe    L161
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x4e,%al
  je     L145
L161:
  cmpl   $0x5,-0x10(%rbp)
  jg     L321
  movl   $0x0,-0xc(%rbp)
  jmp    L96
L119:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x41,(%rax)
  addl   $0x1,-0xc(%rbp)
L96:
  mov    -0xc(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L119
L321:
  addq   $0x1,-0x8(%rbp)
L194:
  mov    -0x8(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jb     L133
  movq   $0x0,-0x8(%rbp)
  jmp    L138
L219:
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x41,%al
  jne    L231
  cmpq   $0x0,-0x8(%rbp)
  je     L306
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x41,%al
  jne    L298
L306:
  cmpq   $0x0,-0x8(%rbp)
  jne    L231
L298:
  movl   $0x0,-0x10(%rbp)
  jmp    L70
L268:
  addl   $0x1,-0x10(%rbp)
L70:
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x28(%rbp)
  jbe    L176
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x41,%al
  je     L268
L176:
  cmpl   $0x5,-0x10(%rbp)
  jg     L231
  movl   $0x0,-0xc(%rbp)
  jmp    L182
L125:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x42,(%rax)
  addl   $0x1,-0xc(%rbp)
L182:
  mov    -0xc(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L125
L231:
  addq   $0x1,-0x8(%rbp)
L138:
  mov    -0x8(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jb     L219
  nop
  nop
  leave
  ret
```

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