// File: /workspace/github_c_makefile_star2_O0/sc932[P]ALE/src/ALEhelpers.c
// Function: calculateContigGCcont
unsigned char *calculateContigGCcont(contig_t *contig, int windowSize) {
	int j, baseGC;
	int *GCpast = malloc(sizeof(int) * windowSize);
	unsigned char *GCcont = (unsigned char*) malloc(sizeof(unsigned char) * contig->seqLen);
	if (contig->seqLen < 2 * windowSize) {
		// contig is too small to estimate per-base windowing
		baseGC = getGCtotal(contig->seq, contig->seqLen);
		baseGC = floor(100.0*(double)baseGC / (double) contig->seqLen);
		for(j=0; j < contig->seqLen ; j++) {
			GCcont[j] = baseGC;
		}
	} else {
		baseGC = getGCtotal(contig->seq, windowSize);
		GCpast[0] = baseGC;
		for(j = 0; j < windowSize - 1; j++){
			GCcont[j] = floor(100.0*(double)baseGC/(double)((j+1)*windowSize));
			if (GCcont[j] > 100)
				printf("GC correction out of range %d %s %d len %d '%c'\n", baseGC, contig->name, j, contig->seqLen, contig->seq[j]);
			GCpast[(j+1)%windowSize] = GCpast[j%windowSize];
			if(isGC(contig->seq[j])){
				GCpast[(j+1)%windowSize]--;
			}
			if(isGC(contig->seq[j+windowSize])){
				GCpast[(j+1)%windowSize]++;
			}
			baseGC += GCpast[(j+1)%windowSize];
		}
		for(j = windowSize - 1; j < contig->seqLen - windowSize; j++){
			GCcont[j] = floor(100.0*(double)baseGC/(double)(windowSize*windowSize));
			if (GCcont[j] > 100)
				printf("GC correction out of range %d %s %d len %d '%c'\n", baseGC, contig->name, j, contig->seqLen, contig->seq[j]);
			baseGC -= GCpast[(j+1)%windowSize];
			GCpast[(j+1)%windowSize] = GCpast[j%windowSize];
			if(isGC(contig->seq[j])){
				GCpast[(j+1)%windowSize]--;
			}
			if(isGC(contig->seq[j+windowSize])) {
				GCpast[(j+1)%windowSize]++;
			}
			baseGC += GCpast[(j+1)%windowSize];
		}
		for(j = contig->seqLen - windowSize; j < contig->seqLen; j++){
			GCcont[j] = floor(100.0*(double)baseGC/(double)((contig->seqLen - j)*windowSize));
			if (GCcont[j] > 100)
				printf("GC correction out of range %d %s %d len %d '%c'\n", baseGC, contig->name, j, contig->seqLen, contig->seq[j]);
			baseGC -= GCpast[(j+1)%windowSize];
		}
	}
	free(GCpast);
	return GCcont;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3420
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movslq 0x8(%rax), %rdi
shlq $0x0, %rdi
callq 0x3420
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl -0xc(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0xd8cc
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
callq 0xcef0
movl %eax, -0x14(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm1
movsd 0x23a8c(%rip), %xmm0    # 0x31308
mulsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0x8(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3560
cvttsd2si %xmm0, %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd8c7
movl -0x14(%rbp), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xd8a0
jmp 0xdcf8
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0xc(%rbp), %esi
callq 0xcef0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xda69
cvtsi2sdl -0x14(%rbp), %xmm0
movsd 0x239fb(%rip), %xmm1    # 0x31308
mulsd %xmm1, %xmm0
movl -0x10(%rbp), %eax
incl %eax
movl -0xc(%rbp), %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x3560
cvttsd2si %xmm0, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x64, %eax
jle 0xd97f
movl -0x14(%rbp), %esi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %r8d
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rdi
movsbl (%rax,%rdi), %r9d
leaq 0x23f6a(%rip), %rdi     # 0x318e2
movb $0x0, %al
callq 0x3200
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x10(%rbp), %eax
cltd
idivl -0xc(%rbp)
movq -0x40(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x38(%rbp), %rax
movl %edx, %ecx
movl -0x2c(%rbp), %edx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0xcea0
cmpl $0x0, %eax
je 0xd9f8
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x48(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x10(%rbp), %ecx
addl -0xc(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edi
callq 0xcea0
cmpl $0x0, %eax
je 0xda39
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x50(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x58(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xd8ef
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
subl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jge 0xdc1b
cvtsi2sdl -0x14(%rbp), %xmm0
movsd 0x23874(%rip), %xmm1    # 0x31308
mulsd %xmm1, %xmm0
movl -0xc(%rbp), %eax
imull %eax, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x3560
cvttsd2si %xmm0, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x64, %eax
jle 0xdb01
movl -0x14(%rbp), %esi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %r8d
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rdi
movsbl (%rax,%rdi), %r9d
leaq 0x23de8(%rip), %rdi     # 0x318e2
movb $0x0, %al
callq 0x3200
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x78(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x10(%rbp), %eax
cltd
idivl -0xc(%rbp)
movq -0x70(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x68(%rbp), %rax
movl %edx, %ecx
movl -0x5c(%rbp), %edx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0xcea0
cmpl $0x0, %eax
je 0xdb9e
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x80(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x10(%rbp), %ecx
addl -0xc(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edi
callq 0xcea0
cmpl $0x0, %eax
je 0xdbe5
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x88(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x90(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xda72
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xdcf6
cvtsi2sdl -0x14(%rbp), %xmm0
movsd 0x236c3(%rip), %xmm1    # 0x31308
mulsd %xmm1, %xmm0
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl -0x10(%rbp), %ecx
subl %ecx, %eax
movl -0xc(%rbp), %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x3560
cvttsd2si %xmm0, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x64, %eax
jle 0xdcbe
movl -0x14(%rbp), %esi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %r8d
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rdi
movsbl (%rax,%rdi), %r9d
leaq 0x23c2b(%rip), %rdi     # 0x318e2
movb $0x0, %al
callq 0x3200
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0xc(%rbp)
movq -0x98(%rbp), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xdc28
jmp 0xdcf8
movq -0x20(%rbp), %rdi
callq 0x3050
movq -0x28(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nop