// File: /workspace/github_c_makefile_star2_O0/algorithm-archivists[P]GathVL/src/objects/tex_string.cpp
// Function: tex_string::draw(_cairo*) const
void tex_string::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 failed in tex_string." << 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 tex_string."
                    << std::endl;
                return;
            }

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

            if (!tmp) {
                std::cout << "Malloc failed in tex_string." << 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_rgba(ctx, clr.r, clr.g, clr.b, clr.a);
        cairo_mask_surface(ctx, surface, 0, 0);
        cairo_fill(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, 0x88(%rax)
je 0x36581
movq -0x38(%rbp), %rax
movl $0x0, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
xorps %xmm0, %xmm0
ucomisd 0x50(%rax), %xmm0
jae 0x362e3
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd 0x58(%rax), %xmm0
jae 0x362e3
movq -0x38(%rbp), %rax
movsd 0x50(%rax), %xmm0
cvtsi2sdl 0x90(%rax), %xmm1
ucomisd %xmm1, %xmm0
jne 0x36387
jp 0x36387
movq -0x38(%rbp), %rax
movsd 0x58(%rax), %xmm0
cvtsi2sdl 0x94(%rax), %xmm1
ucomisd %xmm1, %xmm0
jne 0x36387
jp 0x36387
movq -0x38(%rbp), %rax
movl 0x90(%rax), %esi
xorl %edi, %edi
callq 0x5790
movq -0x38(%rbp), %rcx
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
imull 0x94(%rcx), %eax
movslq %eax, %rdi
callq 0x5690
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3633f
movq 0x18c89(%rip), %rdi     # 0x4efa8
leaq 0x7254(%rip), %rsi      # 0x3d57a
callq 0x5780
movq %rax, %rdi
movq 0x18c8b(%rip), %rsi     # 0x4efc0
callq 0x5960
jmp 0x36581
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x20(%rbp), %rsi
movl 0x90(%rax), %edx
movl 0x94(%rax), %ecx
callq 0x36590
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rdi
movl 0x90(%rax), %edx
movl 0x94(%rax), %ecx
movl -0x14(%rbp), %r8d
xorl %esi, %esi
callq 0x5800
movq %rax, -0x28(%rbp)
jmp 0x364e7
movq -0x38(%rbp), %rax
cvttsd2si 0x50(%rax), %esi
xorl %edi, %edi
callq 0x5790
movq -0x38(%rbp), %rcx
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cvttsd2si 0x58(%rcx), %ecx
imull %ecx, %eax
movslq %eax, %rdi
callq 0x5690
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x363e3
movq 0x18be5(%rip), %rdi     # 0x4efa8
leaq 0x71cd(%rip), %rsi      # 0x3d597
callq 0x5780
movq %rax, %rdi
movq 0x18be7(%rip), %rsi     # 0x4efc0
callq 0x5960
jmp 0x36581
movq -0x38(%rbp), %rax
movsd 0x50(%rax), %xmm0
mulsd 0x58(%rax), %xmm0
movsd 0x5037(%rip), %xmm1     # 0x3b430
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movslq %eax, %rdi
callq 0x5690
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x36452
movq 0x18b8d(%rip), %rdi     # 0x4efa8
leaq 0x7158(%rip), %rsi      # 0x3d57a
callq 0x5780
movq %rax, %rdi
movq 0x18b8f(%rip), %rsi     # 0x4efc0
callq 0x5960
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x3644d
movq -0x40(%rbp), %rdi
callq 0x51f0
jmp 0x36581
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rdi
movl 0x90(%rax), %esi
movl 0x94(%rax), %edx
movq -0x30(%rbp), %r8
cvttsd2si 0x50(%rax), %r9d
cvttsd2si 0x58(%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 0x50(%rax), %edx
cvttsd2si 0x58(%rax), %ecx
callq 0x36590
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rdi
cvttsd2si 0x50(%rax), %edx
cvttsd2si 0x58(%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 0x364e5
movq -0x48(%rbp), %rdi
callq 0x51f0
jmp 0x364e7
movq -0x10(%rbp), %rdi
callq 0x52b0
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
movsd 0x40(%rax), %xmm0
movsd 0x48(%rax), %xmm1
callq 0x5140
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
movsd 0x60(%rax), %xmm0
callq 0x5770
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
movsd 0x20(%rax), %xmm0
movsd 0x28(%rax), %xmm1
movsd 0x30(%rax), %xmm2
movsd 0x38(%rax), %xmm3
callq 0x5220
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x5030
movq -0x10(%rbp), %rdi
callq 0x5890
movq -0x10(%rbp), %rdi
callq 0x5840
movq -0x28(%rbp), %rdi
callq 0x5998
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x3657f
movq -0x50(%rbp), %rdi
callq 0x51f0
jmp 0x36581
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)