user: What is the c source code of the assembly code below?

```asm
<check_log>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  lea    D116(%rip),%rbp
  push   %rbx
  mov    %rbp,%rsi
  sub    $0xc28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xc18(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  test   %rax,%rax
  je     L88
  mov    %rbp,%rsi
  mov    %r14,%rdi
  mov    %rax,%r12
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L99
  lea    0x810(%rsp),%rbp
  mov    %rax,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L116
  lea    0x10(%rsp),%rdi
  mov    %rbp,%rsi
  call   <strcpy@plt>
L116:
  mov    %r13,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L70
  lea    0x410(%rsp),%rdi
  mov    %rbp,%rsi
  call   <strcpy@plt>
L70:
  mov    %r13,%rdi
  call   <fclose@plt>
L85:
  mov    %rsp,%rsi
  mov    %r15,%rdi
  call   <stat@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L130
  lea    0x10(%rsp),%r13
  mov    %r13,%rdi
  call   <atol@plt>
  cmp    (%rsp),%rax
  je     L81
L137:
  mov    %r13,%rdi
  call   <atol@plt>
  cmp    (%rsp),%rax
  je     L13
L45:
  mov    %rbp,%rsi
  xor    %edx,%edx
  lea    0x810(%rsp),%rbp
  mov    %r12,%rdi
  call   <fseek@plt>
  lea    D47(%rip),%rbx
  jmp    L192
  nopl   (%rax)
L198:
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L192:
  mov    %r12,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L198
  lea    D70(%rip),%rsi
  mov    %r14,%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L18
  mov    $0x180,%esi
  mov    %r14,%rdi
  call   <chmod@plt>
  test   %rax,%rax
  jne    L98
  mov    %r12,%rdi
  call   <ftell@plt>
  mov    (%rsp),%rdx
  lea    D12(%rip),%rsi
  mov    %rbp,%rdi
  mov    %rax,%rcx
  call   <fprintf@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L140:
  mov    0xc18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L105
  add    $0xc28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L99:
  lea    0x10(%rsp),%rdi
  lea    D103(%rip),%rsi
  call   <strcpy@plt>
  jmp    L85
  cs nopw 0x0(%rax,%rax,1)
L98:
  mov    %r14,%rsi
  lea    D91(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x3,%eax
  jmp    L140
  nopl   0x0(%rax,%rax,1)
L130:
  mov    %r15,%rsi
  lea    D81(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x3,%eax
  jmp    L140
  nopl   0x0(%rax,%rax,1)
L81:
  lea    0x410(%rsp),%rdi
  call   <atol@plt>
  cmp    0x8(%rsp),%rax
  jle    L137
  lea    D35(%rip),%rdi
  call   <puts@plt>
  mov    %r15,%rsi
  lea    D17(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D21(%rip),%rdi
  call   <puts@plt>
  jmp    L137
  cs nopw 0x0(%rax,%rax,1)
L13:
  lea    0x410(%rsp),%r13
  mov    %r13,%rdi
  call   <atol@plt>
  cmp    0x8(%rsp),%rax
  jg     L45
  mov    %r13,%rdi
  call   <atol@plt>
  mov    %rax,%rbp
  jmp    L45
  nopl   0x0(%rax,%rax,1)
L88:
  mov    %r15,%rsi
  lea    D9(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x2,%eax
  jmp    L140
  nopl   0x0(%rax,%rax,1)
L18:
  mov    %r14,%rsi
  lea    D42(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  xor    %edi,%edi
  call   <fclose@plt>
  mov    $0x4,%eax
  jmp    L140
L105:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D116
type_guessed: string
name: unpack_data
arguments: tag: D47
type_guessed: string
name: unpack_data
arguments: tag: D70
type_guessed: string
name: unpack_data
arguments: tag: D12
type_guessed: string
name: unpack_data
arguments: tag: D103
type_guessed: string
name: unpack_data
arguments: tag: D91
type_guessed: string
name: unpack_data
arguments: tag: D81
type_guessed: string
name: unpack_data
arguments: tag: D35
type_guessed: string
name: unpack_data
arguments: tag: D17
type_guessed: string
name: unpack_data
arguments: tag: D21
type_guessed: string
name: unpack_data
arguments: tag: D9
type_guessed: string
name: unpack_data
arguments: tag: D42
type_guessed: string

tool: D116: rb

tool: D47: %s

tool: D70: w

tool: D12: %ld
%ld

tool: D103: 0

tool: D91: Cannot set permissions on file %s


tool: D81: Cannot get %s file size.


tool: D35: ***************

tool: D17: *** WARNING ***: Log file %s is smaller than last time checked!


tool: D21: ***************	 This could indicate tampering.

tool: D9: File %s cannot be read.


tool: D42: File %s cannot be created. Check your permissions.


assistant: ```c
int check_log(char *logname, char *offset_filename) {
  FILE *input, *offset_output;
  struct stat file_stat;
  char inode_buffer[1024], offset_buffer[1024], buffer[1024];
  long offset_position;
  if ((input = fopen(logname, "rb")) == NULL) {
    printf("File %s cannot be read.\n", logname);
    return (2);
  }
  if ((offset_output = fopen(offset_filename, "rb")) != NULL) {
    if ((fgets(buffer, 1024, offset_output)) != NULL)
      strcpy(inode_buffer, buffer);
    if ((fgets(buffer, 1024, offset_output)) != NULL)
      strcpy(offset_buffer, buffer);
    fclose(offset_output);
  } else {
    strcpy(inode_buffer, "0");
    offset_position = 0L;
  }
  if ((stat(logname, &file_stat)) != 0) {
    printf("Cannot get %s file size.\n", logname);
    return (3);
  }
  if (((atol(inode_buffer)) == (file_stat.st_ino)) && (atol(offset_buffer) > (file_stat.st_size))) {
    offset_position = 0L;
    printf("***************\n");
    printf("*** WARNING ***: Log file %s is smaller than last time checked!\n", logname);
    printf("***************	 This could indicate tampering.\n");
  }
  if (((atol(inode_buffer)) != (file_stat.st_ino)) || (atol(offset_buffer) > (file_stat.st_size)))
    offset_position = 0L;
  else
    offset_position = atol(offset_buffer);
  fseek(input, offset_position, 0);
  while ((fgets(buffer, 1024, input)) != NULL)
    printf("%s", buffer);
  if ((offset_output = fopen(offset_filename, "w")) == NULL) {
    printf("File %s cannot be created. Check your permissions.\n", offset_filename);
    fclose(input);
    fclose(offset_output);
    return (4);
  } else {
    if ((chmod(offset_filename, 00600)) != 0) {
      printf("Cannot set permissions on file %s\n", offset_filename);
      return (3);
    } else {
      offset_position = ftell(input);
      fprintf(offset_output, "%ld\n%ld", (long)file_stat.st_ino, offset_position);
    }
  }
  fclose(input);
  fclose(offset_output);
  return (0);
}
```