// File: /workspace/github_c_makefile_star2_O3/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 0x34fd6
movq 0x8(%rbp), %r12
movq 0x10(%rbp), %r13
movq 0x18(%rbp), %r15
callq 0x50600
callq 0x4bd88
movq %rax, %rbx
movq %rax, %rdi
callq 0x77244
testq %rax, %rax
je 0x34fe5
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x77643
testl %eax, %eax
jne 0x34fe5
callq 0x62c05
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x6181c
testl %eax, %eax
jne 0x34fe5
movq %r13, 0x20(%rsp)
movq 0x28(%rbp), %r15
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x61b94
testl %eax, %eax
jne 0x34fe5
movq 0x30(%rbp), %rdi
leaq 0xb69ee(%rip), %r12     # 0xeb806
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 0x70cf4
movq %rax, %r13
movq %rbx, %rdi
callq 0x4be6e
testb %al, %al
jne 0x34fe5
movq %r14, 0x18(%rsp)
movq 0x20(%rbp), %rdi
movq %rbx, %rsi
callq 0x3501c
movq %rax, %rbp
movq %rbx, %rdi
callq 0x4be6e
testb %al, %al
jne 0x34fe5
movq %rbp, %rdi
xorl %esi, %esi
callq 0x357a1
movq %rax, %r15
movq %rbp, %rdi
xorl %esi, %esi
callq 0x35837
movq 0x28(%rsp), %rdx
movsd 0xad147(%rip), %xmm0    # 0xe2008
movl $0x46, %ecx
movq %r15, %rdi
movq %rax, %rsi
movl $0x1, %r8d
callq 0x70bff
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x71136
movq %r13, %rdi
movl $0x258, %esi            # imm = 0x258
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x76204
movq %rax, %r12
movq %rbx, %rdi
callq 0x4be6e
testb %al, %al
jne 0x34fe5
movq %r13, 0x10(%rsp)
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x7673d
testl %eax, %eax
jne 0x34fe5
movq 0x30(%rsp), %rcx
movl $0x258, %edx            # imm = 0x258
movq %r14, %rdi
movl $0x1, %esi
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x700e2
testq %rax, %rax
je 0x34fe5
movq %rax, %r13
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x76501
testl %eax, %eax
jne 0x34fe5
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x6ffc4
testl %eax, %eax
jne 0x34fe5
movq %r15, %rdi
callq 0x70339
movq %rbp, %rdi
callq 0x355b1
movq %r13, %rdi
callq 0x6fdb0
movq %r12, %rdi
callq 0x76493
movq 0x10(%rsp), %rdi
callq 0x71336
movq 0x18(%rsp), %rdi
callq 0x61662
movq %r14, %rdi
callq 0x78984
movq %rbx, %rdi
callq 0x4bf09
callq 0x5082b
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
callq 0xbd00
movl $0x1, %eax
jmp 0x34fc7
movq %rbx, %rdi
callq 0x34fed