// File: WeiqiangZhou[P]BIRD/source/predict_function.cpp
// Function: WriteExpr(double**, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, char**, char*, int, int)
int WriteExpr(double **data_out, std::vector<std::string> outname, char **lib_TC, char *outfile, int Length, int sample_size)
{
    FILE * pFile;
    
    pFile = fopen(outfile, "w");
    if (pFile != NULL)
    {
        fprintf(pFile, "%s\t", "gene_id");
        
        for (int i = 0; i < sample_size-1; i++)
        {
            fprintf(pFile, "%s\t", outname[i].c_str());
        }
        
        fprintf(pFile, "%s\n", outname[sample_size-1].c_str());
        
        for (int i = 0; i < Length; i++)
        {
            fprintf(pFile, "%s\t", lib_TC[i]);
            
            for (int j = 0; j < sample_size-1; j++)
            {
                fprintf(pFile, "%lf\t", pow(2, data_out[j][i]) - 1);
            }
            
            fprintf(pFile, "%lf\n", pow(2, data_out[sample_size-1][i]) - 1);
            
        }
        fclose(pFile);
    }
    else
    {
        std::cout << "Error! Cannot write file " << outfile << std::endl;
        return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rsi, -0x50(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x8385(%rip), %rsi      # 0xf2d4
callq 0x2220
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x70fc
movq -0x38(%rbp), %rdi
leaq 0x856e(%rip), %rsi      # 0xf4dc
leaq 0x856b(%rip), %rdx      # 0xf4e0
movb $0x0, %al
callq 0x22d0
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6fcd
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movslq -0x3c(%rbp), %rsi
callq 0x9950
movq %rax, %rdi
callq 0x20d0
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0x8521(%rip), %rsi      # 0xf4dc
movb $0x0, %al
callq 0x22d0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6f83
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x30(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x9950
movq %rax, %rdi
callq 0x20d0
movq -0x60(%rbp), %rdi
movq %rax, %rdx
leaq 0x84eb(%rip), %rsi      # 0xf4e8
movb $0x0, %al
callq 0x22d0
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x70f1
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x84ae(%rip), %rsi      # 0xf4dc
movb $0x0, %al
callq 0x22d0
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x7099
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movl $0x2, %edi
callq 0x9a10
movq -0x68(%rbp), %rdi
movsd 0x7f8c(%rip), %xmm1     # 0xf008
subsd %xmm1, %xmm0
leaq 0x8465(%rip), %rsi      # 0xf4ec
movb $0x1, %al
callq 0x22d0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x703c
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movl $0x2, %edi
callq 0x9a10
movq -0x70(%rbp), %rdi
movsd 0x7f37(%rip), %xmm1     # 0xf008
subsd %xmm1, %xmm0
leaq 0x8562(%rip), %rsi      # 0xf63e
movb $0x1, %al
callq 0x22d0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x700b
movq -0x38(%rbp), %rdi
callq 0x21d0
jmp 0x7133
movq 0xeed5(%rip), %rdi      # 0x15fd8
leaq 0x83e7(%rip), %rsi      # 0xf4f1
callq 0x21c0
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x21c0
movq %rax, %rdi
movq 0xee9b(%rip), %rsi      # 0x15fc0
callq 0x2200
movl $0x1, -0x4(%rbp)
jmp 0x713a
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)