// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/firstcodes-spacelog.c
// Function: gt_firstcodes_spacelog_add
void gt_firstcodes_spacelog_add(GtFirstcodesspacelog *fcsl,
                                int line,
                                const char *filename,
                                bool add,
                                const char *title,
                                bool work,
                                size_t size)
{
  GtFirstcodespacelogentry *entry;
  size_t logspace;

  if (add)
  {
    entry = gt_spacelog_find(fcsl,title);
    if (entry != NULL)
    {
      if (entry->size != 0)
      {
        fprintf(stderr,"existing entry for title \"%s\""
                       "(from file %s, line %d) "
                       "in spacelog entries must have size 0\n",
                       title,filename,line);
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      gt_spacelog_updateaddentry(entry,filename,line,title,size,work);
    } else
    {
      gt_spacelog_addentry(fcsl,filename,line,title,size,work);
    }
    if (work)
    {
      fcsl->workspace += size;
    } else
    {
      fcsl->splitspace += size;
    }
    gt_firstcodes_updatemax(fcsl);
  } else
  {
    entry = gt_spacelog_find(fcsl,title);
    if (entry == NULL)
    {
      fprintf(stderr,"cannot find title \"%s\" (from file %s, line %d) "
                     "in spacelog entries\n",title,filename,line);
      (void) gt_firstcodes_spacelog_showentries(stderr,fcsl);
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
    if ((entry->work && !work) || (!entry->work && work))
    {
      fprintf(stderr,"for title \"%s\" (from file %s, line %d) "
                     "in spacelog entries: inconsistent work/splitassignment\n",
               title,filename,line);
      exit(GT_EXIT_PROGRAMMING_ERROR);
    }
    if (work)
    {
      if (entry->size > fcsl->workspace)
      {
        gt_firstcodes_subtract_error(title, filename, line, entry->size, true,
                                     fcsl->workspace);
        (void) gt_firstcodes_spacelog_showentries(stderr,fcsl);
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      fcsl->workspace -= entry->size;
    } else
    {
      if (entry->size > fcsl->splitspace)
      {
        gt_firstcodes_subtract_error(title, filename, line, entry->size, false,
                                     fcsl->splitspace);
        (void) gt_firstcodes_spacelog_showentries(stderr,fcsl);
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      fcsl->splitspace -= entry->size;
    }
    if (size > 0)
    {
      size_t previous_size = entry->size;
      gt_spacelog_updateaddentry(entry,filename,line,title,size,work);
      if (work)
      {
        fcsl->workspace += size;
      } else
      {
        fcsl->splitspace += size;
      }
      if (size > previous_size)
      {
        add = true;
        size -= previous_size;
      } else
      {
        size = previous_size - size;
      }
      gt_firstcodes_updatemax(fcsl);
    } else
    {
      size = entry->size;
      entry->size = 0;
    }
  }
  logspace = fcsl->workspace+fcsl->splitspace;
  gt_log_log(
#ifdef SKDEBUG
             "file %s, line %d: "
#endif
             "%s %s= %.2f, %s, w=%.2f, s=%.2f, sum=%.2f MB",
#ifdef SKDEBUG
             filename,
             line,
#endif
             work ? "w" : "s",
             add ? "+" : "-",
             GT_MEGABYTES(size),
             title,
             GT_MEGABYTES(fcsl->workspace),
             GT_MEGABYTES(fcsl->splitspace),
             GT_MEGABYTES(logspace));
#ifdef SKDEBUG
  if (gt_ma_bookkeeping_enabled())
  {
    GtUword realspace = gt_ma_get_space_current() +
                              gt_fa_get_space_current();
    gt_log_log("current space usage %.2f MB (%.2f+%.2f)",
                                GT_MEGABYTES(realspace),
                                GT_MEGABYTES(gt_ma_get_space_current()),
                                GT_MEGABYTES(gt_fa_get_space_current()));
    if (fcsl->calc_difference)
    {
      double percent_difference;

      if ((GtUword) logspace > realspace)
      {
        fprintf(stderr,"overestimating logspace\n");
        exit(GT_EXIT_PROGRAMMING_ERROR);
      }
      if (realspace >= 1000000UL)
      {
        /*
        printf("realspace="GT_WU",logspace="GT_WU"\n",realspace,
                                              (GtUword) logspace);
        */
        percent_difference = 100.0 * (double) (realspace - logspace)/realspace;
        if (gt_double_larger_double(percent_difference,3.0))
        {
          fprintf(stderr,"space difference of %.2f%% is too large\n",
                       percent_difference);
          exit(GT_EXIT_PROGRAMMING_ERROR);
        }
        if (gt_double_smaller_double(fcsl->max_percent_difference,
                                     percent_difference))
        {
          fcsl->max_percent_difference = percent_difference;
        }
      }
    }
  }
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %ebp
movq %r8, %rbx
movl %ecx, %r15d
movq %rdx, (%rsp)
movl %esi, %r13d
movq %rdi, %r14
movq 0x40(%rsp), %r12
movq %r8, %rsi
callq 0x2b646a
testl %r15d, %r15d
je 0x2b619a
testq %rax, %rax
je 0x2b6237
cmpq $0x0, 0x18(%rax)
jne 0x2b63ce
movq (%rsp), %rcx
movq %rcx, (%rax)
movl %r13d, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %r12, 0x18(%rax)
movb %bpl, 0x20(%rax)
jmp 0x2b62ac
testq %rax, %rax
je 0x2b6394
cmpb %bpl, 0x20(%rax)
jne 0x2b63bb
movq 0x18(%rax), %r15
testb %bpl, %bpl
je 0x2b61c7
movq (%r14), %r9
cmpq %r9, %r15
ja 0x2b63f2
movq %r14, %rcx
jmp 0x2b61d8
movq 0x8(%r14), %r9
cmpq %r9, %r15
ja 0x2b6405
leaq 0x8(%r14), %rcx
subq %r15, %r9
movq %r9, (%rcx)
testq %r12, %r12
je 0x2b6270
movq %r15, %rcx
subq %r12, %rcx
leaq 0xaa200(%rip), %rdx     # 0x3603f4
movl %r13d, %esi
leaq 0xb1fac(%rip), %r13     # 0x3681aa
cmovbq %rdx, %r13
negq %rcx
subq %r12, %r15
movq (%rsp), %rdx
movq %rdx, (%rax)
movl %esi, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %r12, 0x18(%rax)
movb %bpl, 0x20(%rax)
cmovbq %rcx, %r15
movl %ebp, %eax
xorb $0x1, %al
movzbl %al, %eax
addq %r12, (%r14,%rax,8)
movq %r14, %rdi
callq 0x2b64be
jmp 0x2b627c
movq 0x30(%r14), %rcx
cmpq 0x38(%r14), %rcx
ja 0x2b6434
jne 0x2b6281
addq $0x10, %rcx
movq %rcx, 0x38(%r14)
movq 0x28(%r14), %rdi
imulq $0x28, %rcx, %rsi
leaq 0xcc5d4(%rip), %rdx     # 0x382832
pushq $0x7c
popq %rcx
callq 0x93472
movq %rax, 0x28(%r14)
movq 0x30(%r14), %rcx
jmp 0x2b6285
andq $0x0, 0x18(%rax)
leaq 0xb1f2e(%rip), %r13     # 0x3681aa
movq %r15, %r12
jmp 0x2b62c6
movq 0x28(%r14), %rax
imulq $0x28, %rcx, %rdx
movq (%rsp), %rsi
movq %rsi, (%rax,%rdx)
movl %r13d, 0x8(%rax,%rdx)
movq %rbx, 0x10(%rax,%rdx)
movq %r12, 0x18(%rax,%rdx)
movb %bpl, 0x20(%rax,%rdx)
incq %rcx
movq %rcx, 0x30(%r14)
movl %ebp, %eax
xorb $0x1, %al
movzbl %al, %eax
addq %r12, (%r14,%rax,8)
movq %r14, %rdi
callq 0x2b64be
leaq 0xaa12e(%rip), %r13     # 0x3603f4
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq (%rcx,%rdx), %rax
leaq 0x7d636(%rip), %rdi     # 0x33390e
leaq 0x4538a(%rip), %rsi     # 0x2fb669
testb %bpl, %bpl
cmovneq %rdi, %rsi
movq %r12, %xmm1
movq 0x315ed(%rip), %xmm3    # 0x2e78e0
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x315f1(%rip), %xmm4    # 0x2e78f0
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x315e9(%rip), %xmm5    # 0x2e7900
mulsd %xmm5, %xmm0
movq %rdx, %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm4, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
mulsd %xmm5, %xmm1
movq %rcx, %xmm6
punpckldq %xmm3, %xmm6    # xmm6 = xmm6[0],xmm3[0],xmm6[1],xmm3[1]
subpd %xmm4, %xmm6
movapd %xmm6, %xmm2
unpckhpd %xmm6, %xmm2            # xmm2 = xmm2[1],xmm6[1]
addsd %xmm6, %xmm2
mulsd %xmm5, %xmm2
movq %rax, %xmm6
punpckldq %xmm3, %xmm6    # xmm6 = xmm6[0],xmm3[0],xmm6[1],xmm3[1]
subpd %xmm4, %xmm6
movapd %xmm6, %xmm3
unpckhpd %xmm6, %xmm3            # xmm3 = xmm3[1],xmm6[1]
addsd %xmm6, %xmm3
mulsd %xmm5, %xmm3
leaq 0xcc62a(%rip), %rdi     # 0x3829a3
movq %r13, %rdx
movq %rbx, %rcx
movb $0x4, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x92a82
movq 0x181bcd(%rip), %r15    # 0x437f68
movq (%r15), %rdi
leaq 0xcc55b(%rip), %rsi     # 0x382900
movq %rbx, %rdx
movq (%rsp), %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x17a50
movq (%r15), %rdi
jmp 0x2b6424
movq 0x181ba6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0xcc578(%rip), %rsi     # 0x382944
jmp 0x2b63df
movq 0x181b93(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0xcc4c6(%rip), %rsi     # 0x3828a5
movq %rbx, %rdx
movq (%rsp), %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x17a50
jmp 0x2b642c
pushq $0x1
popq %r8
movq %rbx, %rdi
movq (%rsp), %rsi
movl %r13d, %edx
movq %r15, %rcx
jmp 0x2b6415
movq %rbx, %rdi
movq (%rsp), %rsi
movl %r13d, %edx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2b6507
movq 0x181b47(%rip), %rax    # 0x437f68
movq (%rax), %rdi
movq %r14, %rsi
callq 0x2b6060
pushq $0x2
popq %rdi
callq 0x178f0
movq 0x181b2d(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2ebce(%rip), %rsi     # 0x2e5013
leaq 0xcc584(%rip), %rdx     # 0x3829d0
leaq 0xcc59f(%rip), %rcx     # 0x3829f2
leaq 0xcc3d8(%rip), %r8      # 0x382832
pushq $0x77
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390