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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rsi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  cmp    $0x1,%edi
  jle    L26
L51:
  mov    0x8(%rbx),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    0x5(%rax),%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %rbp,%rdx
  lea    D41(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    %rbx,%rsi
  lea    D75(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    0x38(%rsp),%rcx
  lea    0x30(%rsp),%rdx
  lea    0x2c(%rsp),%rsi
  lea    0x28(%rsp),%rdi
  mov    %rbp,%r9
  lea    0x40(%rsp),%r8
  call   <epistasis_dataset_load@plt>
  mov    %rax,%rcx
  mov    %rax,0x18(%rsp)
  mov    0x40(%rsp),%rax
  lea    (%rcx,%rax,4),%rax
  mov    %rax,0x8(%rsp)
  mov    0x2c(%rsp),%eax
  add    0x28(%rsp),%eax
  mov    %eax,0x14(%rsp)
  lea    D61(%rip),%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  mov    0x40(%rsp),%rsi
  lea    D28(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpq   $0x0,0x30(%rsp)
  je     L38
  mov    $0x0,%ebx
  lea    D80(%rip),%rbp
L153:
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  cmp    %rbx,0x30(%rsp)
  ja     L153
L38:
  mov    %r12,%rcx
  mov    $0x6,%edx
  mov    $0x1,%esi
  lea    D90(%rip),%rdi
  call   <fwrite@plt>
  mov    0x28(%rsp),%r15d
  test   %r15d,%r15d
  jle    L148
  movslq 0x14(%rsp),%rax
  shl    $0x2,%rax
  mov    %rax,(%rsp)
  mov    $0x0,%r14d
  lea    D85(%rip),%r13
  mov    $0x3,%ebp
  jmp    L79
L26:
  lea    D40(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L51
L30:
  mov    (%r15),%edx
  cmp    $0xff,%edx
  cmove  %ebp,%edx
  mov    %r13,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  add    (%rsp),%r15
  cmp    %rbx,0x30(%rsp)
  ja     L30
L62:
  mov    %r12,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  lea    D17(%rip),%rdi
  call   <fwrite@plt>
  mov    0x28(%rsp),%r15d
  add    $0x1,%r14
  cmp    %r14d,%r15d
  jle    L148
L79:
  mov    0x8(%rsp),%rax
  lea    (%rax,%r14,4),%r15
  mov    $0x0,%ebx
  cmpq   $0x0,0x30(%rsp)
  jne    L30
  jmp    L62
L148:
  mov    0x14(%rsp),%ecx
  cmp    %r15d,%ecx
  jle    L71
  movslq %r15d,%rax
  mov    0x8(%rsp),%rsi
  lea    (%rsi,%rax,4),%rax
  mov    %rax,0x8(%rsp)
  movslq %ecx,%rax
  shl    $0x2,%rax
  mov    %rax,(%rsp)
  lea    D85(%rip),%r14
  mov    $0x3,%r13d
  jmp    L56
L152:
  mov    0x0(%rbp),%edx
  cmp    $0xff,%edx
  cmove  %r13d,%edx
  mov    %r14,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  add    (%rsp),%rbp
  cmp    %rbx,0x30(%rsp)
  ja     L152
L117:
  mov    %r12,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  lea    D74(%rip),%rdi
  call   <fwrite@plt>
  add    $0x1,%r15d
  addq   $0x4,0x8(%rsp)
  cmp    %r15d,0x14(%rsp)
  je     L71
L56:
  mov    0x8(%rsp),%rbp
  mov    $0x0,%ebx
  cmpq   $0x0,0x30(%rsp)
  jne    L152
  jmp    L117
L71:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x38(%rsp),%rsi
  mov    0x18(%rsp),%rdi
  call   <epistasis_dataset_close@plt>
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L63
  mov    $0x0,%eax
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L63:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D41
type_guessed: string
name: read_data
arguments: label: D75
type_guessed: string
name: read_data
arguments: label: D61
type_guessed: string
name: read_data
arguments: label: D28
type_guessed: string
name: read_data
arguments: label: D80
type_guessed: string
name: read_data
arguments: label: D90
type_guessed: string
name: read_data
arguments: label: D85
type_guessed: string
name: read_data
arguments: label: D40
type_guessed: string
name: read_data
arguments: label: D17
type_guessed: string
name: read_data
arguments: label: D74
type_guessed: string

tool: D41: %s.txt

tool: D75: output file is %s


tool: D61: w

tool: D28: genotypes offset is %zu


tool: D80: S%d	

tool: D90: Class


tool: D85: %d	

tool: D40: Usage: hpgvariant2mdrjava <filename>

tool: D17: 0


tool: D74: 1


assistant: ```c
int main(int argc, char *argv[]) {
  int num_affected, num_unaffected, num_samples;
  size_t num_variants, file_len, genotypes_offset;
  char *filename, *output_filename;
  if (argc < 2) {
    printf("Usage: hpgvariant2mdrjava <filename>\n");
    exit(1);
  }
  filename = argv[1];
  output_filename = malloc((strlen(filename) + 5) * sizeof(char));
  sprintf(output_filename, "%s.txt", filename);
  printf("output file is %s\n", output_filename);
  uint8_t *input_file = epistasis_dataset_load(&num_affected, &num_unaffected, &num_variants, &file_len, &genotypes_offset, filename);
  uint8_t *genotypes = input_file + genotypes_offset;
  num_samples = num_affected + num_unaffected;
  FILE *outfile = fopen(output_filename, "w");
  printf("genotypes offset is %zu\n", genotypes_offset);
  int i, j;
  for (i = 0; i < num_variants; i++) {
    fprintf(outfile, "S%d\t", i);
  }
  fprintf(outfile, "Class\n");
  for (j = 0; j < num_affected; j++) {
    for (i = 0; i < num_variants; i++) {
      uint8_t gt = genotypes[i * num_samples + j];
      if (gt == 255)
        gt = 3;
      fprintf(outfile, "%d\t", gt);
    }
    fprintf(outfile, "0\n");
  }
  for (j = num_affected; j < num_samples; j++) {
    for (i = 0; i < num_variants; i++) {
      uint8_t gt = genotypes[i * num_samples + j];
      if (gt == 255)
        gt = 3;
      fprintf(outfile, "%d\t", gt);
    }
    fprintf(outfile, "1\n");
  }
  fclose(outfile);
  epistasis_dataset_close(input_file, file_len);
  return 0;
}
```