// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/examples/sketch_parsed_with_ctrack.c
// Function: main
int main(int argc, char *argv[])
{
  const char *style_file, *png_file, *gff3_file;
  char *seqid;
  GtStyle *style;
  GtBioseq *bioseq;
  GtFeatureIndex *feature_index;
  GtRange range;
  GtDiagram *diagram;
  GtLayout *layout;
  GtCanvas *canvas;
  GtCustomTrack *custom;
  GtUword height, windowsize;
  GtError *err;

  if (argc != 9) {
    fprintf(stderr, "Usage: %s style_file PNG_file GFF3_file Seq_file seqid"
                    " start end windowsize\n",
                    argv[0]);
    return EXIT_FAILURE;
  }

  style_file = argv[1];
  png_file = argv[2];
  gff3_file = argv[3];

  /* initialize */
  gt_lib_init();

  /* create error object */
  err = gt_error_new();

  /* create style */
  if (!(style = gt_style_new(err)))
    handle_error(err);

  /* load style file */
  if (gt_style_load_file(style, style_file, err))
    handle_error(err);

  /* create feature index */
  feature_index = gt_feature_index_memory_new();

  /* add GFF3 file to index */
  if (gt_feature_index_add_gff3file(feature_index, gff3_file, err))
    handle_error(err);

  /* create diagram for first sequence ID in feature index */
  seqid = argv[5];
  if (gt_feature_index_get_range_for_seqid(feature_index, &range, seqid, err))
    handle_error(err);
  sscanf(argv[6], "%lu", &range.start);
  sscanf(argv[7], "%lu", &range.end);
  sscanf(argv[8], "%lu", &windowsize);

  diagram = gt_diagram_new(feature_index, seqid, &range, style, err);
  if (gt_error_is_set(err))
    handle_error(err);

  /* load sequence for GC plot */
  bioseq = gt_bioseq_new(argv[4], err);
  if (gt_error_is_set(err))
    handle_error(err);

  /* create custom track with GC plot for first sequence in file,
     window size 1000, 40px height and average line at 16.5% */
  custom = gt_custom_track_gc_content_new(gt_bioseq_get_sequence(bioseq, 0),
                                          gt_bioseq_get_sequence_length(bioseq,
                                                                        0),
                                          windowsize,
                                          70,
                                          0.165,
                                          true);
  gt_diagram_add_custom_track(diagram, custom);

  /* create layout with given width, determine resulting image height */
  layout = gt_layout_new(diagram, 600, style, err);
  if (gt_error_is_set(err))
    handle_error(err);
  if (gt_layout_get_height(layout, &height, err))
    handle_error(err);

  /* create PNG canvas */
  canvas = gt_canvas_cairo_file_new(style, GT_GRAPHICS_PNG, 600, height,
                                    NULL, err);
  if (!canvas)
    handle_error(err);

  /* sketch layout on canvas */
  if (gt_layout_sketch(layout, canvas, err))
    handle_error(err);

  /* write canvas to file */
  if (gt_canvas_cairo_file_to_file((GtCanvasCairoFile*) canvas, png_file, err))
    handle_error(err);

  /* free */
  gt_custom_track_delete(custom);
  gt_bioseq_delete(bioseq);
  gt_canvas_delete(canvas);
  gt_layout_delete(layout);
  gt_diagram_delete(diagram);
  gt_feature_index_delete(feature_index);
  gt_style_delete(style);
  gt_error_delete(err);

  /* perform static data cleanup */
  gt_lib_clean();
  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbp
cmpl $0x9, %edi
jne 0xc044
movq 0x8(%rbp), %r12
movq 0x10(%rbp), %r13
movq 0x18(%rbp), %r15
callq 0x2dc74
callq 0x27ebc
movq %rax, %rbx
movq %rax, %rdi
callq 0x5e980
testq %rax, %rax
je 0xc065
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5efa9
testl %eax, %eax
jne 0xc065
callq 0x43a98
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x42141
testl %eax, %eax
jne 0xc065
movq %r13, 0x20(%rsp)
movq 0x28(%rbp), %r15
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x42660
testl %eax, %eax
jne 0xc065
movq 0x30(%rbp), %rdi
leaq 0xc8d2e(%rip), %r12     # 0xd4bb6
leaq 0x38(%rsp), %r13
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0xb680
movq 0x38(%rbp), %rdi
leaq 0x40(%rsp), %rdx
movq %r12, %rsi
xorl %eax, %eax
callq 0xb680
movq 0x40(%rbp), %rdi
leaq 0x28(%rsp), %rdx
movq %r12, %rsi
xorl %eax, %eax
callq 0xb680
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
movq %rbx, %r8
callq 0x56888
movq %rax, %r13
movq %rbx, %rdi
callq 0x27fcf
testb %al, %al
jne 0xc065
movq %r14, 0x18(%rsp)
movq 0x20(%rbp), %rdi
movq %rbx, %rsi
callq 0xc09c
movq %rax, %rbp
movq %rbx, %rdi
callq 0x27fcf
testb %al, %al
jne 0xc065
movq %rbp, %rdi
xorl %esi, %esi
callq 0xca2d
movq %rax, %r15
movq %rbp, %rdi
xorl %esi, %esi
callq 0xcb25
movq 0x28(%rsp), %rdx
pushq $0x46
popq %rcx
movsd 0xbf0d4(%rip), %xmm0    # 0xcb008
pushq $0x1
popq %r8
movq %r15, %rdi
movq %rax, %rsi
callq 0x56794
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x56e68
movq %r13, %rdi
movl $0x258, %esi            # imm = 0x258
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x5d334
movq %rax, %r12
movq %rbx, %rdi
callq 0x27fcf
testb %al, %al
jne 0xc065
movq %r13, 0x10(%rsp)
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x5db89
testl %eax, %eax
jne 0xc065
movq 0x30(%rsp), %rcx
pushq $0x1
popq %rsi
movl $0x258, %edx            # imm = 0x258
movq %r14, %rdi
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x55ac9
testq %rax, %rax
je 0xc065
movq %rax, %r13
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x5d709
testl %eax, %eax
jne 0xc065
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x55928
testl %eax, %eax
jne 0xc065
movq %r15, %rdi
callq 0x55db1
movq %rbp, %rdi
callq 0xc7bb
movq %r13, %rdi
callq 0x55447
movq %r12, %rdi
callq 0x5d69b
movq 0x10(%rsp), %rdi
callq 0x570c5
movq 0x18(%rsp), %rdi
callq 0x41ebb
movq %r14, %rdi
callq 0x60a55
movq %rbx, %rdi
callq 0x2815d
callq 0x2debb
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x123f6d(%rip), %rax    # 0x12ffb8
movq (%rax), %rdi
movq (%rbp), %rdx
leaq 0xbefb7(%rip), %rsi     # 0xcb010
xorl %eax, %eax
callq 0xb8c0
pushq $0x1
popq %rax
jmp 0xc035
movq %rbx, %rdi
callq 0xc06d