// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/inputreader.cpp
// Function: maxPreprocessor::InputReader::readCardinalityConstraint(std::istream&)
int InputReader::readCardinalityConstraint(istream& inputF) {
	string inputLine;
	getline(inputF, inputLine);
	stringstream input(inputLine);
	string coding;
	input>>coding;
	if (input.fail()) return 1;
	int codingN;
	if (coding == "CARD") {
		codingN = CardinalityConstraint::CODING_DEFAULT;
	}
	else {
		return 1;
	}
	
	vector<int> inputLiterals;
	vector<int> outputLiterals;
	vector<int> addLiterals;
	string in;
	string compr;
	int p = 0;
	int k = 0;
	bool foundK = false;
	bool iff = 0;
	while (!input.eof() && input>>in) {
		if (input.fail()) return 1;
		if (in == "=" || in == ">=" || in == "<=" || in == ">" || in == "<" || in == "==" || in == "!=" || in == "<:" || in == ">:" || in == "::") {
			if (p != 0) return 1;
			compr = in;
			p = 1;
		}
		else if (in == "OUT") {
			if (p > 1) return 1;
			p = 2;
		}
		else if (in == "ADD") {
			if (p == 0 || p > 2) return 1;
			p = 3;
		}
		else if (in == "IFF") {
			iff = true;
		}
		else {
			stringstream ss;
			ss<<in;
			int t;
			ss>>t;
			if (!ss.eof()) return 1;
			if (ss.fail()) return 1;
			if (p == 0) {
				if (t == 0) return 1;
				inputLiterals.push_back(t);
			}
			else if (p == 1) {
				if (foundK && t == 0) break;
				if (foundK) return 1;
				foundK = true;
				k = t;
			}
			else if (p == 2) {
				if (t == 0) break;
				outputLiterals.push_back(t);
			}
			else if (p == 3) {
				if (t == 0) break;
				addLiterals.push_back(t);
			}
		}
		input>>ws;
	}
	if (!foundK) return 1;
	if (input.fail()) return 1;
	if (inputLiterals.size() == 0) return 1;
	if (compr == ">") {
		compr = ">=";
		k++;
	}
	if (compr == "<") {
		compr = "<=";
		k--;
	}
	if (compr == "==") compr = "=";
	
	int type = -1;
	
	if (compr == ">=") {
		compr = "<=";
		k = (int)inputLiterals.size() - k;
		for (int& lit : inputLiterals) {
			lit = -lit;
		}
	}
	
	if (compr == "<=") type = CardinalityConstraint::CONSTRAINT_LESS_EQ;
	else if (compr == "=") type = CardinalityConstraint::CONSTRAINT_EQUAL;
	else if (compr == "!=") type = CardinalityConstraint::CONSTRAINT_NEQUAL;
	else if (compr == "<:") type = CardinalityConstraint::CONSTRAINT_ALL_LESS;
	else if (compr == ">:") type = CardinalityConstraint::CONSTRAINT_ALL_GREATER;
	else if (compr == "::") type = CardinalityConstraint::CONSTRAINT_ALL_BOTH;
	else return 1;
	
	if (type == CardinalityConstraint::CONSTRAINT_ALL_LESS || type == CardinalityConstraint::CONSTRAINT_ALL_GREATER || type == CardinalityConstraint::CONSTRAINT_ALL_BOTH) {
		if (k != (int)outputLiterals.size()) return 1;
		if (k > (int)inputLiterals.size()) return 1;
		if (k <= 0) return 1;
	}
	else {
		if (outputLiterals.size() > 1) return 1;
	}
	
	if (outputLiterals.size() == 0) {
		iff = false;
	}
	if (type == CardinalityConstraint::CONSTRAINT_ALL_BOTH) {
		iff = true;
	}
	cardinalityConstraints.push_back(CardinalityConstraint(type, codingN, inputLiterals, outputLiterals, k, addLiterals, iff));
	if (input.fail()) return 1;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %rax
movq %rdi, %rbx
leaq 0xc8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0xb8(%rsp), %rsi
movq %rax, %rdi
callq 0x3060
leaq 0xf8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x3410
movq %rbx, 0x78(%rsp)
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xf8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x3360
movq 0xf8(%rsp), %rax
movq -0x18(%rax), %rax
pushq $0x1
popq %rbx
testb $0x5, 0x118(%rsp,%rax)
jne 0x1ed87
leaq 0x1188f(%rip), %rsi     # 0x302a0
leaq 0x98(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1ed87
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x60(%rsp), %rcx
andq $0x0, 0x10(%rcx)
leaq 0x80(%rsp), %rdx
andq $0x0, 0x10(%rdx)
leaq 0xe8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movaps %xmm0, (%rcx)
movaps %xmm0, (%rdx)
xorl %ebp, %ebp
leaq 0x30(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb %bpl, (%rax)
movb %bpl, (%rcx)
leaq 0xf8(%rsp), %r12
leaq 0xd8(%rsp), %r13
pushq $0x1
popq %rbx
leaq 0x1181f(%rip), %r15     # 0x302b3
leaq 0x20(%rsp), %r14
movl $0x0, 0xc(%rsp)
movl $0x0, 0x14(%rsp)
movl $0x0, 0x1c(%rsp)
movq 0xf8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x118(%rsp,%rax)
jne 0x1ed32
movq %r12, %rdi
movq %r13, %rsi
callq 0x3360
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1ed32
movq 0xf8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x118(%rsp,%rax)
jne 0x1ed4f
movq %r13, %rdi
movq %r15, %rsi
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x11786(%rip), %rsi     # 0x302a5
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x11772(%rip), %rsi     # 0x302a8
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x1175e(%rip), %rsi     # 0x302ab
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x1174d(%rip), %rsi     # 0x302ad
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x1173c(%rip), %rsi     # 0x302af
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x1172c(%rip), %rsi     # 0x302b2
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x1171c(%rip), %rsi     # 0x302b5
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x1170c(%rip), %rsi     # 0x302b8
callq 0x6844
testb %al, %al
jne 0x1ebc8
movq %r13, %rdi
leaq 0x116fc(%rip), %rsi     # 0x302bb
callq 0x6844
testb %al, %al
je 0x1ebea
testl %ebp, %ebp
jne 0x1ed4f
movq %r14, %rdi
movq %r13, %rsi
callq 0x3160
movl %ebx, %ebp
movq %r12, %rdi
callq 0x3260
jmp 0x1eab1
movq %r13, %rdi
leaq 0x116ca(%rip), %rsi     # 0x302be
callq 0x6844
testb %al, %al
je 0x1ec04
cmpl $0x1, %ebp
pushq $0x2
jmp 0x1ec24
movq %r13, %rdi
leaq 0x116b4(%rip), %rsi     # 0x302c2
callq 0x6844
testb %al, %al
je 0x1ec2c
testl %ebp, %ebp
je 0x1ed4f
cmpl $0x2, %ebp
pushq $0x3
popq %rbp
jle 0x1ebdd
jmp 0x1ed4f
movq %r13, %rdi
leaq 0x11690(%rip), %rsi     # 0x302c6
callq 0x6844
testb %al, %al
je 0x1ec47
movb $0x1, %al
movl %eax, 0x1c(%rsp)
jmp 0x1ebdd
leaq 0x280(%rsp), %rdi
callq 0x3210
leaq 0x290(%rsp), %rdi
movq %r13, %rsi
callq 0x3290
leaq 0x280(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x31a0
movq 0x280(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x2a0(%rsp,%rax), %eax
andl $0x7, %eax
cmpl $0x2, %eax
jne 0x1ed16
cmpl $0x3, %ebp
ja 0x1ed04
movl %ebp, %eax
leaq 0x115ed(%rip), %rcx     # 0x30290
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
jne 0x1ecd7
jmp 0x1ed16
cmpl $0x0, 0x10(%rsp)
leaq 0x60(%rsp), %rdi
jne 0x1ecd7
jmp 0x1ed25
cmpl $0x0, 0x10(%rsp)
leaq 0x80(%rsp), %rdi
je 0x1ed25
leaq 0x10(%rsp), %rsi
callq 0x68a4
jmp 0x1ed04
movl 0x10(%rsp), %eax
movl %eax, 0x18(%rsp)
testb $0x1, 0x14(%rsp)
jne 0x1f01f
movl 0x18(%rsp), %eax
movl %eax, 0xc(%rsp)
movb $0x1, %al
movl %eax, 0x14(%rsp)
leaq 0x280(%rsp), %rdi
callq 0x3230
jmp 0x1ebdd
leaq 0x280(%rsp), %rdi
callq 0x3230
jmp 0x1ed4f
leaq 0x280(%rsp), %rdi
callq 0x3230
testb $0x1, 0x14(%rsp)
je 0x1ed4f
movq 0xf8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x118(%rsp,%rax)
je 0x1edc2
leaq 0x20(%rsp), %rdi
callq 0x3130
leaq 0xd8(%rsp), %rdi
callq 0x3130
leaq 0x80(%rsp), %rdi
callq 0x7512
leaq 0x60(%rsp), %rdi
callq 0x7512
leaq 0x40(%rsp), %rdi
callq 0x7512
leaq 0x98(%rsp), %rdi
callq 0x3130
leaq 0xf8(%rsp), %rdi
callq 0x3230
leaq 0xb8(%rsp), %rdi
callq 0x3130
movl %ebx, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x1ed4f
leaq 0x114d6(%rip), %rsi     # 0x302ab
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1edf8
leaq 0x114bb(%rip), %rsi     # 0x302a5
leaq 0x20(%rsp), %rdi
callq 0x34d0
incl 0xc(%rsp)
leaq 0x114ae(%rip), %rsi     # 0x302ad
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1ee22
leaq 0x11494(%rip), %rsi     # 0x302a8
leaq 0x20(%rsp), %rdi
callq 0x34d0
decl 0xc(%rsp)
leaq 0x11486(%rip), %rsi     # 0x302af
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1ee48
leaq 0x11475(%rip), %rsi     # 0x302b3
leaq 0x20(%rsp), %rdi
callq 0x34d0
leaq 0x11456(%rip), %rsi     # 0x302a5
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1ee97
leaq 0x11444(%rip), %rsi     # 0x302a8
leaq 0x20(%rsp), %rdi
callq 0x34d0
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq %rdx, %rax
subq %rcx, %rax
shrq $0x2, %rax
cmpq %rdx, %rcx
je 0x1ee8f
negl (%rcx)
addq $0x4, %rcx
jmp 0x1ee82
subl 0xc(%rsp), %eax
movl %eax, 0xc(%rsp)
leaq 0x1140a(%rip), %rsi     # 0x302a8
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1eeb0
pushq $0x3
jmp 0x1eee4
leaq 0x113fc(%rip), %rsi     # 0x302b3
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1eec9
pushq $0x1
jmp 0x1eee4
leaq 0x113e2(%rip), %rsi     # 0x302b2
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1ef7e
pushq $0x2
popq %rsi
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
movq %rdx, %rax
subq %rcx, %rax
cmpq $0x4, %rax
ja 0x1ed4f
xorl %eax, %eax
cmpq %rcx, %rdx
setne %cl
andb 0x1c(%rsp), %cl
orb %al, %cl
leaq 0x80(%rsp), %rax
movzbl %cl, %r10d
leaq 0x280(%rsp), %rdi
pushq $0x1
popq %rdx
leaq 0x40(%rsp), %rcx
leaq 0x60(%rsp), %r8
movl 0xc(%rsp), %r9d
pushq %r10
pushq %rax
callq 0x2a1ac
popq %rax
popq %rcx
movq 0x78(%rsp), %rdi
addq $0x70, %rdi
leaq 0x280(%rsp), %rsi
callq 0x1fcde
leaq 0x280(%rsp), %rdi
callq 0x7006
movq 0xf8(%rsp), %rax
movq -0x18(%rax), %rax
xorl %ebx, %ebx
testb $0x5, 0x118(%rsp,%rax)
setne %bl
jmp 0x1ed4f
leaq 0x11330(%rip), %rsi     # 0x302b5
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1ef97
pushq $0x4
jmp 0x1efae
leaq 0x1131a(%rip), %rsi     # 0x302b8
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1effb
pushq $0x5
popq %rsi
xorl %eax, %eax
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
movq %rdx, %rdi
subq %rcx, %rdi
shrq $0x2, %rdi
pushq $0x1
popq %rbx
movl 0xc(%rsp), %r8d
cmpl %edi, %r8d
jne 0x1ed4f
testl %r8d, %r8d
jle 0x1ed4f
movq 0x48(%rsp), %rdi
subq 0x40(%rsp), %rdi
shrq $0x2, %rdi
cmpl %edi, %r8d
jle 0x1ef01
jmp 0x1ed4f
leaq 0x112b9(%rip), %rsi     # 0x302bb
leaq 0x20(%rsp), %rdi
callq 0x6844
testb %al, %al
je 0x1f017
movb $0x1, %al
pushq $0x6
popq %rsi
jmp 0x1efb1
pushq $0x1
popq %rbx
jmp 0x1ed4f
leaq 0x280(%rsp), %rdi
callq 0x3230
cmpl $0x0, 0x18(%rsp)
jne 0x1ed4f
jmp 0x1ed32
jmp 0x1f03e
movq %rax, %rbx
leaq 0x280(%rsp), %rdi
callq 0x3230
jmp 0x1f079
jmp 0x1f076
movq %rax, %rbx
leaq 0x280(%rsp), %rdi
callq 0x7006
jmp 0x1f079
jmp 0x1f076
jmp 0x1f076
jmp 0x1f076
movq %rax, %rbx
jmp 0x1f0b1
jmp 0x1f071
movq %rax, %rbx
jmp 0x1f0cb
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3130
leaq 0xd8(%rsp), %rdi
callq 0x3130
leaq 0x80(%rsp), %rdi
callq 0x7512
leaq 0x60(%rsp), %rdi
callq 0x7512
leaq 0x40(%rsp), %rdi
callq 0x7512
leaq 0x98(%rsp), %rdi
callq 0x3130
leaq 0xf8(%rsp), %rdi
callq 0x3230
leaq 0xb8(%rsp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x3490