// File: myudelson[P]hmm-scalable/FitBitSt.cpp
// Function: FitBitSt::projectToSimplex(bool, signed char*)
void FitBitSt::projectToSimplex(bool hasNon01Constraints, NPAR* condition) {
    if(this->sclsmplx_n<=0 || this->sclsmplx_sizes==NULL || this->sclsmplx_offsets==NULL || this->sclsmplx_blocks==NULL) {
        fprintf(stderr,"Error, projection to simplex affordances were nnot created.\n");
        exit(1);
    };
    if(hasNon01Constraints) {
        for(NCAT i=0; i<this->sclsmplx_n; i++) {
//            if(this->sclsmplx_blocks[i]<0 || this->sclsmplx_blocks[i]>this->nK) {
//                int a = 0;
//            } // DEBUG
            if( condition[ this->sclsmplx_blocks[i] ]>0 )
                projectsimplexbounded(&this->PARAM[ this->sclsmplx_offsets[i] ],
                                      &this->task->param_values_lb[ this->sclsmplx_bound_offsets[i] ],
                                      &this->task->param_values_ub[ this->sclsmplx_bound_offsets[i] ],
                                      this->sclsmplx_sizes[i]);
        }
    } else {
        for(NCAT i=0; i<this->sclsmplx_n; i++) {
//            if(this->sclsmplx_blocks[i]<0 || this->sclsmplx_blocks[i]>this->nK) {
//                int a = 0;
//            } // DEBUG
            if( condition[ this->sclsmplx_blocks[i] ] )
                projectsimplex(&this->PARAM[ this->sclsmplx_offsets[i] ], this->sclsmplx_sizes[i]);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, 0xc0(%rax)
jle 0xb703
movq -0x28(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
je 0xb703
movq -0x28(%rbp), %rax
cmpq $0x0, 0x98(%rax)
je 0xb703
movq -0x28(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
jne 0xb725
movq 0x168ce(%rip), %rax     # 0x21fd8
movq (%rax), %rdi
leaq 0x10777(%rip), %rsi     # 0x1be8b
movb $0x0, %al
callq 0x33c0
movl $0x1, %edi
callq 0x3330
testb $0x1, -0x9(%rbp)
je 0xb7ef
movl $0x0, -0x1c(%rbp)
movq -0x28(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0xc0(%rcx), %eax
jge 0xb7ed
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0xb0(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jle 0xb7dd
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x98(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x3, %rcx
addq %rcx, %rdi
movq 0x88(%rax), %rcx
movq 0x10(%rcx), %rsi
movq 0xa0(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x3, %rcx
addq %rcx, %rsi
movq 0x88(%rax), %rcx
movq 0x18(%rcx), %rdx
movq 0xa0(%rax), %rcx
movslq -0x1c(%rbp), %r8
movslq (%rcx,%r8,4), %rcx
shlq $0x3, %rcx
addq %rcx, %rdx
movq 0xa8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
callq 0x6380
jmp 0xb7df
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb736
jmp 0xb863
movl $0x0, -0x20(%rbp)
movq -0x28(%rbp), %rcx
movl -0x20(%rbp), %eax
cmpl 0xc0(%rcx), %eax
jge 0xb861
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0xb0(%rcx), %rcx
movslq -0x20(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xb854
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x98(%rax), %rcx
movslq -0x20(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x3, %rcx
addq %rcx, %rdi
movq 0xa8(%rax), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x5560
jmp 0xb856
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xb7f6
jmp 0xb863
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)