// File: /workspace/github_c_makefile_star2_O2/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 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x89dc2
movslq (%rbx), %rdi
cmpl 0x4(%rbx), %edi
jne 0x23065
movq %rax, %r14
shlq $0x3, %rdi
leaq 0x750b1(%rip), %rsi     # 0x97eb1
pushq $0x7
popq %rdx
callq 0x34f59
movq %rax, %rbx
movl 0x20(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
cmpq %rcx, %rax
je 0x22e52
movq (%r14), %rdx
movq 0x8(%r14), %rsi
movsd (%rdx,%rcx,8), %xmm0
subsd (%rsi,%rcx,8), %xmm0
movsd %xmm0, (%rbx,%rcx,8)
movapd %xmm0, %xmm1
maxsd %xmm2, %xmm1
minsd %xmm3, %xmm0
incq %rcx
movapd %xmm1, %xmm2
movapd %xmm0, %xmm3
jmp 0x22e1e
movsd %xmm3, 0x28(%rsp)
movsd %xmm2, 0x8(%rsp)
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x34fc3
leaq 0x7501b(%rip), %rdi     # 0x97e8b
leaq 0x78a1a(%rip), %rsi     # 0x9b891
callq 0x40f0
testq %rax, %rax
je 0x23065
movq %rax, %r14
movq %rax, %rdi
movl $0x294, %esi            # imm = 0x294
movl $0x294, %edx            # imm = 0x294
callq 0x1ffcc
movsd 0x8(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
divsd %xmm1, %xmm0
mulsd 0x74ec4(%rip), %xmm0    # 0x97d80
addsd 0x74ec4(%rip), %xmm0    # 0x97d88
cvttsd2si %xmm0, %ebp
movl $0x1f4, %eax            # imm = 0x1F4
xorl %edx, %edx
idivl 0x20(%rsp)
cvtsi2sd %eax, %xmm0
movsd 0x74de1(%rip), %xmm1    # 0x97cc0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
mulsd 0x74e9f(%rip), %xmm0    # 0x97d90
movsd %xmm0, 0x38(%rsp)
pushq $0x50
popq %r13
movq %r14, %rdi
movl %r13d, %esi
movl %r13d, %edx
movl %r13d, %ecx
movl $0x244, %r8d            # imm = 0x244
callq 0x20866
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl $0x244, %ecx            # imm = 0x244
movl %ebp, 0x1c(%rsp)
movl %ebp, %r8d
callq 0x20866
movsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
divsd 0x74dfb(%rip), %xmm0    # 0x97d38
movsd %xmm0, 0x40(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x4e(%rsp), %r15
pushq $0x2
popq %r12
movl %r13d, %ebp
cmpl $0x276, %r13d           # imm = 0x276
je 0x22fcc
movq %r14, %rdi
movl %ebp, %esi
movl %r13d, %edx
pushq $0x56
popq %rcx
movl %r13d, %r8d
callq 0x20866
movsd 0x40(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
addsd 0x28(%rsp), %xmm0
movq %r15, %rdi
leaq 0x74ecb(%rip), %rsi     # 0x97e5c
movb $0x1, %al
callq 0x41b0
movq %r14, %rdi
pushq $0x3c
popq %rsi
movl %r13d, %edx
movq %r15, %rcx
movl %r12d, %r8d
callq 0x20944
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
addsd 0x72560(%rip), %xmm0    # 0x95520
movsd %xmm0, 0x10(%rsp)
addl $0x32, %r13d
jmp 0x22f59
cvttsd2si 0x30(%rsp), %r13d
cvttsd2si 0x38(%rsp), %r15d
leal (%r15,%r13), %ebp
addl $0x50, %r15d
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
xorl %r12d, %r12d
movslq 0x20(%rsp), %rax
cmpq %rax, %r12
jge 0x2304d
leal (%r15,%r13), %ecx
movsd (%rbx,%r12,8), %xmm0
incq %r12
xorl %eax, %eax
ucomisd 0x72d06(%rip), %xmm0    # 0x95d18
divsd %xmm1, %xmm0
mulsd 0x74d7a(%rip), %xmm0    # 0x97d98
addsd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %r8d
setbe %al
movl %eax, (%rsp)
movq %r14, %rdi
movl %r15d, %esi
movl 0x1c(%rsp), %edx
pushq $0x4
popq %r9
callq 0x209ea
movsd 0x8(%rsp), %xmm1
addl %ebp, %r15d
jmp 0x22ff1
movq %r14, %rdi
callq 0x20a81
movq %r14, %rdi
callq 0x42a0
movq %rbx, %rdi
callq 0x34ff7
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq