// File: /workspace/github_c_makefile_star2_O3/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, 0x30(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
leaq (,%rsi,8), %rdi
callq 0x9fe6
movq %rax, 0x20(%rsp)
xorl %eax, %eax
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
movq %r14, %rdx
callq 0x2250
movq (%r15), %rdi
callq 0xa09d
movl $0x0, %r15d
movq %rbx, 0x28(%rsp)
testq %rbx, %rbx
jle 0x50aa
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %r15d, %r15d
movslq %r13d, %rax
cmpq %rax, %rbx
jne 0x50b9
movl $0x800, %edi            # imm = 0x800
callq 0x9fe6
movq %rax, %r12
movq 0x20(%rsp), %rax
movq %r12, (%rax,%rbx,8)
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq %rax, 0x10(%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x2250
cmpq $-0x1, %rax
je 0x4fca
movl %r13d, 0x1c(%rsp)
movq 0x8(%rsp), %rsi
cmpb $0x3e, (%rsi)
jne 0x4fd1
xorl %ebp, %ebp
jmp 0x506d
xorl %ebp, %ebp
jmp 0x507c
movl $0x800, %r13d           # imm = 0x800
xorl %ebp, %ebp
movq 0x10(%rsp), %rax
leaq (%rax,%rbp), %rcx
cmpq %r13, %rcx
jbe 0x500d
addq %rax, %r13
addq $0x800, %r13            # imm = 0x800
movq %r12, %rdi
movq %r13, %rsi
callq 0xa166
movq %rax, %r12
movq 0x20(%rsp), %rax
movq %r12, (%rax,%rbx,8)
movq 0x8(%rsp), %rsi
leaq (%r12,%rbp), %rdi
callq 0x2070
movq 0x8(%rsp), %rdi
callq 0x20d0
addq %rax, %rbp
decq %rbp
movq %r14, %rdi
callq 0x21a0
movq %rax, %r15
movq 0x8(%rsp), %rdi
callq 0xa09d
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 0x5077
movq 0x8(%rsp), %rsi
cmpb $0x3e, (%rsi)
jne 0x4fd9
movl 0x1c(%rsp), %r13d
incl %r13d
jmp 0x507c
movl 0x1c(%rsp), %r13d
movq 0x8(%rsp), %rdi
callq 0xa09d
movb $0x0, (%r12,%rbp)
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
addq %rbp, %rax
incq %rax
movq %rax, (%rcx)
incq %rbx
cmpq 0x28(%rsp), %rbx
jne 0x4f6e
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x21e0
jmp 0x50c2
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq