// File: davidjosepha[P]slitherlink/src/solver/solver.cpp
// Function: Solver::applyRules(int*)
void Solver::applyRules(int selectedRules[]) {
    while (grid_->getUpdated()) {
        grid_->setUpdated(false);
        for (int i = 0; i < grid_->getHeight(); i++) {
            for (int j = 0; j < grid_->getWidth(); j++) {
                if (grid_->getUpdateMatrix(i, j)) {
                    for (int x = 0; x < selectLength_; x++) {
                        for (Orientation orient : (Orientation[]){ UP, DOWN, LEFT, RIGHT, UPFLIP, DOWNFLIP, LEFTFLIP, RIGHTFLIP }) {
                            if (ruleApplies(i, j, rules_[selectedRules[x]], orient)) {
                                applyRule(i, j, rules_[selectedRules[x]], orient);
                            }
                        }
                    }
                }
                grid_->setUpdateMatrix(i, j, false);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xfc70
testb $0x1, %al
jne 0xcdae
jmp 0xcf4d
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
callq 0xfc50
movl $0x0, -0x14(%rbp)
movq -0x68(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, -0x6c(%rbp)
movq 0x8(%rax), %rdi
callq 0x2ad0
movl %eax, %ecx
movl -0x6c(%rbp), %eax
cmpl %ecx, %eax
jge 0xcf48
movl $0x0, -0x18(%rbp)
movq -0x68(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, -0x70(%rbp)
movq 0x8(%rax), %rdi
callq 0x2af0
movl %eax, %ecx
movl -0x70(%rbp), %eax
cmpl %ecx, %eax
jge 0xcf38
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0xfd70
testb $0x1, %al
jne 0xce27
jmp 0xcf15
movl $0x0, -0x1c(%rbp)
movq -0x68(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x28(%rcx), %eax
jge 0xcf13
movq 0x85ff(%rip), %rax      # 0x15444
movq %rax, -0x48(%rbp)
movq 0x85fc(%rip), %rax      # 0x1544c
movq %rax, -0x40(%rbp)
movq 0x85f9(%rip), %rax      # 0x15454
movq %rax, -0x38(%rbp)
movq 0x85f6(%rip), %rax      # 0x1545c
movq %rax, -0x30(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0xcf03
movq -0x68(%rbp), %rdi
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movq 0x18(%rdi), %rcx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %r8
movslq (%rax,%r8,4), %rax
shlq $0x7, %rax
addq %rax, %rcx
movl -0x5c(%rbp), %r8d
callq 0xf410
testb $0x1, %al
jne 0xcec9
jmp 0xcef3
movq -0x68(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movq 0x18(%rdi), %rcx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %r8
movslq (%rax,%r8,4), %rax
shlq $0x7, %rax
addq %rax, %rcx
movl -0x5c(%rbp), %r8d
callq 0xf830
jmp 0xcef5
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
jmp 0xce86
jmp 0xcf05
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xce2e
jmp 0xcf15
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
xorl %ecx, %ecx
callq 0x48f0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xcdeb
jmp 0xcf3a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xcdc4
jmp 0xcd98
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)