// File: /workspace/github_c_makefile_star2_O0/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sReadLine
bool sReadLine(FILE *stream, Allocator *a, StringView *result_out)
{
  const int old_errno = errno;

  size_t capacity = 4; /* Small value to test growth. */
  char *buffer = allocate(getTemporaryBuffer(false), capacity);
  size_t length_used = 0;

  while(true)
  {
    errno = 0;
    const int character = fgetc(stream);
    if(character == EOF)
    {
      if(errno != 0) dieErrno("failed to read line");

      if(length_used == 0)
      {
        strSet(result_out, str(""));
        errno = old_errno;
        return false;
      }
    }
    if(character == EOF || character == '\n' || character == '\r' ||
       character == '\0')
    {
      strSet(result_out, strCopy(strUnterminated(buffer, length_used), a));
      errno = old_errno;
      return true;
    }

    buffer[length_used] = (char)character;
    length_used++;

    if(length_used == capacity)
    {
      capacity = sSizeMul(capacity, 2);
      buffer = allocate(getTemporaryBuffer(false), capacity);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
callq 0x2050
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq $0x4, -0x30(%rbp)
xorl %edi, %edi
callq 0xd020
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x24c0
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
callq 0x2050
movl $0x0, (%rax)
movq -0x10(%rbp), %rdi
callq 0x2190
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0xd17d
callq 0x2050
cmpl $0x0, (%rax)
je 0xd111
leaq 0x17c9a(%rip), %rdi     # 0x24da4
movb $0x0, %al
callq 0x4760
cmpq $0x0, -0x40(%rbp)
jne 0xd17b
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x1767c(%rip), %rsi     # 0x247aa
callq 0xf100
movq -0xa0(%rbp), %rdi
leaq -0x60(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf240
movl -0x24(%rbp), %eax
movl %eax, -0x94(%rbp)
callq 0x2050
movl -0x94(%rbp), %ecx
movl %ecx, (%rax)
movb $0x0, -0x1(%rbp)
jmp 0xd27e
jmp 0xd17d
cmpl $-0x1, -0x44(%rbp)
je 0xd199
cmpl $0xa, -0x44(%rbp)
je 0xd199
cmpl $0xd, -0x44(%rbp)
je 0xd199
cmpl $0x0, -0x44(%rbp)
jne 0xd22a
movq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0xf140
movq -0x18(%rbp), %rsi
leaq -0x78(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf270
movq -0xb0(%rbp), %rdi
leaq -0x78(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf240
movl -0x24(%rbp), %eax
movl %eax, -0xa4(%rbp)
callq 0x2050
movl -0xa4(%rbp), %ecx
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0xd27e
movl -0x44(%rbp), %eax
movb %al, %dl
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0xd279
movq -0x30(%rbp), %rdi
movl $0x2, %esi
callq 0xb930
movq %rax, -0x30(%rbp)
xorl %edi, %edi
callq 0xd020
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x24c0
movq %rax, -0x38(%rbp)
jmp 0xd0d8
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)