// File: SMT-COMP[P]scrambler/scrambler.cpp
// Function: scrambler::is_commutative(scrambler::node const*)
int is_commutative(const node *n)
{
    // *n might be a qualified identifier of the form ('as' identifier sort)
    const std::string *symbol = &(n->symbol);
    if (*symbol == "as") {
        assert(n->children.size() > 0);
        symbol = &(n->children[0]->symbol);
    }
    const std::string &s = *symbol;
    assert(!s.empty());

    // Core theory
    if (s == "and" || s == "or" || s == "xor" || s == "distinct") {
        return 0;
    }
    if (!logic_is_dl()) {
        if (s == "=") {
            return 0;
        }
    }

    // arithmetic (IA, RA, IRA) (but not difference logic)
    if (logic_is_arith()) {
        if (s == "*" || s == "+") {
            return 0;
        }
    }

    // BitVectors
    if (logic_is_bv()) {
        if (s == "bvand" || s == "bvor" || s == "bvxor" ||
            s == "bvnand" || s == "bvnor" || s == "bvcomp" ||
            s == "bvadd" || s == "bvmul") {
            return 0;
        }
    }

    // FloatingPoint
    if (logic_is_fp()) {
        if (s == "fp.eq") {
            return 0;
        }
        if (s == "fp.add" || s == "fp.mul") {
            return 1;
        }
    }

    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x14c8f(%rip), %rsi     # 0x1910e
callq 0x74e0
testb $0x1, %al
jne 0x448a
jmp 0x44d6
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
callq 0x7430
cmpq $0x0, %rax
jbe 0x449f
jmp 0x44be
leaq 0x14c6b(%rip), %rdi     # 0x19111
leaq 0x14b68(%rip), %rsi     # 0x19015
movl $0x1bd, %edx            # imm = 0x1BD
leaq 0x14c6f(%rip), %rcx     # 0x19128
callq 0x31a0
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7510
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x34f0
xorb $-0x1, %al
testb $0x1, %al
jne 0x44ef
jmp 0x44f1
jmp 0x4510
leaq 0x14c5c(%rip), %rdi     # 0x19154
leaq 0x14b16(%rip), %rsi     # 0x19015
movl $0x1c1, %edx            # imm = 0x1C1
leaq 0x14c1d(%rip), %rcx     # 0x19128
callq 0x31a0
movq -0x20(%rbp), %rdi
leaq 0x16cf3(%rip), %rsi     # 0x1b20e
callq 0x74e0
testb $0x1, %al
jne 0x4562
movq -0x20(%rbp), %rdi
leaq 0x14c58(%rip), %rsi     # 0x19187
callq 0x74e0
testb $0x1, %al
jne 0x4562
movq -0x20(%rbp), %rdi
leaq 0x14c36(%rip), %rsi     # 0x19179
callq 0x74e0
testb $0x1, %al
jne 0x4562
movq -0x20(%rbp), %rdi
leaq 0x14c08(%rip), %rsi     # 0x1915f
callq 0x74e0
testb $0x1, %al
jne 0x4562
jmp 0x456e
movl $0x0, -0x4(%rbp)
jmp 0x4703
callq 0x41e0
testb $0x1, %al
jne 0x459b
movq -0x20(%rbp), %rdi
leaq 0x16a25(%rip), %rsi     # 0x1afa7
callq 0x74e0
testb $0x1, %al
jne 0x458d
jmp 0x4599
movl $0x0, -0x4(%rbp)
jmp 0x4703
jmp 0x459b
callq 0x4290
testb $0x1, %al
jne 0x45a6
jmp 0x45de
movq -0x20(%rbp), %rdi
leaq 0x14bb7(%rip), %rsi     # 0x19168
callq 0x74e0
testb $0x1, %al
jne 0x45d0
movq -0x20(%rbp), %rdi
leaq 0x14ba5(%rip), %rsi     # 0x1916a
callq 0x74e0
testb $0x1, %al
jne 0x45d0
jmp 0x45dc
movl $0x0, -0x4(%rbp)
jmp 0x4703
jmp 0x45de
callq 0x4340
testb $0x1, %al
jne 0x45ec
jmp 0x469d
movq -0x20(%rbp), %rdi
leaq 0x14b75(%rip), %rsi     # 0x1916c
callq 0x74e0
testb $0x1, %al
jne 0x4692
movq -0x20(%rbp), %rdi
leaq 0x14b63(%rip), %rsi     # 0x19172
callq 0x74e0
testb $0x1, %al
jne 0x4692
movq -0x20(%rbp), %rdi
leaq 0x14b54(%rip), %rsi     # 0x19177
callq 0x74e0
testb $0x1, %al
jne 0x4692
movq -0x20(%rbp), %rdi
leaq 0x14b46(%rip), %rsi     # 0x1917d
callq 0x74e0
testb $0x1, %al
jne 0x4692
movq -0x20(%rbp), %rdi
leaq 0x14b39(%rip), %rsi     # 0x19184
callq 0x74e0
testb $0x1, %al
jne 0x4692
movq -0x20(%rbp), %rdi
leaq 0x14b2b(%rip), %rsi     # 0x1918a
callq 0x74e0
testb $0x1, %al
jne 0x4692
movq -0x20(%rbp), %rdi
leaq 0x14b1e(%rip), %rsi     # 0x19191
callq 0x74e0
testb $0x1, %al
jne 0x4692
movq -0x20(%rbp), %rdi
leaq 0x14b10(%rip), %rsi     # 0x19197
callq 0x74e0
testb $0x1, %al
jne 0x4692
jmp 0x469b
movl $0x0, -0x4(%rbp)
jmp 0x4703
jmp 0x469d
callq 0x43d0
testb $0x1, %al
jne 0x46a8
jmp 0x46fc
movq -0x20(%rbp), %rdi
leaq 0x14aea(%rip), %rsi     # 0x1919d
callq 0x74e0
testb $0x1, %al
jne 0x46be
jmp 0x46c7
movl $0x0, -0x4(%rbp)
jmp 0x4703
movq -0x20(%rbp), %rdi
leaq 0x14ad1(%rip), %rsi     # 0x191a3
callq 0x74e0
testb $0x1, %al
jne 0x46f1
movq -0x20(%rbp), %rdi
leaq 0x14ac4(%rip), %rsi     # 0x191aa
callq 0x74e0
testb $0x1, %al
jne 0x46f1
jmp 0x46fa
movl $0x1, -0x4(%rbp)
jmp 0x4703
jmp 0x46fc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)