// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/annotationsketch/diagram.c
// Function: collect_blocks
static int collect_blocks(GT_UNUSED void *key, void *value, void *data,
                          GT_UNUSED GtError *err)
{
  NodeInfoElement *ni = (NodeInfoElement*) value;
  GtDiagram *diagram = (GtDiagram*) data;
  GtBlock *block = NULL;
  GtStr *trackid_str;
  GtUword i = 0;
  trackid_str = gt_str_new();
  for (i = 0; i < gt_str_array_size(ni->types); i++) {
    const char *type;
    GtUword j;
    GtArray *list;
    PerTypeInfo *type_struc = NULL;
    GtBlock* mainblock = NULL;
    type = gt_str_array_get(ni->types, i);
    type_struc = gt_hashmap_get(ni->type_index, type);
    gt_assert(type_struc);
    for (j=0; j<gt_array_size(type_struc->blocktuples); j++)
    {
      GtBlockTuple *bt;
      bt  = *(GtBlockTuple**) gt_array_get(type_struc->blocktuples, j);
      if (bt->rep == GT_UNDEF_REPR && type_struc->must_merge)
      {
        block = mainblock = gt_block_ref(bt->block);
        gt_block_delete(mainblock);
        gt_free(bt);
        continue;
      }
      else
      {
        if (mainblock)
        {
          block = gt_block_clone(mainblock);
          gt_block_merge(block, bt->block);
          gt_block_delete(bt->block);
        } else block = bt->block;
      }
      gt_assert(block);
      gt_str_reset(trackid_str);
      /* execute hook for track selector function */
      diagram->select_func(block, trackid_str, diagram->ptr);

      if (!(list = (GtArray*) gt_hashmap_get(diagram->blocks,
                                             gt_str_get(trackid_str))))
      {
        list = gt_array_new(sizeof (GtBlock*));
        gt_hashmap_add(diagram->blocks, gt_cstr_dup(gt_str_get(trackid_str)),
                       list);
      };
      gt_assert(list);
      gt_array_add(list, block);
      gt_free(bt);
    }
    gt_array_delete(type_struc->blocktuples);
    gt_hashmap_delete(type_struc->rep_index);
    gt_block_delete(mainblock);
  }
  gt_hashmap_delete(ni->type_index);
  gt_str_array_delete(ni->types);
  gt_free(ni);
  gt_str_delete(trackid_str);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq $0x0, (%rsp)
callq 0x3b728
movq %rax, 0x8(%rsp)
movq 0x10(%rbx), %rdi
callq 0x3cbed
testq %rax, %rax
je 0x4cbc2
xorl %r12d, %r12d
movq %rbx, 0x10(%rsp)
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0x3ca6f
movq 0x8(%rbx), %rdi
movq %rax, %rsi
callq 0x775ed
testq %rax, %rax
je 0x4cc0d
movq %rax, %r14
movq %r12, 0x18(%rsp)
movq 0x8(%rax), %rdi
callq 0x6f310
xorl %ebx, %ebx
testq %rax, %rax
je 0x4cb8a
xorl %ebp, %ebp
movq %r14, 0x20(%rsp)
movq 0x8(%r14), %rdi
movq %rbp, %rsi
callq 0x6f037
movq (%rax), %r13
cmpq $-0x1, 0x8(%r13)
jne 0x4ca8e
cmpb $0x1, 0x10(%r14)
jne 0x4ca8e
movq 0x10(%r13), %rdi
callq 0x8a757
movq %rax, %rbx
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x8b7c2
movl $0x2bb, %edx            # imm = 0x2BB
jmp 0x4cb66
testq %rbx, %rbx
je 0x4caba
movq %rbx, %rdi
callq 0x8a9e3
movq %rax, (%rsp)
movq 0x10(%r13), %rsi
movq %rax, %rdi
callq 0x8a904
movq 0x10(%r13), %rdi
callq 0x8b7c2
movq (%rsp), %rax
jmp 0x4cac2
movq 0x10(%r13), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0x4cc03
movq %rbx, %r14
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x3bbee
movq (%rsp), %rdi
movq 0x50(%r15), %rdx
movq %r12, %rsi
callq *0x58(%r15)
movq (%r15), %rbx
movq %r12, %rdi
callq 0x3bb5d
movq %rbx, %rdi
movq %rax, %rsi
callq 0x775ed
testq %rax, %rax
je 0x4cb0a
movq %rax, %rbx
jmp 0x4cb49
movl $0x8, %edi
callq 0x6ef7c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
movq %r15, %r12
movq (%r15), %r15
callq 0x3bb5d
movq %rax, %rdi
callq 0x728c0
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x77628
testq %rbx, %rbx
je 0x4cc08
movq %r12, %r15
movl $0x8, %edx
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x6f240
movl $0x2d5, %edx            # imm = 0x2D5
movq %r14, %rbx
movq 0x20(%rsp), %r14
movq %r13, %rdi
leaq 0x9dc1f(%rip), %rsi     # 0xea78f
callq 0x35c27
incq %rbp
movq 0x8(%r14), %rdi
callq 0x6f310
cmpq %rax, %rbp
jb 0x4ca4f
movq 0x8(%r14), %rdi
callq 0x6f768
movq (%r14), %rdi
callq 0x77bab
movq %rbx, %rdi
callq 0x8b7c2
movq 0x18(%rsp), %r12
incq %r12
movq 0x10(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x3cbed
cmpq %rax, %r12
jb 0x4ca0b
movq 0x8(%rbx), %rdi
callq 0x77bab
movq 0x10(%rbx), %rdi
callq 0x3cc00
leaq 0x9dbb4(%rip), %rsi     # 0xea78f
movq %rbx, %rdi
movl $0x2dd, %edx            # imm = 0x2DD
callq 0x35c27
movq 0x8(%rsp), %rdi
callq 0x3c87b
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x15ae9
callq 0x15ab0
callq 0x15b22