// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/reads2twobit.c
// Function: gt_reads2twobit_add_library
int gt_reads2twobit_add_library(GtReads2Twobit *r2t, const GtStr *libspec,
    GtError *err)
{
  GtSplitter *s1, *s2;
  char *libspec_copy;
  int had_err = 0;

  gt_assert(r2t != NULL);
  gt_assert(libspec != NULL);
  gt_assert(gt_str_length(libspec) > 0);
  libspec_copy = gt_malloc(sizeof (*libspec_copy) *
      (gt_str_length(libspec) + 1UL));
  (void)strcpy(libspec_copy, gt_str_get(libspec));
  s1 = gt_splitter_new();
  gt_splitter_split(s1, libspec_copy, gt_str_length(libspec),
      GT_READS2TWOBIT_LIBSPECSEP);
  gt_log_log("reads2twobit add library: %s", gt_str_get(libspec));
  if (gt_splitter_size(s1) == 1UL)
  {
    gt_reads2twobit_add(r2t, false, libspec, NULL, 0, 0);
  }
  else if (gt_splitter_size(s1) < 4UL)
  {
    GtStr *filename1, *filename2;
    GtUword insertlength = 0, stdev = 0;
    char *insertspec, *insertspec_copy;
    r2t->has_paired = true;
    filename1 = gt_str_new_cstr(gt_splitter_get_token(s1, 0));
    if (gt_splitter_size(s1) == 3UL)
    {
      filename2 = gt_str_new_cstr(gt_splitter_get_token(s1, 1UL));
      insertspec = gt_splitter_get_token(s1, 2UL);
    }
    else
    {
      filename2 = NULL;
      insertspec = gt_splitter_get_token(s1, 1UL);
    }
    s2 = gt_splitter_new();
    insertspec_copy = gt_malloc(sizeof (*insertspec_copy) *
        (strlen(insertspec) + 1UL));
    (void)strcpy(insertspec_copy, insertspec);
    gt_splitter_split(s2, insertspec_copy, (GtUword)strlen(insertspec),
      GT_READS2TWOBIT_INSERTSEP);
    if (gt_splitter_size(s2) <= 2UL)
    {
      had_err = gt_parse_uword(&insertlength, gt_splitter_get_token(s2, 0));
      if (gt_splitter_size(s2) == 2UL && !had_err)
      {
        had_err = gt_parse_uword(&stdev, gt_splitter_get_token(s2, 1UL));
      }
    }
    if (gt_splitter_size(s2) > 2UL || had_err)
    {
      gt_error_set(err, "insert specification not valid: %s\nthe correct "
          "syntax is \"insertlength[%cstdev]\"", insertspec,
          GT_READS2TWOBIT_INSERTSEP);
    }
    if (!had_err)
    {
      gt_reads2twobit_add(r2t, true, filename1, filename2, insertlength, stdev);
    }
    gt_str_delete(filename1);
    gt_str_delete(filename2);
    gt_free(insertspec_copy);
    gt_splitter_delete(s2);
  }
  else
  {
    gt_error_set(err, "library specification not valid: %s\nthe correct "
        "syntax is \"filename[[%cfilename2]%cinsertlength[%cstdev]]\"\n"
        "(filenames are not allowed to contain \"%c\"",
        gt_str_get(libspec),
      GT_READS2TWOBIT_LIBSPECSEP, GT_READS2TWOBIT_LIBSPECSEP,
      GT_READS2TWOBIT_INSERTSEP, GT_READS2TWOBIT_LIBSPECSEP);
    had_err = -1;
  }
  gt_free(libspec_copy);
  gt_splitter_delete(s1);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rdi, %rdi
je 0x1e4d8a
movq %rsi, %r12
testq %rsi, %rsi
je 0x1e4d8f
movq %rdx, %rbp
movq %rdi, %r15
movq %r12, %rdi
callq 0x120d4c
testq %rax, %rax
je 0x1e4d94
movq %r12, %rdi
callq 0x120d4c
leaq 0x1(%rax), %rdi
leaq 0x1d6d32(%rip), %rsi    # 0x3bb7f4
movl $0xb6, %edx
callq 0x1092b2
movq %rax, %rbx
movq %r12, %rdi
callq 0x120d23
movq %rbx, %rdi
movq %rax, %rsi
callq 0x17770
callq 0x11f0ac
movq %rax, %r14
movq %r12, %rdi
callq 0x120d4c
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x3a, %ecx
callq 0x11f0c7
movq %r12, %rdi
callq 0x120d23
leaq 0x1d6d93(%rip), %rdi    # 0x3bb8a7
xorl %r13d, %r13d
movq %rax, %rsi
xorl %eax, %eax
callq 0x108e02
movq %r14, %rdi
callq 0x11f2e4
cmpq $0x1, %rax
jne 0x1e4b49
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1e49aa
jmp 0x1e4d5c
movq %r14, %rdi
callq 0x11f2e4
cmpq $0x3, %rax
ja 0x1e4bcd
movq %rbp, 0x28(%rsp)
xorl %r13d, %r13d
movq %r13, 0x18(%rsp)
movq %r13, 0x10(%rsp)
movb $0x1, 0x90(%r15)
movq %r14, %rdi
xorl %esi, %esi
callq 0x11f2a8
movq %rax, %rdi
callq 0x120955
movq %rax, 0x40(%rsp)
movq %r14, %rdi
callq 0x11f2e4
movq %rax, %rbp
movl $0x1, %esi
movq %r14, %rdi
callq 0x11f2a8
movq %rax, %r12
cmpq $0x3, %rbp
movq %r15, 0x30(%rsp)
jne 0x1e4c0c
movq %r12, %rdi
callq 0x120955
movq %rax, 0x8(%rsp)
movl $0x2, %esi
movq %r14, %rdi
callq 0x11f2a8
movq %rax, %r12
jmp 0x1e4c15
movq %r12, %rdi
callq 0x120d23
movl $0x3a, (%rsp)
leaq 0x1d6d32(%rip), %rsi    # 0x3bb915
movq %rbp, %rdi
movq %rax, %rdx
movl $0x3a, %ecx
movl $0x3a, %r8d
movl $0x2c, %r9d
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x1e4d5c
movq $0x0, 0x8(%rsp)
callq 0x11f0ac
movq %rax, %r15
movq %r12, %rdi
callq 0x172f0
leaq 0x1(%rax), %rdi
leaq 0x1d6bc4(%rip), %rsi    # 0x3bb7f4
movl $0xd3, %edx
callq 0x1092b2
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
callq 0x17770
movq %r12, 0x20(%rsp)
movq %r12, %rdi
callq 0x172f0
movq %r15, %rdi
movq %rbp, 0x38(%rsp)
movq %rbp, %rsi
movq %r15, %rbp
movq %rax, %rdx
movl $0x2c, %ecx
callq 0x11f0c7
movq %r15, %rdi
callq 0x11f2e4
cmpq $0x2, %rax
ja 0x1e4cce
movq %rbp, %rdi
xorl %esi, %esi
callq 0x11f2a8
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x11043f
movl %eax, %r13d
movq %rbp, %rdi
callq 0x11f2e4
cmpq $0x2, %rax
setne %al
testl %r13d, %r13d
setne %cl
orb %al, %cl
jne 0x1e4cce
movl $0x1, %esi
movq %rbp, %rdi
callq 0x11f2a8
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x11043f
movl %eax, %r13d
movq %rbp, %rdi
callq 0x11f2e4
cmpq $0x2, %rax
movq 0x30(%rsp), %r15
ja 0x1e4ce6
testl %r13d, %r13d
je 0x1e4d03
leaq 0x1d6bd7(%rip), %rsi    # 0x3bb8c4
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
movl $0x2c, %ecx
xorl %eax, %eax
callq 0x1019cf
testl %r13d, %r13d
movq 0x40(%rsp), %r12
jne 0x1e4d2c
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
movq %r15, %rdi
movl $0x1, %esi
movq %r12, %rdx
movq 0x8(%rsp), %rcx
callq 0x1e49aa
movq %r12, %rdi
callq 0x121b03
movq 0x8(%rsp), %rdi
callq 0x121b03
leaq 0x1d6aaf(%rip), %rsi    # 0x3bb7f4
movq 0x38(%rsp), %rdi
movl $0xeb, %edx
callq 0x109670
movq %rbp, %rdi
callq 0x11f2f4
leaq 0x1d6a91(%rip), %rsi    # 0x3bb7f4
movq %rbx, %rdi
movl $0xf8, %edx
callq 0x109670
movq %r14, %rdi
callq 0x11f2f4
movl %r13d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x74c88
callq 0x74c4f
callq 0x74c16