// File: /workspace/github_c_makefile_star2_O1/felipelouza[P]egap/tools/lib/file.c
// Function: load_multiple_fasta
char** load_multiple_fasta(FILE* f_in, int_t k, size_t *n){

  char **c_buffer = (char**) malloc(k*sizeof(char*));

  char *buf = NULL;
  size_t len = 0;
  ssize_t size=0;

  size = getline(&buf, &len, f_in);// first sequence
  free(buf);

  size_t tell=0;

  int count=0;
  int_t i;
  for(i=0; i<k; i++){


    if(i!=count) return 0;

    len = 0;
    size_t nalloc = N_ALLOC;
    c_buffer[i] = malloc(nalloc*sizeof(char));

    size_t p=0;
    buf = NULL; len = 0;  
    while((size = getline(&buf, &len, f_in))!=-1){

      if(buf[0] == '>'){
        count++;
        break;
      }

      if(p+len>nalloc){
        nalloc += len+N_ALLOC;
        c_buffer[i] = realloc(c_buffer[i], sizeof(char) * nalloc);
      }

      strcpy(&c_buffer[i][p], buf);
      p+=strlen(buf)-1;
      
      tell = ftell(f_in);
      free(buf); len=0; buf=NULL;
    }
/*
    if (size == -1){//EOF
      printf("K = %" PRIdN "\n", i);
      free(buf);
      return 0;
    }
*/

    free(buf);
    c_buffer[i][p] = 0;
    (*n) += p+1;
  }

fseek(f_in , tell, SEEK_SET);
return c_buffer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
leaq (,%rsi,8), %rdi
callq 0x9fd2
movq %rax, %r15
xorl %eax, %eax
leaq 0x8(%rsp), %rbx
movq %rax, (%rbx)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2250
movq (%rbx), %rdi
movq %r12, %rbx
callq 0xa089
movl $0x0, %r12d
movq %r13, 0x30(%rsp)
testq %r13, %r13
jle 0x50d8
xorl %ebp, %ebp
movl $0x0, 0x1c(%rsp)
xorl %r12d, %r12d
movq %r15, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
movslq 0x1c(%rsp), %rax
cmpq %rax, %rbp
jne 0x50e7
xorl %r13d, %r13d
movq %r13, 0x10(%rsp)
movl $0x800, %edi            # imm = 0x800
callq 0x9fd2
movq %rax, (%r15,%rbp,8)
movq %r13, 0x8(%rsp)
movq %r13, 0x10(%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x2250
cmpq $-0x1, %rax
je 0x4fe9
movq 0x8(%rsp), %rax
cmpb $0x3e, (%rax)
jne 0x4ff1
xorl %r13d, %r13d
jmp 0x5097
xorl %r13d, %r13d
jmp 0x50ab
movq (%r15,%rbp,8), %rbx
movl $0x800, %r15d           # imm = 0x800
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %rcx
cmpq %r15, %rcx
jbe 0x5024
addq %rax, %r15
addq $0x800, %r15            # imm = 0x800
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa152
movq %rax, %rbx
leaq (%rbx,%r13), %rdi
movq 0x8(%rsp), %rsi
callq 0x2070
movq 0x8(%rsp), %rdi
callq 0x20d0
addq %rax, %r13
decq %r13
movq %r14, %rdi
callq 0x21a0
movq %rax, %r12
movq 0x8(%rsp), %rdi
callq 0xa089
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x2250
cmpq $-0x1, %rax
je 0x509d
movq 0x8(%rsp), %rax
cmpb $0x3e, (%rax)
jne 0x4ffe
movq 0x28(%rsp), %r15
movq %rbx, (%r15,%rbp,8)
movq 0x20(%rsp), %rbx
incl 0x1c(%rsp)
jmp 0x50ab
movq 0x28(%rsp), %r15
movq %rbx, (%r15,%rbp,8)
movq 0x20(%rsp), %rbx
movq 0x8(%rsp), %rdi
callq 0xa089
movq (%r15,%rbp,8), %rax
movb $0x0, (%rax,%r13)
movq (%rbx), %rax
addq %r13, %rax
incq %rax
movq %rax, (%rbx)
incq %rbp
cmpq 0x30(%rsp), %rbp
jne 0x4f91
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x21e0
jmp 0x50ea
xorl %r15d, %r15d
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq