// File: /workspace/github_c_makefile_star2_O0/michaelnmmeyer[P]gourgandine/cmd/gourgandine.c
// Function: read_file
static void *read_file(const char *path, size_t *size)
{
   FILE *fp = stdin;
   if (path) {
      fp = fopen(path, "r");
      if (!fp) {
         complain("cannot open '%s':", path);
         return NULL;
      }
   } else {
      path = "<stdin>";
   }

   uint8_t *buf = GN_VEC_INIT;
   size_t len = 0;

   gn_vec_grow(buf, BUFSIZ);
   while ((len = fread(&buf[gn_vec_len(buf)], 1, BUFSIZ, fp))) {
      gn_vec_len(buf) += len;
      if (gn_vec_len(buf) > MAX_FILE_SIZE) {
         complain("input file '%s' too large (limit is %d)", path, MAX_FILE_SIZE);
         goto fail;
      }
      gn_vec_grow(buf, BUFSIZ);
   }
   if (ferror(fp)) {
      complain("cannot read '%s':", path);
      goto fail;
   }

   uint8_t *nrm;
   ssize_t ret = utf8proc_map(buf, gn_vec_len(buf), &nrm, UTF8PROC_STABLE | UTF8PROC_COMPOSE);
   if (ret < 0) {
      complain("cannot process file '%s': %s", path, utf8proc_errmsg(ret));
      goto fail;
   }

   gn_vec_free(buf);
   *size = ret;
   return nrm;

fail:
   gn_vec_free(buf);
   fclose(fp);
   return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq 0x116499(%rip), %rax    # 0x11afd0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4b81
movq -0x10(%rbp), %rdi
leaq 0x9d321(%rip), %rsi     # 0xa1e71
callq 0x2220
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4b7f
movq -0x10(%rbp), %rsi
leaq 0xe8f0(%rip), %rdi      # 0x1345b
movb $0x0, %al
callq 0x3e80
movq $0x0, -0x8(%rbp)
jmp 0x4cf4
jmp 0x4b8c
leaq 0xe8e5(%rip), %rax      # 0x1346d
movq %rax, -0x10(%rbp)
leaq 0x11661d(%rip), %rax    # 0x11b1b0
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rdi
addq $-0x10, %rdi
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %edx
callq 0x2b30
movq %rax, -0x28(%rbp)
jmp 0x4bc0
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
addq -0x10(%rax), %rdi
movq -0x20(%rbp), %rcx
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x20a0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x4c45
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
addq -0x10(%rax), %rcx
movq %rcx, -0x10(%rax)
movq -0x28(%rbp), %rax
cmpq $0x3200000, -0x10(%rax) # imm = 0x3200000
jbe 0x4c23
movq -0x10(%rbp), %rsi
leaq 0xe863(%rip), %rdi      # 0x13475
movl $0x3200000, %edx        # imm = 0x3200000
movb $0x0, %al
callq 0x3e80
jmp 0x4cd6
jmp 0x4c25
movq -0x28(%rbp), %rdi
addq $-0x10, %rdi
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %edx
callq 0x2b30
movq %rax, -0x28(%rbp)
jmp 0x4bc0
movq -0x20(%rbp), %rdi
callq 0x2090
cmpl $0x0, %eax
je 0x4c67
movq -0x10(%rbp), %rsi
leaq 0xe83f(%rip), %rdi      # 0x1349d
movb $0x0, %al
callq 0x3e80
jmp 0x4cd6
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x10(%rax), %rsi
leaq -0x38(%rbp), %rdx
movl $0xa, %ecx
callq 0x12000
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jge 0x4cb4
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x10710
movq -0x48(%rbp), %rsi
movq %rax, %rdx
leaq 0xe804(%rip), %rdi      # 0x134af
movb $0x0, %al
callq 0x3e80
jmp 0x4cd6
movq -0x28(%rbp), %rdi
addq $-0x10, %rdi
callq 0x4d00
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4cf4
movq -0x28(%rbp), %rdi
addq $-0x10, %rdi
callq 0x4d00
movq -0x20(%rbp), %rdi
callq 0x20d0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop