// File: /workspace/github_c_makefile_star2_O0/algorithm-archivists[P]GathVL/src/objects/image.cpp
// Function: image::draw(_cairo*) const
void image::draw(cairo_t *ctx) const {
    if (image_data) {
        int stride = 0;
        unsigned char *data = nullptr;
        cairo_surface_t *surface;

        if (size.x <= 0 || size.y <= 0 ||
            (size.x == width && size.y == height)) {

            stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
            data = new unsigned char[stride * height];

            if (!data) {
                std::cout << "Malloc for data failed in image." << std::endl;
                return;
            }

            format_converter(image_data, data, width, height);

            surface =
                cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32,
                                                    width, height, stride);
        } else {
            stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
                                                   (int)size.x);

            data = new unsigned char[stride * (int)size.y];

            if (!data) {
                std::cout << "Malloc for data failed in image." << std::endl;
                return;
            }

            unsigned char *tmp = new unsigned char[(int)(size.x * size.y * 4)];

            if (!tmp) {
                std::cout << "Malloc failed in image." << std::endl;
                delete[] data;
                return;
            }

            stbir_resize_uint8(image_data, width, height, 0,
                               tmp, size.x, size.y, 0, 4);

            format_converter(tmp, data, (int)size.x, (int)size.y);

            surface =
                cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32,
                                                    (int)size.x, (int)size.y,
                                                    stride);

            delete[] tmp;
        }

        cairo_save(ctx);
        cairo_translate(ctx, location.x, location.y);
        cairo_rotate(ctx, rotation);

        cairo_set_source_surface(ctx, surface, 0, 0);

        if (size.x <= 0 || size.y <= 0 ||
            (size.x == width && size.y == height)) {
            cairo_rectangle(ctx, 0, 0, width, height);
        } else {
            cairo_rectangle(ctx, 0, 0, size.x, size.y);
        }

        cairo_clip(ctx);
        cairo_paint(ctx);

        cairo_restore(ctx);

        cairo_surface_destroy(surface);
        delete[] data;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, 0x48(%rax)
je 0x192f6
movq -0x38(%rbp), %rax
movl $0x0, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
xorps %xmm0, %xmm0
ucomisd 0x30(%rax), %xmm0
jae 0x1900a
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd 0x38(%rax), %xmm0
jae 0x1900a
movq -0x38(%rbp), %rax
movsd 0x30(%rax), %xmm0
cvtsi2sdl 0x50(%rax), %xmm1
ucomisd %xmm1, %xmm0
jne 0x19099
jp 0x19099
movq -0x38(%rbp), %rax
movsd 0x38(%rax), %xmm0
cvtsi2sdl 0x54(%rax), %xmm1
ucomisd %xmm1, %xmm0
jne 0x19099
jp 0x19099
movq -0x38(%rbp), %rax
movl 0x50(%rax), %esi
xorl %edi, %edi
callq 0x5790
movq -0x38(%rbp), %rcx
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
imull 0x54(%rcx), %eax
movslq %eax, %rdi
callq 0x5690
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x19060
movq 0x35f68(%rip), %rdi     # 0x4efa8
leaq 0x22cf8(%rip), %rsi     # 0x3bd3f
callq 0x5780
movq %rax, %rdi
movq 0x35f6a(%rip), %rsi     # 0x4efc0
callq 0x5960
jmp 0x192f6
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rsi
movl 0x50(%rax), %edx
movl 0x54(%rax), %ecx
callq 0x19300
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rdi
movl 0x50(%rax), %edx
movl 0x54(%rax), %ecx
movl -0x14(%rbp), %r8d
xorl %esi, %esi
callq 0x5800
movq %rax, -0x28(%rbp)
jmp 0x191f0
movq -0x38(%rbp), %rax
cvttsd2si 0x30(%rax), %esi
xorl %edi, %edi
callq 0x5790
movq -0x38(%rbp), %rcx
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cvttsd2si 0x38(%rcx), %ecx
imull %ecx, %eax
movslq %eax, %rdi
callq 0x5690
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x190f5
movq 0x35ed3(%rip), %rdi     # 0x4efa8
leaq 0x22c63(%rip), %rsi     # 0x3bd3f
callq 0x5780
movq %rax, %rdi
movq 0x35ed5(%rip), %rsi     # 0x4efc0
callq 0x5960
jmp 0x192f6
movq -0x38(%rbp), %rax
movsd 0x30(%rax), %xmm0
mulsd 0x38(%rax), %xmm0
movsd 0x22325(%rip), %xmm1    # 0x3b430
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movslq %eax, %rdi
callq 0x5690
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x19164
movq 0x35e7b(%rip), %rdi     # 0x4efa8
leaq 0x22c2c(%rip), %rsi     # 0x3bd60
callq 0x5780
movq %rax, %rdi
movq 0x35e7d(%rip), %rsi     # 0x4efc0
callq 0x5960
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x1915f
movq -0x40(%rbp), %rdi
callq 0x51f0
jmp 0x192f6
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rdi
movl 0x50(%rax), %esi
movl 0x54(%rax), %edx
movq -0x30(%rbp), %r8
cvttsd2si 0x30(%rax), %r9d
cvttsd2si 0x38(%rax), %eax
xorl %ecx, %ecx
movl %eax, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x4, 0x10(%rsp)
callq 0x18390
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
cvttsd2si 0x30(%rax), %edx
cvttsd2si 0x38(%rax), %ecx
callq 0x19300
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rdi
cvttsd2si 0x30(%rax), %edx
cvttsd2si 0x38(%rax), %ecx
movl -0x14(%rbp), %r8d
xorl %esi, %esi
callq 0x5800
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x191ee
movq -0x48(%rbp), %rdi
callq 0x51f0
jmp 0x191f0
movq -0x10(%rbp), %rdi
callq 0x52b0
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
movsd 0x20(%rax), %xmm0
movsd 0x28(%rax), %xmm1
callq 0x5140
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
movsd 0x40(%rax), %xmm0
callq 0x5770
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x5470
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd 0x30(%rax), %xmm0
jae 0x1927d
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd 0x38(%rax), %xmm0
jae 0x1927d
movq -0x38(%rbp), %rax
movsd 0x30(%rax), %xmm0
cvtsi2sdl 0x50(%rax), %xmm1
ucomisd %xmm1, %xmm0
jne 0x1929c
jp 0x1929c
movq -0x38(%rbp), %rax
movsd 0x38(%rax), %xmm0
cvtsi2sdl 0x54(%rax), %xmm1
ucomisd %xmm1, %xmm0
jne 0x1929c
jp 0x1929c
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
cvtsi2sdl 0x50(%rax), %xmm2
cvtsi2sdl 0x54(%rax), %xmm3
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x5670
jmp 0x192b9
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
movsd 0x30(%rax), %xmm2
movsd 0x38(%rax), %xmm3
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x5670
movq -0x10(%rbp), %rdi
callq 0x5360
movq -0x10(%rbp), %rdi
callq 0x5580
movq -0x10(%rbp), %rdi
callq 0x5840
movq -0x28(%rbp), %rdi
callq 0x5998
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x192f4
movq -0x50(%rbp), %rdi
callq 0x51f0
jmp 0x192f6
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)