// File: /workspace/github_c_makefile_star2_O0/sc932[P]ALE/src/ALEhelpers.c
// Function: importLibraryParameters
int importLibraryParameters(libraryParametersT *libParams, char paramFile[256]){
  FILE *in = fopen(paramFile, "r");
  int temp;
  if(in == NULL){
    printf("Could not open parameter file: %s\n", paramFile);
    libParams = NULL;
    return 0;
  }else{
    
    // read in the file the same way we outputed it
    char comments[256];
    int j;
    temp = fscanf(in, "%s", comments);
    for(j=0; j < MATE_ORIENTATION_MAX; j++) {
        temp = fscanf(in, "%lf", &libParams->mateParameters[j].insertLength);
        temp = fscanf(in, "%lf", &libParams->mateParameters[j].insertStd);
        temp = fscanf(in, "%lf", &libParams->mateParameters[j].libraryFraction);
        temp = fscanf(in, "%ld", &libParams->mateParameters[j].count);
        temp = fscanf(in, "%ld", &libParams->mateParameters[j].mapped);
        // placed is always calculated
        temp = fscanf(in, "%d", &libParams->mateParameters[j].isValid);

        // These are not stored, but calculated
        libParams->mateParameters[j].placed = 0;
        if (libParams->mateParameters[j].isValid && j <= MAPPED_PAIRED_ORIENTATION) {
        	libParams->mateParameters[j].zNormalizationInsert = zNormalizationInsertStd(libParams->mateParameters[j].insertStd);
        } else {
        	libParams->mateParameters[j].zNormalizationInsert = 1.0;
        }
    }
    temp = fscanf(in, "%ld", &libParams->avgReadSize);
    temp = fscanf(in, "%ld", &libParams->numReads);
    temp = fscanf(in, "%lf", &libParams->totalValidSingleFraction);
    temp = fscanf(in, "%lf", &libParams->totalValidMateFraction);
    temp = fscanf(in, "%lf", &libParams->totalChimerMateFraction);
    temp = fscanf(in, "%lf", &libParams->totalUnmappedFraction);
    temp = fscanf(in, "%d", &libParams->qOff);
    temp = fscanf(in, "%d", &libParams->isSortedByName);
    temp = fscanf(in, "%u", &libParams->primaryOrientation);
    fclose(in);
    printf("Read in library parameters.\n");
    return 1;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x24821(%rip), %rsi     # 0x3341f
callq 0x3520
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xec34
movq -0x18(%rbp), %rsi
leaq 0x230b7(%rip), %rdi     # 0x31cd0
movb $0x0, %al
callq 0x3200
movq $0x0, -0x10(%rbp)
movl $0x0, -0x4(%rbp)
jmp 0xef48
movq -0x20(%rbp), %rdi
leaq -0x130(%rbp), %rdx
leaq 0x1c3cb(%rip), %rsi     # 0x2b011
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movl $0x0, -0x134(%rbp)
cmpl $0xe, -0x134(%rbp)
jge 0xee0a
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x134(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rdx
leaq 0x2306f(%rip), %rsi     # 0x31cf3
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x134(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rdx
addq $0x8, %rdx
leaq 0x23044(%rip), %rsi     # 0x31cf3
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x134(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rdx
addq $0x18, %rdx
leaq 0x23019(%rip), %rsi     # 0x31cf3
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x134(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rdx
addq $0x20, %rdx
leaq 0x22ff2(%rip), %rsi     # 0x31cf7
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x134(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rdx
addq $0x28, %rdx
leaq 0x22fc7(%rip), %rsi     # 0x31cf7
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x134(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rdx
addq $0x38, %rdx
leaq 0x21734(%rip), %rsi     # 0x3048f
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movslq -0x134(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movslq -0x134(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
cmpl $0x0, 0x38(%rax)
je 0xedd5
cmpl $0x5, -0x134(%rbp)
ja 0xedd5
movq -0x10(%rbp), %rax
movslq -0x134(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
callq 0xeb70
movq -0x10(%rbp), %rax
movslq -0x134(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
jmp 0xedf4
movq -0x10(%rbp), %rax
movslq -0x134(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movsd 0x1cc51(%rip), %xmm0    # 0x2ba40
movsd %xmm0, 0x10(%rax)
jmp 0xedf6
movl -0x134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0xec5a
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x380, %rdx            # imm = 0x380
leaq 0x22ed7(%rip), %rsi     # 0x31cf7
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x388, %rdx            # imm = 0x388
leaq 0x22eb7(%rip), %rsi     # 0x31cf7
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x390, %rdx            # imm = 0x390
leaq 0x22e93(%rip), %rsi     # 0x31cf3
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x398, %rdx            # imm = 0x398
leaq 0x22e73(%rip), %rsi     # 0x31cf3
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x3a0, %rdx            # imm = 0x3A0
leaq 0x22e53(%rip), %rsi     # 0x31cf3
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x3a8, %rdx            # imm = 0x3A8
leaq 0x22e33(%rip), %rsi     # 0x31cf3
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x3b0, %rdx            # imm = 0x3B0
leaq 0x215af(%rip), %rsi     # 0x3048f
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x3b4, %rdx            # imm = 0x3B4
leaq 0x2158f(%rip), %rsi     # 0x3048f
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x3b8, %rdx            # imm = 0x3B8
leaq 0x22ddb(%rip), %rsi     # 0x31cfb
movb $0x0, %al
callq 0x30d0
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
callq 0x31c0
leaq 0x22dc4(%rip), %rdi     # 0x31cfe
movb $0x0, %al
callq 0x3200
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)