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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    0x8(%rsi),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L230
  xor    %r14d,%r14d
  mov    $0x64,%r15d
  mov    $0x1f4,%edx
  mov    $0x1f4,%eax
  mov    %r14d,0x18(%rsp)
  lea    0x8(%rsi),%rbx
  lea    0x34(%rsp),%r12
  mov    %edx,%r14d
  mov    %r15d,0x20(%rsp)
  lea    0x33(%rsp),%rbp
  mov    %eax,%r15d
  lea    D4(%rip),%r13
  movl   $0x21,0x28(%rsp)
  movl   $0x0,0x10(%rsp)
  movl   $0x3e8,0x8(%rsp)
  movl   $0x0,0x2c(%rsp)
  jmp    L160
  nopl   0x0(%rax)
L259:
  mov    0x34(%rsp),%eax
  test   %eax,%eax
  jle    L13
  movzbl 0x33(%rsp),%edx
  cmp    $0x72,%dl
  je     L42
  jg     L46
  cmp    $0x4c,%dl
  je     L0
  cmp    $0x6c,%dl
  cmove  %eax,%r15d
  nopl   0x0(%rax)
L171:
  mov    0x8(%rbx),%rdi
  add    $0x8,%rbx
  test   %rdi,%rdi
  je     L270
L160:
  mov    %r12,%rcx
  mov    %rbp,%rdx
  mov    %r13,%rsi
  call   <sscanf@plt>
  cmp    $0x2,%eax
  je     L259
L13:
  mov    (%rbx),%rdi
  mov    %r12,%rcx
  mov    %rbp,%rdx
  lea    D12(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x2,%eax
  jne    L236
  mov    0x34(%rsp),%eax
  test   %eax,%eax
  js     L236
  movzbl 0x33(%rsp),%edx
  cmp    $0x70,%dl
  je     L23
  jg     L226
  cmp    $0x69,%dl
  je     L130
  cmp    $0x6d,%dl
  cmovne 0x10(%rsp),%eax
  mov    0x8(%rbx),%rdi
  add    $0x8,%rbx
  mov    %eax,0x10(%rsp)
  test   %rdi,%rdi
  jne    L160
L270:
  mov    %r14d,%ebx
  mov    0x18(%rsp),%r14d
  mov    %r15d,0x14(%rsp)
  mov    %r15d,%edi
  mov    0x20(%rsp),%r15d
  test   %r14d,%r14d
  je     L176
  call   <read_labels@plt>
  mov    %rax,0x20(%rsp)
L219:
  mov    0x28(%rsp),%esi
  mov    %r15d,%edi
  lea    D18(%rip),%r13
  call   <genrights@plt>
  mov    0x8(%rsp),%esi
  mov    0x2c(%rsp),%ecx
  mov    %ebx,%edx
  mov    0x14(%rsp),%edi
  mov    %rax,%r12
  call   <make_the_rules@plt>
  lea    -0x1(%rbx),%edx
  lea    0x4(%rax),%rsi
  lea    (%rsi,%rdx,4),%rdx
  mov    %rsi,0x8(%rsp)
  mov    %rdx,0x18(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L254:
  mov    (%rax),%eax
  mov    0x20(%rsp),%rbx
  xor    %r14d,%r14d
  cltd
  mov    %eax,0x34(%rsp)
  idivl  0x14(%rsp)
  movslq %edx,%rdx
  cltq
  lea    (%rbx,%rdx,8),%rbp
  lea    (%rbx,%rax,8),%rbx
L145:
  mov    %r15d,%edi
  add    $0x1,%r14d
  call   <alea@plt>
  mov    0x0(%rbp),%rdx
  mov    (%rbx),%rsi
  mov    %r13,%rdi
  mov    (%r12,%rax,8),%rcx
  call   <printf@plt>
  cmp    0x10(%rsp),%r14d
  jle    L145
  mov    0x8(%rsp),%rsi
  mov    %rsi,%rax
  cmp    %rsi,0x18(%rsp)
  je     L137
  lea    0x4(%rsi),%rdx
  mov    %rdx,0x8(%rsp)
  jmp    L254
L236:
  xor    %eax,%eax
  call   <usage@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L171
  cs nopw 0x0(%rax,%rax,1)
L46:
  cmp    $0x75,%dl
  cmove  %eax,%r14d
  jmp    L171
L226:
  cmp    $0x73,%dl
  jne    L171
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
  mov    %eax,0x2c(%rsp)
  jmp    L171
  cs nopw 0x0(%rax,%rax,1)
L0:
  mov    %eax,0x8(%rsp)
  jmp    L171
  nopl   0x0(%rax)
L137:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L264
  add    $0x48,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L130:
  mov    %eax,0x18(%rsp)
  jmp    L171
L230:
  movl   $0x21,0x28(%rsp)
  mov    $0x64,%r15d
  mov    $0x1f4,%ebx
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0x2c(%rsp)
  movl   $0x1f4,0x14(%rsp)
  movl   $0x3e8,0x8(%rsp)
L176:
  mov    0x14(%rsp),%edi
  mov    $0x18,%edx
  mov    $0x4,%esi
  call   <gen_labels@plt>
  mov    %rax,0x20(%rsp)
  jmp    L219
L42:
  mov    %eax,0x20(%rsp)
  jmp    L171
L23:
  mov    %eax,0x28(%rsp)
  jmp    L171
L264:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D4
type_guessed: string
name: disassemble_data
arguments: tag: D12
type_guessed: string
name: disassemble_data
arguments: tag: D18
type_guessed: string

tool: D4: %1[lLru]=%d

tool: D12: %1[misp]=%d

tool: D18: %s %s %s


assistant: ```c
int main(int argc, char **argv) {
  int shuffle = 0;
  int lab_cnt = 500;
  int rig_cnt = 100;
  int rul_cnt = 500;
  int lab_max = rul_cnt * 2;
  int mer_cnt = 0;
  int lab_stdin = 0;
  int permodif = 33;
  char **labels;
  char **rights, c;
  int n, r, m, sub, obj;
  int *rules;
  while (*++argv) {
    if (sscanf(*argv, "%1[lLru]=%d", &c, &n) == 2 && n > 0) {
      switch (c) {
      case 'l':
        lab_cnt = n;
        break;
      case 'r':
        rig_cnt = n;
        break;
      case 'u':
        rul_cnt = n;
        break;
      case 'L':
        lab_max = n;
        break;
      }
    } else if (sscanf(*argv, "%1[misp]=%d", &c, &n) == 2 && n >= 0) {
      switch (c) {
      case 'm':
        mer_cnt = n;
        break;
      case 'i':
        lab_stdin = n;
        break;
      case 's':
        shuffle = !!n;
        break;
      case 'p':
        permodif = n;
        break;
      }
    } else {
      usage();
      exit(1);
    }
  }
  if (lab_stdin)
    labels = read_labels(lab_cnt);
  else
    labels = gen_labels(lab_cnt, 4, 24);
  rights = genrights(rig_cnt, permodif);
  rules = make_the_rules(lab_cnt, lab_max, rul_cnt, shuffle);
  for (r = 0; r < rul_cnt; r++) {
    n = rules[r];
    sub = n / lab_cnt;
    obj = n % lab_cnt;
    for (m = 0; m <= mer_cnt; m++)
      printf("%s %s %s\n", labels[sub], labels[obj], rights[alea(rig_cnt)]);
  }
  return 0;
}
```