// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %r13d
movq %r8, -0x38(%rbp)
movq %rcx, %r14
movq %rdx, -0x48(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdi, %r15
leaq 0x3198(%rip), %rsi      # 0x7254
movq %rcx, %rdi
callq 0x2210
testq %rax, %rax
je 0x4200
movq %rax, %r12
leaq 0x3399(%rip), %rsi      # 0x7470
leaq 0x3396(%rip), %rdx      # 0x7474
movq %rax, %rdi
xorl %eax, %eax
callq 0x2290
decl %r13d
testl %r13d, %r13d
movl $0x0, %ebx
movl %r13d, -0x3c(%rbp)
cmovgl %r13d, %ebx
movq %rbx, %r14
shlq $0x5, %r14
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x412c
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq (%rax,%r13), %rdx
movq %r12, %rdi
leaq 0x3351(%rip), %rsi      # 0x7470
xorl %eax, %eax
callq 0x2290
addq $0x20, %r13
jmp 0x4105
movslq -0x3c(%rbp), %rcx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rcx, -0x30(%rbp)
shlq $0x5, %rcx
movq (%rax,%rcx), %rdx
leaq 0x3332(%rip), %rsi      # 0x747c
xorl %r14d, %r14d
movq %r12, %rdi
xorl %eax, %eax
callq 0x2290
movq -0x38(%rbp), %rax
testl %eax, %eax
cmovlel %r14d, %eax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
cmpq -0x38(%rbp), %r14
je 0x41f4
movq -0x48(%rbp), %rax
movq (%rax,%r14,8), %rdx
movq %r12, %rdi
leaq 0x32ec(%rip), %rsi      # 0x7470
xorl %eax, %eax
callq 0x2290
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x41c0
movq (%r15,%r13,8), %rax
movsd (%rax,%r14,8), %xmm0
callq 0x21a0
addsd 0x32a6(%rip), %xmm0     # 0x7450
movq %r12, %rdi
leaq 0x32cc(%rip), %rsi      # 0x7480
movb $0x1, %al
callq 0x2290
incq %r13
jmp 0x418e
movq -0x30(%rbp), %rax
movq (%r15,%rax,8), %rax
movsd (%rax,%r14,8), %xmm0
callq 0x21a0
addsd 0x3275(%rip), %xmm0     # 0x7450
movq %r12, %rdi
leaq 0x33ed(%rip), %rsi      # 0x75d2
movb $0x1, %al
callq 0x2290
incq %r14
jmp 0x4168
movq %r12, %rdi
callq 0x21e0
xorl %eax, %eax
jmp 0x4229
movq 0x6dd1(%rip), %rdi      # 0xafd8
leaq 0x3277(%rip), %rsi      # 0x7485
callq 0x21d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2120
pushq $0x1
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq