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

```asm
<randnorep>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    D15(%rip),%rbp
  push   %rbx
  mov    %edi,%ebx
  test   %rbp,%rbp
  je     L270
L112:
  cmp    $0xfffffffc,%ebx
  je     L121
  cmp    $0xffffffff,%ebx
  je     L156
  cmp    $0xfffffffe,%ebx
  je     L72
  cmp    $0xfffffffd,%ebx
  jne    L238
  mov    D89(%rip),%esi
  test   %esi,%esi
  je     L198
  mov    (%r12),%ecx
  mov    %rbp,%rdi
  xor    %edx,%edx
  jmp    L243
  cs nopw 0x0(%rax,%rax,1)
L154:
  mov    0x8(%rdi),%rax
  mov    %rdi,%rdx
  test   %rax,%rax
  je     L238
  mov    %rax,%rdi
L243:
  cmp    %ecx,(%rdi)
  jne    L154
  sub    $0x1,%esi
  mov    %esi,D58(%rip)
  test   %esi,%esi
  jle    L179
  test   %rdx,%rdx
  je     L15
  mov    0x8(%rdi),%rax
  mov    %rax,0x8(%rdx)
  jmp    L134
  nopl   0x0(%rax,%rax,1)
L156:
  mov    D58(%rip),%esi
  test   %esi,%esi
  je     L198
  xor    %edi,%edi
  call   <randmm@plt>
  mov    D15(%rip),%rdi
  test   %eax,%eax
  jle    L69
  xor    %edx,%edx
  cs nopw 0x0(%rax,%rax,1)
L129:
  add    $0x1,%edx
  mov    %rdi,%rcx
  mov    0x8(%rdi),%rdi
  cmp    %edx,%eax
  jne    L129
  mov    (%rdi),%eax
  mov    %eax,(%r12)
  mov    D58(%rip),%eax
  sub    $0x1,%eax
  mov    %eax,D58(%rip)
  test   %eax,%eax
  jle    L179
  mov    0x8(%rdi),%rax
  mov    %rax,0x8(%rcx)
L134:
  call   <free@plt>
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L179:
  xor    %eax,%eax
L36:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L121:
  mov    (%r12),%eax
  test   %eax,%eax
  jle    L238
  mov    0x8(%rbp),%rbx
  test   %rbx,%rbx
  je     L120
  nopl   0x0(%rax)
L116:
  mov    %rbx,%rdi
  mov    0x8(%rbx),%rbx
  call   <free@plt>
  test   %rbx,%rbx
  jne    L116
  mov    (%r12),%eax
  mov    D15(%rip),%rbp
  mov    %eax,D58(%rip)
  movq   $0x0,0x8(%rbp)
  test   %eax,%eax
  jle    10a0 <randnorep.cold>
L65:
  xor    %ebx,%ebx
  nopl   0x0(%rax)
L132:
  mov    %ebx,0x0(%rbp)
  mov    $0x10,%edi
  mov    %rbp,%r12
  add    $0x1,%ebx
  call   <malloc@plt>
  cmp    %ebx,D58(%rip)
  mov    %rax,0x8(%r12)
  mov    %rax,%rbp
  movq   $0x0,0x8(%rax)
  jg     L132
  mov    %rax,%rdi
  call   <free@plt>
  xor    %eax,%eax
  movq   $0x0,0x8(%r12)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L270:
  mov    $0x10,%edi
  call   <malloc@plt>
  mov    %rax,D58(%rip)
  mov    %rax,%rbp
  movq   $0x0,0x8(%rax)
  mov    %rax,D58(%rip)
  jmp    L112
  nopl   0x0(%rax,%rax,1)
L72:
  mov    D58(%rip),%eax
  test   %eax,%eax
  je     L83
  mov    D58(%rip),%rax
  test   %rax,%rax
  je     L292
  mov    (%rax),%edx
  mov    0x8(%rax),%rax
  mov    %edx,(%r12)
  pop    %rbx
  mov    %rax,D12(%rip)
  pop    %rbp
  xor    %eax,%eax
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L238:
  pop    %rbx
  mov    $0xfffffffd,%eax
  pop    %rbp
  pop    %r12
  ret
L69:
  mov    (%rdi),%eax
  mov    %eax,(%r12)
  mov    D58(%rip),%eax
  sub    $0x1,%eax
  mov    %eax,D12(%rip)
  test   %eax,%eax
  jle    L179
  mov    0x8(%rdi),%rax
  mov    %rax,D12(%rip)
  mov    %rax,D12(%rip)
  jmp    L134
  xchg   %ax,%ax
L15:
  mov    0x8(%rbp),%rax
  mov    %rax,D12(%rip)
  mov    %rax,D12(%rip)
  jmp    L134
  nopw   0x0(%rax,%rax,1)
L120:
  mov    %eax,D12(%rip)
  jmp    L65
L198:
  mov    $0xffffffff,%eax
  jmp    L36
L83:
  mov    $0xfffffffe,%eax
  jmp    L36
L292:
  mov    %rbp,D12(%rip)
  mov    $0xfffffffe,%eax
  jmp    L36
```

assistant: ```c
int randnorep(int mode, int *n) {
  struct listnum {
    int num;
    struct listnum *prox;
  };
  static int listqtd = 0;
  static struct listnum *lcab = NULL;
  struct listnum *ln = NULL, *lant = NULL;
  static struct listnum *lista = NULL;
  int j;
  int sort;
  if (lcab == NULL) {
    lcab = (struct listnum *)malloc(sizeof(struct listnum));
    lcab->prox = NULL;
    lista = lcab;
  }
  if (mode == -4) {
    if (*n < 1)
      return -3;
    lant = lcab->prox;
    while (lant != NULL) {
      ln = lant->prox;
      free(lant);
      lant = ln;
    }
    lcab->prox = NULL;
    listqtd = *n;
    ln = lcab;
    for (j = 0; j < listqtd; j++) {
      ln->num = j;
      ln->prox = (struct listnum *)malloc(sizeof(struct listnum));
      lant = ln;
      ln = ln->prox;
      ln->prox = NULL;
    }
    free(ln);
    lant->prox = NULL;
    return 0;
  } else if (mode == -1) {
    if (listqtd == 0)
      return -1;
    sort = randmm(0, listqtd);
    ln = lcab;
    lant = NULL;
    for (j = 0; j < sort; j++) {
      lant = ln;
      ln = ln->prox;
    }
    *n = ln->num;
    listqtd--;
    if (listqtd <= 0)
      return 0;
    if (lant != NULL)
      lant->prox = ln->prox;
    else {
      lcab = lcab->prox;
      lista = lcab;
    }
    free(ln);
    return 0;
  } else if (mode == -2) {
    if (listqtd == 0)
      return -2;
    if (lista == NULL) {
      lista = lcab;
      return -2;
    }
    while (lista != NULL) {
      *n = lista->num;
      lista = lista->prox;
      return 0;
    }
  } else if (mode == -3) {
    if (listqtd == 0)
      return -1;
    sort = *n;
    ln = lcab;
    lant = NULL;
    while (ln != NULL) {
      if (ln->num == sort)
        break;
      lant = ln;
      ln = ln->prox;
    }
    if (ln == NULL)
      return -3;
    listqtd--;
    if (listqtd <= 0)
      return 0;
    if (lant != NULL)
      lant->prox = ln->prox;
    else {
      lcab = lcab->prox;
      lista = lcab;
    }
    free(ln);
    return 0;
  }
  return -3;
}
```