// File: 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 %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xda6e(%rip), %rsi      # 0x1c23c
callq 0x3310
movq %rax, -0x20(%rbp)
movb $0x3, -0x11(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x11(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x3510
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movl 0x8fc(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movl 0x914(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movsbl 0x901(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movl 0x904(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movl 0x90c(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movl 0x908(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movsbl 0x910(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3510
movq -0x8(%rbp), %rax
movb 0x920(%rax), %al
movb %al, -0x11(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x11(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x3510
movq -0x8(%rbp), %rax
movq 0x880(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xf750
movq -0x8(%rbp), %rax
movq 0x890(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xf780
movq -0x8(%rbp), %rax
movq 0x8b8(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xf780
movq -0x8(%rbp), %rax
movsbl 0x920(%rax), %eax
cmpl $0x0, %eax
jne 0xe9be
movq -0x8(%rbp), %rax
movq 0x898(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xf780
jmp 0xea18
movq -0x8(%rbp), %rax
movq 0x8a0(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8fc(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xf780
movq -0x8(%rbp), %rax
movq 0x8a8(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xf780
movq -0x8(%rbp), %rax
movq 0x8b0(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xf780
movq -0x8(%rbp), %rax
movsbl 0x910(%rax), %eax
cmpl $0x1, %eax
jle 0xea7a
movq -0x8(%rbp), %rax
movsbl 0x920(%rax), %eax
cmpl $0x0, %eax
jne 0xea4a
movq -0x8(%rbp), %rax
movl 0x8f8(%rax), %eax
movl %eax, -0xd4(%rbp)
jmp 0xea5a
movq -0x8(%rbp), %rax
movl 0x8fc(%rax), %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x8c0(%rax), %rdi
movl -0x24(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0xf750
leaq -0x30(%rbp), %rdi
callq 0xf7b0
movq -0x8(%rbp), %rax
movq 0x930(%rax), %rdi
callq 0xf7d0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x930(%rax), %rdi
callq 0xf830
movq %rax, -0x40(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xf800
testb $0x1, %al
jne 0xeac6
jmp 0xeb34
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf860
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x3110
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0xb8e0
jmp 0xeb06
leaq -0x60(%rbp), %rdi
callq 0x3160
leaq -0x30(%rbp), %rdi
callq 0xf880
jmp 0xea9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3160
jmp 0xeccd
movq -0x8(%rbp), %rax
movq 0x950(%rax), %rdi
callq 0xf7d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x950(%rax), %rdi
callq 0xf830
movq %rax, -0x80(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xf800
testb $0x1, %al
jne 0xeb77
jmp 0xebf1
movq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf860
movq %rax, %rsi
addq $0x8, %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x3110
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0xb8e0
jmp 0xebba
leaq -0xa0(%rbp), %rdi
callq 0x3160
leaq -0x30(%rbp), %rdi
callq 0xf880
jmp 0xeb50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3160
jmp 0xeccd
movq -0x8(%rbp), %rax
movq 0x940(%rax), %rdi
callq 0xf7d0
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x940(%rax), %rdi
callq 0xf830
movq %rax, -0xb0(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xf800
testb $0x1, %al
jne 0xec40
jmp 0xecb7
movq -0x20(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf860
movq %rax, %rsi
addq $0x8, %rsi
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x3110
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
callq 0xb8e0
jmp 0xec83
leaq -0xd0(%rbp), %rdi
callq 0x3160
leaq -0x30(%rbp), %rdi
callq 0xf880
jmp 0xec13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x3160
jmp 0xeccd
movq -0x20(%rbp), %rdi
callq 0x3260
movb $0x1, %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)