// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/annotationsketch/graphics_cairo.c
// Function: gt_graphics_cairo_save_to_file
int gt_graphics_cairo_save_to_file(const GtGraphics *gg, const char *filename,
                                GtError *err)
{
  const GtGraphicsCairo *g = (const GtGraphicsCairo*) gg;
  cairo_surface_t *bgsurf = NULL;
  cairo_t *bgc = NULL;
  cairo_status_t rval;
  GtFile *outfile;
  gt_error_check(err);
  gt_assert(g && filename);

  /* do nothing if no surface was created */
  if (g->from_context)
    return 0;
  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(bgsurf, filename);
      gt_assert(rval == CAIRO_STATUS_SUCCESS ||
                rval == CAIRO_STATUS_WRITE_ERROR);
      if (rval == CAIRO_STATUS_WRITE_ERROR)
      {
        cairo_destroy(bgc);
        cairo_surface_destroy(bgsurf);
        gt_error_set(err, "an I/O error occurred while attempting "
                          "to write image file \"%s\"", filename);
        return -1;
      }
      cairo_destroy(bgc);
      cairo_surface_destroy(bgsurf);
      break;
    default:
      cairo_show_page(g->cr);
      cairo_surface_flush(g->surf);
      cairo_surface_finish(g->surf);
      outfile = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, filename, "w+", err);
      if (outfile)
      {
        gt_file_xwrite(outfile, gt_str_get_mem(g->outbuf),
                       gt_str_length(g->outbuf));
        gt_file_delete(outfile);
      } else return -1;
      break;
  }
  return 0;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x4437f
movq 0x38(%rsp), %rdi
callq 0xc270
testb $0x1, %al
jne 0x44347
jmp 0x4437f
movq 0x16fc8a(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0x119d0e(%rip), %rsi    # 0x15e066
leaq 0x11a2e9(%rip), %rdx    # 0x15e648
leaq 0x124475(%rip), %rcx    # 0x1687db
leaq 0x12403f(%rip), %r8     # 0x1683ac
movl $0x28d, %r9d            # imm = 0x28D
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x44381
jmp 0x44383
cmpq $0x0, 0x30(%rsp)
je 0x44393
cmpq $0x0, 0x40(%rsp)
jne 0x443cb
movq 0x16fc3e(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0x119cc2(%rip), %rsi    # 0x15e066
leaq 0x12444f(%rip), %rdx    # 0x1687fa
leaq 0x124429(%rip), %rcx    # 0x1687db
leaq 0x123ff3(%rip), %r8     # 0x1683ac
movl $0x28e, %r9d            # imm = 0x28E
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x443cd
movq 0x30(%rsp), %rax
testb $0x1, 0x70(%rax)
je 0x443e5
movl $0x0, 0x54(%rsp)
jmp 0x445e4
movq 0x30(%rsp), %rax
movl 0x48(%rax), %eax
subl $0x1, %eax
jne 0x4453a
jmp 0x443f8
movq 0x30(%rsp), %rax
cvttsd2si 0x68(%rax), %esi
movq 0x30(%rsp), %rax
cvttsd2si 0x60(%rax), %edx
xorl %edi, %edi
callq 0xb810
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0xb1c0
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
movsd 0x20(%rax), %xmm0
movq 0x30(%rsp), %rax
movsd 0x28(%rax), %xmm1
movq 0x30(%rsp), %rax
movsd 0x30(%rax), %xmm2
movq 0x30(%rsp), %rax
movsd 0x38(%rax), %xmm3
callq 0xb360
movq 0x20(%rsp), %rdi
callq 0xba40
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rsi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbba0
movq 0x20(%rsp), %rdi
callq 0xba40
movq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xb120
movl %eax, 0x1c(%rsp)
cmpl $0x0, 0x1c(%rsp)
je 0x444df
cmpl $0xb, 0x1c(%rsp)
je 0x444df
movq 0x16fb2a(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0x119bae(%rip), %rsi    # 0x15e066
leaq 0x124349(%rip), %rdx    # 0x168808
leaq 0x124315(%rip), %rcx    # 0x1687db
leaq 0x123edf(%rip), %r8     # 0x1683ac
movl $0x2a1, %r9d            # imm = 0x2A1
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x444e1
cmpl $0xb, 0x1c(%rsp)
jne 0x44521
movq 0x20(%rsp), %rdi
callq 0xb880
movq 0x28(%rsp), %rdi
callq 0xb770
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rdx
leaq 0x12433c(%rip), %rsi    # 0x168849
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x445e4
movq 0x20(%rsp), %rdi
callq 0xb880
movq 0x28(%rsp), %rdi
callq 0xb770
jmp 0x445dc
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0xb480
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xbab0
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xb210
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rcx
xorl %edi, %edi
leaq 0x124312(%rip), %rdx    # 0x168889
callq 0x82f00
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0x445d0
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x199b0
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x19a00
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rax, %rdx
callq 0x83d40
movq 0x10(%rsp), %rdi
callq 0x83f40
jmp 0x445da
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x445e4
jmp 0x445dc
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax)