// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/InputUtilSt.cpp
// Function: InputUtilSt::toBin(task*, char const*)
bool InputUtilSt::toBin(struct task *task, const char *fn) {
    char c;
    NDAT i;
    FILE *fid = fopen(fn,"wb");

    // version
    c = bin_input_file_verstion;
    fwrite (&c , sizeof(char), 1, fid);
    
    // N
    i = task->N;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // Nst
    i = task->Nst;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // N_null
    i = task->N_null;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // nO
    i = task->nO;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // nG
    i = task->nG;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // nI
    i = task->nI;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // nK
    i = task->nK;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // nZ
    i = task->nZ;
    fwrite (&i , sizeof(NDAT), 1, fid);
    
    // multiskill
    c = task->multiskill;
    fwrite (&c , sizeof(char), 1, fid);
    
//    NDAT nwrit;
    // dat_obs
    /*nwrit = */StripedArray<NPAR>::arrayToBinFile(task->dat_obs, task->N, fid);//task->dat_obs->toBinFile(fid);
    // dat_group
    /*nwrit = */StripedArray<NCAT>::arrayToBinFile(task->dat_group, task->N, fid);//->toBinFile(fid);
    // dat_item
    /*nwrit = */StripedArray<NCAT>::arrayToBinFile(task->dat_item, task->N, fid);//->toBinFile(fid);
    // dat_skill
    if(task->multiskill == 0)
    /*nwrit = */StripedArray<NCAT>::arrayToBinFile(task->dat_skill, task->N, fid);//->toBinFile(fid);
    else {
        //        /*nwrit = */writeMultiSkill(fid, param);
        /*nwrit = */StripedArray<NCAT>::arrayToBinFile(task->dat_skill_stacked, task->Nst, fid);//->toBinFile(fid);
        /*nwrit = */StripedArray<NCAT>::arrayToBinFile(task->dat_skill_rcount , task->N,        fid);//->toBinFile(fid);
        /*nwrit = */StripedArray<NCAT>::arrayToBinFile(task->dat_skill_rix    , task->N,        fid);//->toBinFile(fid);
    }
    // dat_slices, only of nZ > 1
    if(task->nZ > 1) {
        NDAT szZ = (task->multiskill == 0)?task->N:task->Nst;
        StripedArray<NPAR>::arrayToBinFile(task->dat_slice, szZ, fid);
    }

    map<NCAT,string>::iterator it;
    // voc_group
    for (it = task->map_group_bwd->begin(); it != task->map_group_bwd->end(); ++it) {
        writeString(fid, it->second);
    }

    // voc_skill
    for (it = task->map_skill_bwd->begin(); it != task->map_skill_bwd->end(); ++it) {
        writeString(fid, it->second);
    }
    
    // voc_item
    for (it =  task->map_step_bwd->begin(); it != task->map_step_bwd->end(); ++it) {
        writeString(fid, it->second);
    }
    
    
    fclose(fid);
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x8084(%rip), %rsi      # 0x12124
movq %rax, %rdi
callq 0x2230
movq %rax, %r14
movl $0x3, %edi
movq %rax, %rsi
callq 0x2280
movl 0x8f8(%rbx), %eax
leaq 0xc(%rsp), %r15
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movl 0x8fc(%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movl 0x914(%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movsbl 0x901(%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movl 0x904(%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movl 0x90c(%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movl 0x908(%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movsbl 0x910(%rbx), %eax
movl %eax, (%r15)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x23d0
movsbl 0x920(%rbx), %edi
movq %r14, %rsi
callq 0x2280
movq 0x880(%rbx), %rdi
movslq 0x8f8(%rbx), %rdx
movl $0x1, %esi
movq %r14, %rcx
callq 0x23d0
movq 0x890(%rbx), %rdi
movslq 0x8f8(%rbx), %rdx
movl $0x4, %esi
movq %r14, %rcx
callq 0x23d0
movq 0x8b8(%rbx), %rdi
movslq 0x8f8(%rbx), %rdx
movl $0x4, %esi
movq %r14, %rcx
callq 0x23d0
cmpb $0x0, 0x920(%rbx)
je 0xa255
movq 0x8a0(%rbx), %rdi
movslq 0x8fc(%rbx), %rdx
movl $0x4, %esi
movq %r14, %rcx
callq 0x23d0
movq 0x8a8(%rbx), %rdi
movslq 0x8f8(%rbx), %rdx
movl $0x4, %esi
movq %r14, %rcx
callq 0x23d0
movl $0x8b0, %eax            # imm = 0x8B0
jmp 0xa25a
movl $0x898, %eax            # imm = 0x898
movq (%rbx,%rax), %rdi
movslq 0x8f8(%rbx), %rdx
movl $0x4, %esi
movq %r14, %rcx
callq 0x23d0
cmpb $0x2, 0x910(%rbx)
jl 0xa2a3
xorl %eax, %eax
cmpb $0x0, 0x920(%rbx)
setne %al
movslq 0x8f8(%rbx,%rax,4), %rdx
movq 0x8c0(%rbx), %rdi
movl $0x1, %esi
movq %r14, %rcx
callq 0x23d0
movq 0x930(%rbx), %rax
movq 0x18(%rax), %r15
addq $0x8, %rax
cmpq %rax, %r15
je 0xa316
leaq 0x60(%rsp), %r13
leaq 0x50(%rsp), %r12
movq %r13, 0x50(%rsp)
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x7858
movq %r14, %rdi
movq %r12, %rsi
callq 0x81a0
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0xa2fb
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %r15, %rdi
callq 0x2130
movq %rax, %r15
movq 0x930(%rbx), %rax
addq $0x8, %rax
cmpq %rax, %r15
jne 0xa2c1
movq 0x950(%rbx), %rax
movq 0x18(%rax), %r15
addq $0x8, %rax
cmpq %rax, %r15
je 0xa389
leaq 0x40(%rsp), %r13
leaq 0x30(%rsp), %r12
movq %r13, 0x30(%rsp)
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x7858
movq %r14, %rdi
movq %r12, %rsi
callq 0x81a0
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0xa36e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %r15, %rdi
callq 0x2130
movq %rax, %r15
movq 0x950(%rbx), %rax
addq $0x8, %rax
cmpq %rax, %r15
jne 0xa334
movq 0x940(%rbx), %rax
movq 0x18(%rax), %r15
addq $0x8, %rax
cmpq %rax, %r15
je 0xa3fc
leaq 0x20(%rsp), %r13
leaq 0x10(%rsp), %r12
movq %r13, 0x10(%rsp)
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x7858
movq %r14, %rdi
movq %r12, %rsi
callq 0x81a0
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0xa3e1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %r15, %rdi
callq 0x2130
movq %rax, %r15
movq 0x940(%rbx), %rax
addq $0x8, %rax
cmpq %rax, %r15
jne 0xa3a7
movq %r14, %rdi
callq 0x21b0
movb $0x1, %al
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq