// File: /workspace/github_c_makefile_star2_O1/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, 0x10(%rsp)
movq %rsi, %rbx
movq $0x0, (%rsp)
callq 0x3bfe0
movq %rax, 0x8(%rsp)
movq 0x10(%rbx), %rdi
callq 0x3d560
testq %rax, %rax
je 0x4d849
xorl %r15d, %r15d
movq %rbx, 0x18(%rsp)
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x3d3e2
movq 0x8(%rbx), %rdi
movq %rax, %rsi
callq 0x77109
testq %rax, %rax
je 0x4d894
movq %rax, %r14
movq %r15, 0x20(%rsp)
movq 0x8(%rax), %rdi
callq 0x6ecda
xorl %r12d, %r12d
testq %rax, %rax
je 0x4d811
xorl %ebp, %ebp
movq 0x8(%r14), %rdi
movq %rbp, %rsi
callq 0x6e9fa
movq (%rax), %r13
cmpq $-0x1, 0x8(%r13)
jne 0x4d721
cmpb $0x1, 0x10(%r14)
jne 0x4d721
movq 0x10(%r13), %rdi
callq 0x8ac73
movq %rax, %r12
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x8bcd2
movl $0x2bb, %edx            # imm = 0x2BB
jmp 0x4d7ed
testq %r12, %r12
je 0x4d749
movq %r12, %rdi
callq 0x8aeff
movq %rax, (%rsp)
movq 0x10(%r13), %rsi
movq %rax, %rdi
callq 0x8ae20
movq 0x10(%r13), %rdi
callq 0x8bcd2
jmp 0x4d751
movq 0x10(%r13), %rax
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
je 0x4d88a
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3c49c
movq (%rsp), %rdi
movq 0x10(%rsp), %rbx
movq 0x50(%rbx), %rdx
movq %r15, %rsi
callq *0x58(%rbx)
movq (%rbx), %rbx
movq %r15, %rdi
callq 0x3c40b
movq %rbx, %rdi
movq %rax, %rsi
callq 0x77109
movq %rax, %rbx
testq %rax, %rax
jne 0x4d7cf
movl $0x8, %edi
callq 0x6e93c
movq %rax, %rbx
movq 0x10(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rsp), %rdi
callq 0x3c40b
movq %rax, %rdi
callq 0x722dc
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x77144
testq %rbx, %rbx
je 0x4d88f
movl $0x8, %edx
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x6ec0e
movl $0x2d5, %edx            # imm = 0x2D5
movq %r13, %rdi
leaq 0x9cfe8(%rip), %rsi     # 0xea7df
callq 0x362a0
incq %rbp
movq 0x8(%r14), %rdi
callq 0x6ecda
cmpq %rax, %rbp
jb 0x4d6e2
movq 0x8(%r14), %rdi
callq 0x6f134
movq (%r14), %rdi
callq 0x77675
movq %r12, %rdi
callq 0x8bcd2
movq 0x20(%rsp), %r15
incq %r15
movq 0x18(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x3d560
cmpq %rax, %r15
jb 0x4d6a2
movq 0x8(%rbx), %rdi
callq 0x77675
movq 0x10(%rbx), %rdi
callq 0x3d573
leaq 0x9cf7d(%rip), %rsi     # 0xea7df
movq %rbx, %rdi
movl $0x2dd, %edx            # imm = 0x2DD
callq 0x362a0
movq 0x8(%rsp), %rdi
callq 0x3d1eb
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x15c3b
callq 0x15c02
callq 0x15c74