// File: /workspace/github_cpp_makefile_star2_O3/adrianphoulady[P]weighted-tsetlin-machine-cpp/./weightm.h
// Function: weightm::weightm(int, int, double, double, int, int)
weightm(int features, int clauses, double p, double gamma, int threshold, int states = 8)
    : features{features},
      clauses{clauses},
      p{p},
      gamma{gamma},
      threshold{threshold},
      states{states},
      literals{(2 * features - 1) / word_bits + 1},
      actmask{~((bool) (2 * features % word_bits) * ~((word) 0) << 2 * features % word_bits)},
      state{clauses, literals, states},
      lmask{literals},
      clause{clauses},
      weight{clauses} {
        for (int c = 0; c < clauses; ++c) {
            // even clauses are positive and and odds are negative
            weight(c) = c & 1? -1: +1;
            // initialize all the states to 2^states - 1
            for (int l = 0; l < literals; ++l) {
                for (int b = 0; b < states - 1; ++b)
                    state(c, l, b) = ~((word) 0);
                state(c, l, states - 1) = 0;
            }
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %ebx
movq %rdi, %r12
movl %esi, (%rdi)
movl %edx, 0x4(%rdi)
movsd %xmm0, 0x8(%rdi)
movsd %xmm1, 0x10(%rdi)
movl %ecx, 0x18(%rdi)
movl %r8d, 0x1c(%rdi)
leal (%rsi,%rsi), %ecx
leal -0x1(,%rsi,2), %eax
leal 0x1e(,%rsi,2), %edi
testl %eax, %eax
cmovnsl %eax, %edi
sarl $0x5, %edi
movq %rsi, 0x48(%rsp)
leal 0x1f(,%rsi,2), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movslq %edi, %r15
andl $-0x20, %eax
subl %eax, %ecx
xorl %eax, %eax
movl %ecx, %esi
negl %esi
sbbl %eax, %eax
shll %cl, %eax
leal 0x1(%r15), %ebp
movl %ebp, 0x20(%r12)
notl %eax
movl %eax, 0x24(%r12)
movl %edx, 0x28(%r12)
movl %ebp, 0x2c(%r12)
movl %r8d, 0x30(%r12)
movl %edx, %r13d
movl %edx, %eax
imull %r8d, %eax
imull %ebp, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x2030
movq %rax, 0x20(%rsp)
movq %rax, 0x38(%r12)
movl %ebp, 0x40(%r12)
movq %r15, %r14
leaq 0x4(,%r15,4), %rdi
callq 0x2030
movq %rax, %r15
movq %rax, 0x48(%r12)
movl %r13d, %ebp
movl %r13d, 0x50(%r12)
movslq %r13d, %r13
leaq (,%r13,4), %rdi
callq 0x2030
movq %rax, %r15
movq %rax, 0x58(%r12)
movl %ebp, 0x60(%r12)
shlq $0x3, %r13
movq %r13, %rdi
callq 0x2030
movq %rax, 0x68(%r12)
testl %ebp, %ebp
jle 0x3f1a
movq %r14, %rcx
incq %rcx
leal -0x1(%rbx), %edx
leaq (,%rdx,4), %rsi
movq %rsi, 0x50(%rsp)
movslq %ebx, %r14
movslq %edx, %rsi
movl %ebp, %edx
movq %rdx, 0x30(%rsp)
movl %ecx, %edx
movq %rdx, 0x28(%rsp)
movq 0x20(%rsp), %rdx
leaq (%rdx,%rsi,4), %rdx
movq %rdx, 0x10(%rsp)
movl %ebx, %edx
imull %ecx, %edx
movl %edx, 0x1c(%rsp)
imulq %r14, %rcx
shlq $0x2, %rcx
movq %rcx, 0x40(%rsp)
shlq $0x2, %r14
movq $0x0, 0x8(%rsp)
xorl %r15d, %r15d
movq %rax, 0x38(%rsp)
movl %r15d, %ecx
andl $0x1, %ecx
negl %ecx
orl $0x1, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, (%rax,%r15,8)
cmpl $-0xf, 0x48(%rsp)
jl 0x3eea
movq 0x28(%rsp), %r13
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rax
movl %eax, %r12d
cmpl $0x2, %ebx
jl 0x3ed8
movslq %r12d, %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,4), %rdi
movl $0xff, %esi
movq 0x50(%rsp), %rdx
callq 0x2110
movl $0x0, (%rbp)
addl %ebx, %r12d
addq %r14, %rbp
decq %r13
jne 0x3eb8
incq %r15
movq 0x8(%rsp), %rax
addl 0x1c(%rsp), %eax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq 0x30(%rsp), %r15
movq 0x38(%rsp), %rax
jne 0x3e87
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0x2230
movq 0x48(%r12), %r15
testq %r15, %r15
jne 0x3f43
jmp 0x3f50
movq %rax, %rbx
movq %r15, %rdi
callq 0x2230
jmp 0x3f50
movq %rax, %rbx
movq 0x38(%r12), %rdi
testq %rdi, %rdi
je 0x3f5f
callq 0x2230
movq %rbx, %rdi
callq 0x22e0
nop