// File: cloudinary[P]fuif/image/image.cpp
// Function: Image::undo_transforms(int)
void Image::undo_transforms(int keep) {
    while ( transform.size() > keep ) {
            Transform t = transform.back();
            v_printf(4,"Undoing transform %s\n",t.name());
            bool result = t.apply(*this, true);
            if (result == false) {
                e_printf("Error while undoing transform %s.\n",t.name());
                error = true;
                return;
            }
            v_printf(8,"Undoing transform %s: done\n",t.name());
            transform.pop_back();
    }
    if (!keep) { // clamp the values to the valid range (lossy compression can produce values outside the range)
        for (int i=0; i<channel.size(); i++) {
            for (int j=0; j<channel[i].data.size(); j++) {
                channel[i].data[j] = CLAMP(channel[i].data[j], minval, maxval);
            }
        }
    }
//    recompute_minmax();
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movl %esi, 0x9c(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
addq $0x18, %rdi
callq 0x4a70
movslq 0x9c(%rsp), %rcx
cmpq %rcx, %rax
jbe 0x4687
movq 0x50(%rsp), %rdi
addq $0x18, %rdi
callq 0x4a90
movq %rax, %rsi
leaq 0x78(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x4ad0
movq 0x40(%rsp), %rdi
callq 0x4b10
movq %rax, 0x48(%rsp)
jmp 0x4583
movq 0x48(%rsp), %rdx
leaq 0x41b80(%rip), %rsi     # 0x4610f
xorl %eax, %eax
movl $0x4, %edi
callq 0x3a770
jmp 0x459d
movq 0x50(%rsp), %rsi
leaq 0x78(%rsp), %rdi
movl $0x1, %edx
callq 0x11d80
movb %al, 0x3f(%rsp)
jmp 0x45b7
movb 0x3f(%rsp), %al
andb $0x1, %al
movb %al, 0x6b(%rsp)
movb 0x6b(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4628
leaq 0x78(%rsp), %rdi
callq 0x4b10
movq %rax, 0x30(%rsp)
jmp 0x45e0
movq 0x30(%rsp), %rsi
leaq 0x41b39(%rip), %rdi     # 0x46125
xorl %eax, %eax
callq 0x3a670
jmp 0x45f5
movq 0x50(%rsp), %rax
movb $0x1, 0xa8(%rax)
movl $0x1, 0x64(%rsp)
jmp 0x4669
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x4b60
jmp 0x47ee
leaq 0x78(%rsp), %rdi
callq 0x4b10
movq %rax, 0x28(%rsp)
jmp 0x4639
movq 0x28(%rsp), %rdx
leaq 0x41b03(%rip), %rsi     # 0x46148
xorl %eax, %eax
movl $0x8, %edi
callq 0x3a770
jmp 0x4653
movq 0x50(%rsp), %rdi
addq $0x18, %rdi
callq 0x4b40
movl $0x0, 0x64(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x4b60
movl 0x64(%rsp), %eax
testl %eax, %eax
je 0x4682
jmp 0x467d
jmp 0x47e6
jmp 0x4533
cmpl $0x0, 0x9c(%rsp)
jne 0x47e6
movl $0x0, 0x60(%rsp)
movq 0x50(%rsp), %rdi
movslq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
callq 0x4b80
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x47e4
movl $0x0, 0x5c(%rsp)
movq 0x50(%rsp), %rdi
movslq 0x5c(%rsp), %rax
movq %rax, 0x18(%rsp)
movslq 0x60(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
callq 0x4a30
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x47d2
movq 0x50(%rsp), %rdi
movslq 0x60(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movslq 0x5c(%rsp), %rsi
callq 0x4bc0
movq 0x50(%rsp), %rcx
movswl (%rax), %eax
cmpl 0x5c(%rcx), %eax
jge 0x4733
movq 0x50(%rsp), %rax
movl 0x5c(%rax), %eax
movl %eax, 0x14(%rsp)
jmp 0x4795
movq 0x50(%rsp), %rdi
movslq 0x60(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movslq 0x5c(%rsp), %rsi
callq 0x4bc0
movq 0x50(%rsp), %rcx
movswl (%rax), %eax
cmpl 0x60(%rcx), %eax
jle 0x476a
movq 0x50(%rsp), %rax
movl 0x60(%rax), %eax
movl %eax, 0x10(%rsp)
jmp 0x478d
movq 0x50(%rsp), %rdi
movslq 0x60(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movslq 0x5c(%rsp), %rsi
callq 0x4bc0
movswl (%rax), %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x50(%rsp), %rdi
movl 0x14(%rsp), %eax
movw %ax, 0xe(%rsp)
movslq 0x60(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movslq 0x5c(%rsp), %rsi
callq 0x4bc0
movw 0xe(%rsp), %cx
movw %cx, (%rax)
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x46ca
jmp 0x47d4
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x469d
jmp 0x47e6
addq $0xa8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x36a0
nopl (%rax,%rax)