// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movl %r9d, %r14d
movl %r8d, %r15d
movq %rdx, -0x58(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdi, %rbx
leaq 0x3b86(%rip), %rsi      # 0x8254
movq %rcx, %r13
movq %rcx, %rdi
callq 0x2240
testq %rax, %rax
je 0x4821
movq %rax, %r12
movl %r15d, -0x30(%rbp)
leaq 0x3da0(%rip), %rsi      # 0x8490
leaq 0x3d9d(%rip), %rdx      # 0x8494
movq %rax, %rdi
xorl %eax, %eax
callq 0x22a0
leal -0x1(%r14), %eax
movl %eax, -0x3c(%rbp)
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq %r14, -0x50(%rbp)
cmpl $0x2, %r14d
movq -0x38(%rbp), %r15
jl 0x4748
movq -0x48(%rbp), %r14
shlq $0x5, %r14
xorl %r13d, %r13d
movq (%r15), %rax
movq (%rax,%r13), %rdx
movq %r12, %rdi
leaq 0x3d58(%rip), %rsi      # 0x8490
xorl %eax, %eax
callq 0x22a0
addq $0x20, %r13
cmpq %r13, %r14
jne 0x4727
movslq -0x3c(%rbp), %rcx
movq (%r15), %rax
movq %rcx, -0x38(%rbp)
shlq $0x5, %rcx
movq (%rax,%rcx), %rdx
leaq 0x3d3a(%rip), %rsi      # 0x849c
movq %r12, %rdi
xorl %eax, %eax
callq 0x22a0
movl -0x30(%rbp), %eax
testl %eax, %eax
jle 0x4815
movl %eax, %eax
movq %rax, -0x30(%rbp)
xorl %r14d, %r14d
movq -0x58(%rbp), %rax
movq (%rax,%r14,8), %rdx
movq %r12, %rdi
leaq 0x3cfe(%rip), %rsi      # 0x8490
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, -0x50(%rbp)
movq %r12, %r15
movq -0x48(%rbp), %r12
jl 0x47d9
xorl %r13d, %r13d
movq (%rbx,%r13,8), %rax
movsd (%rax,%r14,8), %xmm0
callq 0x21b0
addsd 0x3cb0(%rip), %xmm0     # 0x8470
movq %r15, %rdi
leaq 0x3cd6(%rip), %rsi      # 0x84a0
movb $0x1, %al
callq 0x22a0
incq %r13
cmpq %r13, %r12
jne 0x47a9
movq -0x38(%rbp), %rax
movq (%rbx,%rax,8), %rax
movsd (%rax,%r14,8), %xmm0
callq 0x21b0
addsd 0x3c7c(%rip), %xmm0     # 0x8470
movq %r15, %rdi
leaq 0x3df4(%rip), %rsi      # 0x85f2
movb $0x1, %al
callq 0x22a0
incq %r14
cmpq -0x30(%rbp), %r14
movq %r15, %r12
jne 0x4780
movq %r12, %rdi
callq 0x21f0
xorl %eax, %eax
jmp 0x48a0
movq 0x77b0(%rip), %rbx      # 0xbfd8
leaq 0x3c76(%rip), %rsi      # 0x84a5
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2230
testq %r13, %r13
je 0x485d
movq %r13, %rdi
callq 0x2100
movq 0x7788(%rip), %rdi      # 0xbfd8
movq %r13, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x4874
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq