// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/eps.c
// Function: difference_plot
void difference_plot(char** files, int filecount)
{
 int i, base, barwidth, bargap;
 int counts[2];
 char st[10];
 double** observations, *difference, max = 0, min = 0;
 FILE* outfile;
 observations = read_observations_for_two_file(files, counts);
 if (counts[0] != counts[1])
   return;
 difference = safemalloc(counts[0] * sizeof(double), "difference_plot", 7);
 for (i = 0; i < counts[0]; i++)
  {
   difference[i] = observations[0][i] - observations[1][i];
   if (difference[i] > max)
     max = difference[i];
   if (difference[i] < min)
     min = difference[i];
  }
 free_2d((void**) observations, 2);
 outfile = fopen("image.eps", "w");
 if (!outfile)
   return; 
 write_image_header(outfile, 2 * MARGIN + epsaxis, 2 * MARGIN + epsaxis);
 base = MARGIN + epsaxis * (-min / (max - min));
 barwidth = 0.8 * (epsaxis / counts[0]);
 bargap = 0.2 * (epsaxis / counts[0]);
 write_line(outfile, MARGIN, MARGIN, MARGIN, epsaxis + MARGIN);
 write_line(outfile, MARGIN, base, epsaxis + MARGIN, base);
 for (i = 0; i <= 10; i++)
  {
   write_line(outfile, MARGIN, MARGIN + i * epsaxis / 10, MARGIN + TICKWIDTH, MARGIN + i * epsaxis / 10);
   sprintf(st, "%.2f", min + ((max - min) / 10) * i);
   write_string(outfile, MARGIN - 20, MARGIN + i * epsaxis / 10, st, ALIGN_CENTER); 
  }
 for (i = 0; i < counts[0]; i++)
   write_rectangle(outfile, MARGIN + bargap + (barwidth + bargap) * i, base, MARGIN + (barwidth + bargap) * (i + 1), base + epsaxis * (difference[i] / (max - min)), FILL_COLOR, difference[i] > 0 ? BLACK : RED);
 write_image_footer(outfile);
 fclose(outfile);
 safe_free(difference);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq 0x28(%rsp), %rbx
movq %rbx, %rsi
callq 0x98796
movslq (%rbx), %rdi
cmpl 0x4(%rbx), %edi
jne 0x2619d
movq %rax, %r14
shlq $0x3, %rdi
leaq 0x8208e(%rip), %rsi     # 0xa7f31
movl $0x7, %edx
callq 0x3a0e1
movq %rax, %rbx
movslq 0x28(%rsp), %rax
testq %rax, %rax
jle 0x25ef8
movq (%r14), %rcx
movq 0x8(%r14), %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
xorpd %xmm1, %xmm1
movsd (%rcx,%rsi,8), %xmm3
subsd (%rdx,%rsi,8), %xmm3
movsd %xmm3, (%rbx,%rsi,8)
movapd %xmm3, %xmm2
maxsd %xmm1, %xmm2
minsd %xmm0, %xmm3
incq %rsi
movapd %xmm3, %xmm0
movapd %xmm2, %xmm1
cmpq %rsi, %rax
jne 0x25ecb
jmp 0x25f00
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
movsd %xmm3, 0x20(%rsp)
movsd %xmm2, 0x10(%rsp)
movq %r14, %rdi
movl $0x2, %esi
callq 0x3a14b
leaq 0x81feb(%rip), %rdi     # 0xa7f0b
leaq 0x85a46(%rip), %rsi     # 0xab96d
callq 0x40f0
testq %rax, %rax
je 0x2619d
movq %rax, %r14
movq %rax, %rdi
movl $0x294, %esi            # imm = 0x294
movl $0x294, %edx            # imm = 0x294
callq 0x22a5c
movsd 0x10(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
divsd %xmm1, %xmm0
mulsd 0x81e94(%rip), %xmm0    # 0xa7e00
addsd 0x81e94(%rip), %xmm0    # 0xa7e08
cvttsd2si %xmm0, %ebp
movl $0x1f4, %eax            # imm = 0x1F4
xorl %edx, %edx
idivl 0x28(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd 0x81dae(%rip), %xmm0    # 0xa7d40
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
mulsd 0x81e6c(%rip), %xmm1    # 0xa7e10
movsd %xmm1, 0x30(%rsp)
leaq 0x820a9(%rip), %r15     # 0xa805a
movl $0x50, %r12d
movq %r14, %rdi
movq %r15, %rsi
movl $0x50, %edx
movl $0x50, %ecx
movl $0x50, %r8d
movl $0x244, %r9d            # imm = 0x244
xorl %eax, %eax
callq 0x42e0
movq %r14, %rdi
movq %r15, %rsi
movl $0x50, %edx
movl %ebp, %ecx
movl $0x244, %r8d            # imm = 0x244
movl %ebp, 0x1c(%rsp)
movl %ebp, %r9d
xorl %eax, %eax
callq 0x42e0
movsd 0x10(%rsp), %xmm0
divsd 0x81daf(%rip), %xmm0    # 0xa7db8
movsd %xmm0, 0x40(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x81ebc(%rip), %r13     # 0xa7edc
leaq 0x4e(%rsp), %rbp
movq %r14, %rdi
movq %r15, %rsi
movl $0x50, %edx
movl %r12d, %ecx
movl $0x56, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x42e0
movsd 0x40(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movq %rbp, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x41b0
movq %r14, %rdi
movl $0x3c, %esi
movl %r12d, %edx
movq %rbp, %rcx
movl $0x2, %r8d
callq 0x23500
movsd 0x8(%rsp), %xmm0
addsd 0x7f497(%rip), %xmm0    # 0xa5520
movsd %xmm0, 0x8(%rsp)
addl $0x32, %r12d
cmpl $0x276, %r12d           # imm = 0x276
jne 0x26025
cmpl $0x0, 0x28(%rsp)
movq %rbx, 0x8(%rsp)
movsd 0x10(%rsp), %xmm1
movl 0x1c(%rsp), %eax
jle 0x26159
cvttsd2si 0x30(%rsp), %r15d
cvttsd2si 0x38(%rsp), %r13d
leal (%r15,%r13), %ebp
addl $0x50, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rsp)
xorl %r12d, %r12d
leaq 0xaeadd(%rip), %rbx     # 0xd4bc0
leal (%r15,%r13), %r8d
movq 0x8(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
incq %r12
xorl %eax, %eax
ucomisd 0x7fc09(%rip), %xmm0    # 0xa5d08
divsd %xmm1, %xmm0
mulsd 0x81d0d(%rip), %xmm0    # 0xa7e18
addsd 0x20(%rsp), %xmm0
cvttsd2si %xmm0, %r9d
setbe %al
leaq (%rax,%rax,2), %rax
movsd (%rbx,%rax,8), %xmm0
movsd 0x8(%rbx,%rax,8), %xmm1
movsd 0x10(%rbx,%rax,8), %xmm2
movq %r14, %rdi
leaq 0x8200c(%rip), %rsi     # 0xa8144
movl %r15d, %edx
movl 0x1c(%rsp), %ecx
movb $0x3, %al
callq 0x42e0
movsd 0x10(%rsp), %xmm1
movslq 0x28(%rsp), %rax
addl %ebp, %r15d
cmpq %rax, %r12
jl 0x260e3
leaq 0x81d56(%rip), %rdi     # 0xa7eb6
movl $0x7, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
leaq 0x81e9d(%rip), %rdi     # 0xa8016
movl $0x9, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movq %r14, %rdi
callq 0x42a0
movq 0x8(%rsp), %rdi
callq 0x3a180
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq