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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x860,%rsp
  mov    %edi,-0x854(%rbp)
  mov    %rsi,-0x860(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x3,-0x854(%rbp)
  jg     L44
  lea    D36(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D70(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L39
L44:
  mov    -0x860(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    %rax,-0x840(%rbp)
  mov    -0x860(%rbp),%rax
  mov    0x10(%rax),%rax
  mov    %rax,-0x838(%rbp)
  mov    -0x860(%rbp),%rax
  mov    0x18(%rax),%rax
  mov    %rax,-0x830(%rbp)
  cmpl   $0x5,-0x854(%rbp)
  je     L31
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  call   <getpass@plt>
  mov    %rax,-0x828(%rbp)
  mov    -0x828(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    D33(%rip),%rax
  mov    %rax,%rdi
  call   <getpass@plt>
  mov    %rax,-0x828(%rbp)
  mov    -0x828(%rbp),%rdx
  lea    -0x410(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x828(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x828(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  lea    -0x410(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  mov    %eax,-0x844(%rbp)
  cmpl   $0x0,-0x844(%rbp)
  je     L26
  lea    D54(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x2,%eax
  jmp    L39
L31:
  mov    -0x860(%rbp),%rax
  add    $0x20,%rax
  mov    (%rax),%rdx
  lea    -0x810(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
L26:
  lea    -0x810(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <crypt@plt>
  mov    %rax,-0x820(%rbp)
  mov    -0x840(%rbp),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x818(%rbp)
  mov    -0x820(%rbp),%rsi
  mov    -0x838(%rbp),%rcx
  mov    -0x830(%rbp),%rdx
  mov    -0x818(%rbp),%rax
  mov    %rsi,%r8
  lea    D63(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  mov    -0x818(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L39:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L6
  call   <__stack_chk_fail@plt>
L6:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D36
datatype: string
name: extract_symbolic_data
arguments: data_tag: D70
datatype: string
name: extract_symbolic_data
arguments: data_tag: D21
datatype: string
name: extract_symbolic_data
arguments: data_tag: D10
datatype: string
name: extract_symbolic_data
arguments: data_tag: D19
datatype: string
name: extract_symbolic_data
arguments: data_tag: D33
datatype: string
name: extract_symbolic_data
arguments: data_tag: D54
datatype: string
name: extract_symbolic_data
arguments: data_tag: D2
datatype: string
name: extract_symbolic_data
arguments: data_tag: D63
datatype: string

tool: D36: Usage:



tool: D70: htdigest passwordfile realm username


tool: D21: htdigest passwordfile realm username password



tool: D10: Creates or updates an Apache/nginx compatible htdigest file


tool: D19: Password: 

tool: D33: Password (again): 

tool: D54: Passwords did not match


tool: D2: a

tool: D63: %s:%s:%s


assistant: ```c
int main(int argc, char **argv) {
  char password_first[1024], password_repeat[1024];
  char *input, *passwordfile, *username, *realm, *encrypted;
  FILE *htpasswd_file;
  if (argc < 4) {
    printf("Usage:\n\n");
    printf("htdigest passwordfile realm username\n");
    printf("htdigest passwordfile realm username password\n\n");
    printf("Creates or updates an Apache/nginx compatible htdigest file\n");
    return 1;
  }
  passwordfile = argv[1];
  realm = argv[2];
  username = argv[3];
  if (argc != 5) {
    input = getpass("Password: ");
    strcpy(password_first, input);
    input = getpass("Password (again): ");
    strcpy(password_repeat, input);
    memset(input, 0, strlen(input));
    int password_compare = strcmp(password_first, password_repeat);
    if (password_compare != 0) {
      printf("Passwords did not match\n");
      return 2;
    }
  } else {
    strcpy(password_first, argv[4]);
  }
  encrypted = (char *)crypt(password_first, password_first);
  htpasswd_file = fopen(passwordfile, "a");
  fprintf(htpasswd_file, "%s:%s:%s\n", username, realm, encrypted);
  fclose(htpasswd_file);
  return 0;
}
```