// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %r15
movl %esi, (%rdi)
movl %edx, 0x4(%rdi)
movsd %xmm0, 0x8(%rdi)
movsd %xmm1, 0x10(%rdi)
movl %ecx, 0x18(%rdi)
leal (%rsi,%rsi), %ecx
leal -0x1(,%rsi,2), %eax
leal 0x1e(,%rsi,2), %r14d
testl %eax, %eax
cmovnsl %eax, %r14d
sarl $0x5, %r14d
leal 0x1f(,%rsi,2), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movl %r8d, 0x1c(%rdi)
andl $-0x20, %eax
subl %eax, %ecx
xorl %eax, %eax
movl %ecx, %esi
negl %esi
sbbl %eax, %eax
shll %cl, %eax
leal 0x1(%r14), %ebx
movl %ebx, 0x20(%rdi)
notl %eax
movl %eax, 0x24(%rdi)
movl %edx, 0x28(%rdi)
movl %ebx, 0x2c(%rdi)
movl %r8d, 0x30(%rdi)
movl %edx, %r12d
movl %edx, %eax
movq %r8, %rbp
imull %r8d, %eax
imull %ebx, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x2030
movq %rax, 0x28(%rsp)
movq %rax, 0x38(%r15)
movl %ebx, 0x40(%r15)
movslq %r14d, %rax
leaq 0x4(,%rax,4), %rdi
callq 0x2030
movq %rax, 0x48(%r15)
movl %r12d, %r14d
movl %r12d, 0x50(%r15)
movslq %r12d, %r12
leaq (,%r12,4), %rdi
callq 0x2030
movq %rax, %r13
movq %rax, 0x58(%r15)
movl %r14d, 0x60(%r15)
shlq $0x3, %r12
movq %r12, %rdi
callq 0x2030
movq %rax, 0x40(%rsp)
movq %rax, 0x68(%r15)
testl %r14d, %r14d
jle 0x3eb3
movl 0x20(%r15), %eax
movq %rax, 0x20(%rsp)
movl %r14d, %edx
movl 0x30(%r15), %r14d
movq %rbp, %rcx
leal -0x1(%rbp), %eax
leaq (,%rax,4), %rsi
movq %rsi, 0x50(%rsp)
movslq %ecx, %r12
cltq
movslq %ebx, %rsi
movl %edx, %ecx
movq %rcx, 0x30(%rsp)
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x10(%rsp)
movl 0x2c(%r15), %eax
imull %r14d, %eax
movl %eax, 0x1c(%rsp)
imulq %r12, %rsi
shlq $0x2, %rsi
movq %rsi, 0x38(%rsp)
shlq $0x2, %r12
movq $0x0, 0x8(%rsp)
xorl %edx, %edx
xorl %eax, %eax
testb $0x1, %dl
sete %al
leaq 0x127b(%rip), %rcx      # 0x50a0
movsd (%rcx,%rax,8), %xmm0
movq 0x40(%rsp), %rax
movq %rdx, 0x48(%rsp)
movsd %xmm0, (%rax,%rdx,8)
cmpl $0x0, 0x20(%rsp)
jle 0x3e83
movq 0x20(%rsp), %r15
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rax
movl %eax, %r13d
cmpl $0x2, %ebp
jl 0x3e72
movslq %r13d, %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,4), %rdi
movl $0xff, %esi
movq 0x50(%rsp), %rdx
callq 0x2110
movl $0x0, (%rbx)
addl %r14d, %r13d
addq %r12, %rbx
decq %r15
jne 0x3e52
movq 0x48(%rsp), %rdx
incq %rdx
movq 0x8(%rsp), %rax
addl 0x1c(%rsp), %eax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
addq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq 0x30(%rsp), %rdx
jne 0x3e16
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r13, %rdi
callq 0x2230
jmp 0x3ed2
movq %rax, %rbx
movq 0x48(%r15), %rdi
testq %rdi, %rdi
je 0x3ee5
callq 0x2230
jmp 0x3ee5
movq %rax, %rbx
movq 0x38(%r15), %rdi
testq %rdi, %rdi
je 0x3ef3
callq 0x2230
movq %rbx, %rdi
callq 0x22f0
nop