// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/annotationsketch/graphics_cairo.c
// Function: gt_graphics_cairo_save_to_stream
void gt_graphics_cairo_save_to_stream(const GtGraphics *gg, GtStr *stream)
{
  const GtGraphicsCairo *g = (const GtGraphicsCairo*) gg;
  GT_UNUSED cairo_status_t rval;
  cairo_surface_t *bgsurf = NULL;
  cairo_t *bgc = NULL;
  gt_assert(g && stream);

  /* do nothing if no surface was created */
  if (g->from_context)
    return;
  switch (g->type)
  {
    case GT_GRAPHICS_PNG:
      /* blend rendered image with background color */
      bgsurf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, g->width,
                                          g->height);
      bgc = cairo_create(bgsurf);
      cairo_set_source_rgba(bgc, g->bg_color.red, g->bg_color.green,
                                 g->bg_color.blue, g->bg_color.alpha);
      cairo_paint(bgc);
      cairo_set_source_surface(bgc, g->surf, 0, 0);
      cairo_paint(bgc);
      rval = cairo_surface_write_to_png_stream(bgsurf, str_write_func, stream);
      gt_assert(rval == CAIRO_STATUS_SUCCESS); /* str_write_func() is sane */
      cairo_destroy(bgc);
      cairo_surface_destroy(bgsurf);
      break;
    default:
      cairo_show_page(g->cr);
      cairo_surface_flush(g->surf);
      cairo_surface_finish(g->surf);
      gt_str_reset(stream);
      gt_str_append_str(stream, g->outbuf);
      gt_assert(gt_str_length(stream) > 0);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x30769
movq %rsi, %rbx
testq %rsi, %rsi
je 0x30769
movq %rdi, %r14
cmpb $0x0, 0x70(%rdi)
jne 0x3075d
cmpl $0x1, 0x48(%r14)
jne 0x30721
cvttsd2si 0x68(%r14), %esi
cvttsd2si 0x60(%r14), %edx
xorl %edi, %edi
callq 0xb840
movq %rax, %r15
movq %rax, %rdi
callq 0xb1e0
movq %rax, %r12
movsd 0x20(%r14), %xmm0
movsd 0x28(%r14), %xmm1
movsd 0x30(%r14), %xmm2
movsd 0x38(%r14), %xmm3
movq %rax, %rdi
callq 0xb380
movq %r12, %rdi
callq 0xba70
movq 0x18(%r14), %rsi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
movq %r12, %rdi
callq 0xbbd0
movq %r12, %rdi
callq 0xba70
leaq -0x21c8(%rip), %rsi     # 0x2e52b
movq %r15, %rdi
movq %rbx, %rdx
callq 0xbb90
testl %eax, %eax
jne 0x307a1
movq %r12, %rdi
callq 0xb8b0
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xb7a0
movq 0x10(%r14), %rdi
callq 0xb4a0
movq 0x18(%r14), %rdi
callq 0xbae0
movq 0x18(%r14), %rdi
callq 0xb230
movq %rbx, %rdi
callq 0x1452f
movq 0x40(%r14), %rsi
movq %rbx, %rdi
callq 0x13eeb
movq %rbx, %rdi
callq 0x14461
testq %rax, %rax
je 0x307cf
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xfd848(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x998ec(%rip), %rsi     # 0xca066
leaq 0xa3ecb(%rip), %rdx     # 0xd464c
leaq 0xa3ed0(%rip), %rcx     # 0xd4658
leaq 0xa39dd(%rip), %r8      # 0xd416c
movl $0x2c3, %r9d            # imm = 0x2C3
xorl %eax, %eax
callq 0xb8c0
callq 0xb300
movq 0xfd810(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x998b4(%rip), %rsi     # 0xca066
leaq 0xa3ec0(%rip), %rdx     # 0xd4679
leaq 0xa3e98(%rip), %rcx     # 0xd4658
leaq 0xa39a5(%rip), %r8      # 0xd416c
movl $0x2d5, %r9d            # imm = 0x2D5
jmp 0x30795
movq 0xfd7e2(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x99886(%rip), %rsi     # 0xca066
leaq 0xa3eaf(%rip), %rdx     # 0xd4696
leaq 0xa3e6a(%rip), %rcx     # 0xd4658
leaq 0xa3977(%rip), %r8      # 0xd416c
movl $0x2df, %r9d            # imm = 0x2DF
jmp 0x30795