user: Translate the below assembly code into C programming language:

```asm
<build_default_affinity_string>:
  endbr64
  push   %r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <numa_num_configured_nodes@plt>
  mov    %eax,%r13d
  xor    %eax,%eax
  call   <numa_num_configured_cpus@plt>
  lea    0x0(,%r13,8),%edi
  movl   $0x200,0x38(%rsp)
  movl   $0x0,0x3c(%rsp)
  mov    %eax,%ebx
  call   <malloc@plt>
  mov    %rax,0x10(%rsp)
  test   %r13d,%r13d
  jle    L118
  mov    %rax,%r12
  mov    %rax,%rbp
  xor    %r15d,%r15d
  nopw   0x0(%rax,%rax,1)
L104:
  xor    %eax,%eax
  add    $0x8,%rbp
  call   <numa_allocate_cpumask@plt>
  mov    %r15d,%edi
  mov    %rax,-0x8(%rbp)
  mov    %rax,%rsi
  call   <numa_node_to_cpus@plt>
  mov    %r15d,%edx
  add    $0x1,%r15d
  cmp    %r15d,%r13d
  jne    L104
  mov    0x38(%rsp),%edi
  mov    %edx,0x8(%rsp)
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x40(%rsp)
  call   <assert@plt>
  test   %r14d,%r14d
  mov    0x8(%rsp),%edx
  jne    L30
  test   %ebx,%ebx
  jle    L113
  mov    0x10(%rsp),%rax
  lea    0x3c(%rsp),%r13
  lea    0x8(%rax,%rdx,8),%r14
L49:
  xor    %ebp,%ebp
  jmp    L151
  nopl   0x0(%rax)
L166:
  add    $0x1,%ebp
  cmp    %ebp,%ebx
  je     L128
L151:
  mov    (%r12),%rdi
  mov    %ebp,%esi
  call   <numa_bitmask_isbitset@plt>
  test   %rax,%rax
  je     L166
  mov    %ebp,%ecx
  lea    0x38(%rsp),%rsi
  lea    0x40(%rsp),%rdi
  mov    %r13,%rdx
  call   <add_core_to_str@plt>
  add    $0x1,%ebp
  cmp    %ebp,%ebx
  jne    L151
L128:
  add    $0x8,%r12
  cmp    %r14,%r12
  jne    L49
L113:
  movslq 0x3c(%rsp),%rax
  test   %eax,%eax
  je     L32
  mov    0x40(%rsp),%rdx
  movb   $0x0,-0x1(%rdx,%rax,1)
L32:
  mov    0x40(%rsp),%rax
  mov    0x48(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L107
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L118:
  mov    0x38(%rsp),%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x40(%rsp)
  call   <assert@plt>
  test   %r14d,%r14d
  je     L113
  nopl   0x0(%rax)
L30:
  test   %ebx,%ebx
  jle    L113
  lea    0x3c(%rsp),%rax
  movl   $0x0,0xc(%rsp)
  mov    %rax,0x20(%rsp)
  lea    0x38(%rsp),%rax
  mov    %rax,0x18(%rsp)
  lea    0x40(%rsp),%rax
  movl   $0x0,0x8(%rsp)
  mov    %rax,0x28(%rsp)
  nopw   0x0(%rax,%rax,1)
L140:
  mov    0x8(%rsp),%eax
  mov    0x10(%rsp),%rcx
  xor    %r15d,%r15d
  xor    %r14d,%r14d
  cltd
  idiv   %r13d
  lea    0x1(%rax),%ebp
  movslq 0xc(%rsp),%rax
  lea    (%rcx,%rax,8),%r12
  jmp    L97
  nopl   0x0(%rax)
L36:
  lea    0x1(%r15),%eax
  cltd
  idiv   %ebx
  mov    %edx,%r15d
L97:
  mov    (%r12),%rdi
  mov    %r15d,%esi
  call   <numa_bitmask_isbitset@plt>
  cmp    $0x1,%rax
  sbb    $0xffffffff,%r14d
  cmp    %ebp,%r14d
  jne    L36
  mov    0x20(%rsp),%rdx
  mov    0x18(%rsp),%rsi
  mov    %r15d,%ecx
  mov    0x28(%rsp),%rdi
  call   <add_core_to_str@plt>
  mov    0xc(%rsp),%eax
  addl   $0x1,0x8(%rsp)
  add    $0x1,%eax
  cltd
  idiv   %r13d
  mov    0x8(%rsp),%eax
  mov    %edx,0xc(%rsp)
  cmp    %eax,%ebx
  jne    L140
  jmp    L113
L107:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *build_default_affinity_string(int shuffle) {
  int nr_nodes = numa_num_configured_nodes();
  int nr_cores = numa_num_configured_cpus();
  char *str;
  int str_size = 512;
  int str_written = 0;
  int i;
  struct bitmask **bm = (struct bitmask **)malloc(sizeof(struct bitmask *) * nr_nodes);
  for (i = 0; i < nr_nodes; i++) {
    bm[i] = numa_allocate_cpumask();
    numa_node_to_cpus(i, bm[i]);
  }
  str = (char *)malloc(str_size * sizeof(char));
  assert(str);
  if (!shuffle) {
    for (i = 0; i < nr_nodes; i++) {
      int j;
      for (j = 0; j < nr_cores; j++) {
        if (numa_bitmask_isbitset(bm[i], j)) {
          add_core_to_str(&str, &str_size, &str_written, j);
        }
      }
    }
  } else {
    int next_node = 0;
    for (i = 0; i < nr_cores; i++) {
      int idx = (i / nr_nodes) + 1;
      int found = 0;
      int j = 0;
      do {
        if (numa_bitmask_isbitset(bm[next_node], j)) {
          found++;
        }
        if (found == idx) {
          add_core_to_str(&str, &str_size, &str_written, j);
          break;
        }
        j = (j + 1) % nr_cores;
      } while (found != idx);
      next_node = (next_node + 1) % nr_nodes;
    }
  }
  if (str_written) {
    str[str_written - 1] = 0;
  }
  return str;
}
```