// File: /workspace/github_cpp_makefile_star2_O1/cloudinary[P]fuif/./import/read_gif.h
// Function: read_GIF_file(char const*)
Image read_GIF_file(const char *filename) {
    gd_GIF *gif;
    gif = gd_open_gif(filename);
    if (!gif) {
//        v_printf(3,"%s could not be loaded as GIF\n",filename);
        return Image();
    }
    int w = gif->width;
    int h = gif->height;
    uint8_t *frame = (uint8_t*) calloc(1, w * h * 4);

    Image image(w, h, 255, 4);
    image.den=100;
    int ret = 1;
    int f = 0;
    while (ret) {
        ret = gd_get_frame(gif);
        if (ret < 1) break;

        // make room
        image.channel[0].resize(w, h+h*f);
        image.channel[1].resize(w, h+h*f);
        image.channel[2].resize(w, h+h*f);
        image.channel[3].resize(w, h+h*f);

        gd_render_frame(gif, frame);
        image.num.push_back(gif->gce.delay);
//        printf("Frame %i: ret=%i, delay=%i\n",f,ret,gif->gce.delay);

        for (int y=0; y<h; y++) {
            for (int x=0; x<w; x++) {
                image.channel[0].value(y+h*f,x) = frame[y*4*w+x*4];
                image.channel[1].value(y+h*f,x) = frame[y*4*w+x*4+1];
                image.channel[2].value(y+h*f,x) = frame[y*4*w+x*4+2];
                image.channel[3].value(y+h*f,x) = frame[y*4*w+x*4+3];
            }
        }
        f++;
    }
    free(frame);
    gd_close_gif(gif);
    image.nb_frames = f;
    image.h = h*f;

    return image;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r15
movq %rsi, %rdi
callq 0x1d705
testq %rax, %rax
je 0x1d681
movq %rax, %r14
movzwl 0x10(%rax), %r12d
movzwl 0x12(%rax), %ebx
leal (,%r12,4), %eax
movl %eax, 0x30(%rsp)
movl %eax, %esi
imull %ebx, %esi
movl $0x1, %edi
callq 0x3200
movq %rax, %r13
movq $0x0, 0x40(%rsp)
movq %r15, %rdi
movq %r12, 0x10(%rsp)
movl %r12d, %esi
movl %ebx, %edx
movl $0xff, %ecx
movl $0x4, %r8d
xorl %r9d, %r9d
callq 0x15138
movl $0x64, 0x3c(%r15)
leaq 0x40(%r15), %rax
movq %rax, 0x58(%rsp)
movq %r13, 0x38(%rsp)
addq $0x3, %r13
movq %r13, 0x78(%rsp)
movq %rbx, 0x8(%rsp)
leal (%rbx,%rbx), %eax
movq %rax, 0x60(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
movq %r15, 0x18(%rsp)
movq %r14, 0x68(%rsp)
movq %r14, %rdi
callq 0x1d904
testl %eax, %eax
jle 0x1d654
movq (%r15), %rdi
movq %r13, %rbx
movq 0x8(%rsp), %rax
imulq %rax, %rbx
addq %rax, %rbx
movq 0x10(%rsp), %r12
movl %r12d, 0x18(%rdi)
movl %ebx, 0x1c(%rdi)
movq %rbx, %rbp
imulq %r12, %rbp
leaq 0x24(%rdi), %rdx
movq %rbp, %rsi
callq 0xe944
movq (%r15), %rdx
leaq 0x40(%rdx), %rdi
movl %r12d, 0x58(%rdx)
movl %ebx, 0x5c(%rdx)
addq $0x64, %rdx
movq %rbp, %rsi
callq 0xe944
movq (%r15), %rdx
leaq 0x80(%rdx), %rdi
movl %r12d, 0x98(%rdx)
movl %ebx, 0x9c(%rdx)
addq $0xa4, %rdx
movq %rbp, %rsi
callq 0xe944
movq (%r15), %rdx
leaq 0xc0(%rdx), %rdi
movl %r12d, 0xd8(%rdx)
movl %ebx, 0xdc(%rdx)
addq $0xe4, %rdx
movq %rbp, %rsi
callq 0xe944
movq 0x660(%r14), %rsi
movzwl 0x10(%r14), %eax
movzwl 0x12(%r14), %edx
imull %eax, %edx
shll $0x2, %edx
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x3260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1e296
movzwl 0x18(%r14), %eax
movl %eax, 0x34(%rsp)
movq 0x48(%r15), %rsi
cmpq 0x50(%r15), %rsi
movq %r13, 0x70(%rsp)
je 0x1d409
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%r15)
movq 0x10(%rsp), %rdi
jmp 0x1d41d
movq 0x58(%rsp), %rdi
leaq 0x34(%rsp), %rdx
callq 0xf6da
movq 0x10(%rsp), %rdi
cmpq $0x0, 0x8(%rsp)
je 0x1d624
movq 0x18(%rsp), %rax
movq (%rax), %rax
leaq 0x24(%rax), %r14
leaq 0x64(%rax), %rcx
movq %rcx, 0xa0(%rsp)
leaq 0xa4(%rax), %rcx
movq %rcx, 0x98(%rsp)
movq %rax, 0x80(%rsp)
addq $0xe4, %rax
movq %rax, 0x90(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x88(%rsp)
testq %rdi, %rdi
je 0x1d5f5
movslq 0x28(%rsp), %rbp
addq 0x78(%rsp), %rbp
movq 0x80(%rsp), %rsi
movslq 0x18(%rsi), %rbx
movq (%rsi), %r12
movq 0x8(%rsi), %rax
subq %r12, %rax
sarq %rax
movq %rax, 0xb0(%rsp)
movslq 0x58(%rsi), %r13
movq 0x48(%rsi), %rax
movq 0x40(%rsi), %rcx
subq %rcx, %rax
sarq %rax
movq %rax, 0xa8(%rsp)
movslq 0x98(%rsi), %r8
movq 0x88(%rsi), %r11
movq 0x80(%rsi), %rdx
subq %rdx, %r11
sarq %r11
movslq 0xd8(%rsi), %rax
movq 0xc8(%rsi), %r9
movq 0xc0(%rsi), %rsi
subq %rsi, %r9
sarq %r9
movq 0x48(%rsp), %r15
movq %r15, %r10
imulq %rbx, %r10
movq 0x50(%rsp), %rdi
imulq %rdi, %rbx
addq %r12, %rbx
movq %r15, %r12
imulq %r13, %r12
imulq %rdi, %r13
addq %rcx, %r13
movq %r15, %rcx
imulq %r8, %rcx
imulq %rdi, %r8
addq %rdx, %r8
movq %r15, %rdx
imulq %rax, %rdx
imulq %rdi, %rax
addq %rsi, %rax
xorl %esi, %esi
leaq (%r10,%rsi), %rdi
cmpq %rdi, 0xb0(%rsp)
movq %r14, %rdi
cmovaq %rbx, %rdi
movq %r14, %r15
movzbl -0x3(%rbp,%rsi,4), %r14d
movw %r14w, (%rdi)
leaq (%r12,%rsi), %rdi
cmpq %rdi, 0xa8(%rsp)
movq 0xa0(%rsp), %rdi
cmovaq %r13, %rdi
movzbl -0x2(%rbp,%rsi,4), %r14d
movw %r14w, (%rdi)
leaq (%rcx,%rsi), %rdi
cmpq %rdi, %r11
movq 0x98(%rsp), %rdi
cmovaq %r8, %rdi
movzbl -0x1(%rbp,%rsi,4), %r14d
movw %r14w, (%rdi)
leaq (%rdx,%rsi), %rdi
cmpq %rdi, %r9
movq 0x90(%rsp), %rdi
cmovaq %rax, %rdi
movzbl (%rbp,%rsi,4), %r14d
movw %r14w, (%rdi)
movq %r15, %r14
movq 0x10(%rsp), %rdi
incq %rsi
addq $0x2, %rbx
addq $0x2, %r13
addq $0x2, %r8
addq $0x2, %rax
cmpq %rsi, %rdi
jne 0x1d555
movq 0x88(%rsp), %rcx
incq %rcx
movq 0x28(%rsp), %rax
addl 0x30(%rsp), %eax
movq %rax, 0x28(%rsp)
incq 0x48(%rsp)
addq $0x2, 0x50(%rsp)
cmpq 0x8(%rsp), %rcx
jne 0x1d485
movq 0x70(%rsp), %r13
incq %r13
movq 0x20(%rsp), %rax
addq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rax
addq %rax, 0x40(%rsp)
movq 0x18(%rsp), %r15
movq 0x68(%rsp), %r14
jmp 0x1d30a
movq 0x38(%rsp), %rdi
callq 0x3380
movl (%r14), %edi
callq 0x35f0
movq %r14, %rdi
callq 0x3380
movl %r13d, 0x38(%r15)
movq 0x8(%rsp), %rax
imull %r13d, %eax
movl %eax, 0x34(%r15)
jmp 0x1d6d1
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movups %xmm0, (%r15)
xorl %eax, %eax
movq %rax, 0x30(%r15)
movabsq $0xa00000001, %rcx      # imm = 0xA00000001
movq %rcx, 0x38(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movl $0xff, 0x60(%r15)
movups %xmm0, 0x78(%r15)
movq %rax, 0x88(%r15)
movups %xmm0, 0x64(%r15)
movb $0x1, 0xa8(%r15)
movq %r15, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1d6f2
movq %rax, %r14
movq 0x18(%rsp), %r15
jmp 0x1d6f5
movq %rax, %r14
movq %r15, %rdi
callq 0xded8
movq %r14, %rdi
callq 0x35a0