// File: jkingan[P]ladyheather/heather.cpp
// Function: format_plot_title(char*)
void format_plot_title(char *title)
{
int len;
int i, j;
char c;

   if(title == 0) return;

   j = 0;
   i = 0;
   out[0] = 0;
   len = strlen(title);

   for(i=0; i<len; i++) {
      if((unsigned) j > (sizeof(plot_title)-2)) break;

      c = title[i];
      if(c == '&') {
         if(title[i+1] == '&') {  // && -> disciplining parameters
            if((unsigned)j > (sizeof(plot_title)-45)) break;
            if(osc_control_on) {
               sprintf(&out[j], "(OSC PID: P=%f D=%f F=%f I=%f)", OSC_P_GAIN, OSC_D_TC, OSC_FILTER_TC, OSC_I_TC);
            }
            else {
               sprintf(&out[j], "(TC=%.3f  DAMPING=%.3f  GAIN=%.3f Hz/V  INITV:%.3f)",
                   time_constant, damping_factor, osc_gain, initial_voltage);
            }
            j = strlen(out);
            ++i;
         }
         else if(title[i+1] == 'd') {  // &d -> date
            if((unsigned)j > (sizeof(plot_title)-20)) break;
            sprintf(&out[j], "%s", fmt_date(0));
            j = strlen(out);
            ++i;
         }
         else if(title[i+1] == 't') {  // &t -> time
            if((unsigned)j > (sizeof(plot_title)-20)) break;
            sprintf(&out[j], "%02d:%02d:%02d %s", pri_hours,pri_minutes,pri_seconds, tz_string);
            j = strlen(out);
            ++i;
         }
         else {
            out[j++] = '&';
            out[j] = 0;
         }
      }
      else {
         out[j++] = c;
         out[j] = 0;
         if(c == 0) break;
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x21588
jmp 0x2180d
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movb $0x0, 0x379e63(%rip)    # 0x39b400
movq -0x8(%rbp), %rdi
callq 0x9120
movl %eax, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2180d
movl -0x14(%rbp), %eax
cmpq $0x149, %rax            # imm = 0x149
jbe 0x215cc
jmp 0x2180d
movq -0x8(%rbp), %rax
movslq -0x10(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x15(%rbp)
movsbl -0x15(%rbp), %eax
cmpl $0x26, %eax
jne 0x217c6
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x26, %eax
jne 0x216b1
movl -0x14(%rbp), %eax
cmpq $0x11e, %rax            # imm = 0x11E
jbe 0x21611
jmp 0x2180d
cmpb $0x0, 0x37d2a0(%rip)    # 0x39e8b8
je 0x21658
movslq -0x14(%rbp), %rax
leaq 0x379ddb(%rip), %rdi    # 0x39b400
addq %rax, %rdi
movsd 0x37d250(%rip), %xmm0   # 0x39e880
movsd 0x37d250(%rip), %xmm1   # 0x39e888
movsd 0x37d250(%rip), %xmm2   # 0x39e890
movsd 0x37d250(%rip), %xmm3   # 0x39e898
leaq 0x14f415(%rip), %rsi    # 0x170a64
movb $0x4, %al
callq 0x9060
jmp 0x21694
movslq -0x14(%rbp), %rax
leaq 0x379d9d(%rip), %rdi    # 0x39b400
addq %rax, %rdi
movsd 0x34ac62(%rip), %xmm0   # 0x36c2d0
movsd 0x34ac6a(%rip), %xmm1   # 0x36c2e0
movsd 0x34ac6a(%rip), %xmm2   # 0x36c2e8
movsd 0x34acaa(%rip), %xmm3   # 0x36c330
leaq 0x14f3f6(%rip), %rsi    # 0x170a83
movb $0x4, %al
callq 0x9060
leaq 0x379d65(%rip), %rdi    # 0x39b400
callq 0x9120
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x217c4
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x64, %eax
jne 0x21722
movl -0x14(%rbp), %eax
cmpq $0x137, %rax            # imm = 0x137
jbe 0x216d7
jmp 0x2180d
movslq -0x14(%rbp), %rcx
leaq 0x379d1e(%rip), %rax    # 0x39b400
addq %rcx, %rax
movq %rax, -0x20(%rbp)
xorl %edi, %edi
callq 0x148a00
movq -0x20(%rbp), %rdi
movq %rax, %rdx
leaq 0x16f42f(%rip), %rsi    # 0x190b2d
movb $0x0, %al
callq 0x9060
leaq 0x379cf4(%rip), %rdi    # 0x39b400
callq 0x9120
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x217c2
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x74, %eax
jne 0x21798
movl -0x14(%rbp), %eax
cmpq $0x137, %rax            # imm = 0x137
jbe 0x21748
jmp 0x2180d
movslq -0x14(%rbp), %rax
leaq 0x379cad(%rip), %rdi    # 0x39b400
addq %rax, %rdi
movl 0x34af8c(%rip), %edx    # 0x36c6e8
movl 0x34af82(%rip), %ecx    # 0x36c6e4
movl 0x34af77(%rip), %r8d    # 0x36c6e0
leaq 0x14f347(%rip), %rsi    # 0x170ab7
leaq 0x34b395(%rip), %r9     # 0x36cb0c
movb $0x0, %al
callq 0x9060
leaq 0x379c7b(%rip), %rdi    # 0x39b400
callq 0x9120
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x217c0
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %eax, %rcx
leaq 0x379c53(%rip), %rax    # 0x39b400
movb $0x26, (%rax,%rcx)
movslq -0x14(%rbp), %rcx
leaq 0x379c44(%rip), %rax    # 0x39b400
movb $0x0, (%rax,%rcx)
jmp 0x217c2
jmp 0x217c4
jmp 0x217fd
movb -0x15(%rbp), %dl
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %eax, %rcx
leaq 0x379c22(%rip), %rax    # 0x39b400
movb %dl, (%rax,%rcx)
movslq -0x14(%rbp), %rcx
leaq 0x379c14(%rip), %rax    # 0x39b400
movb $0x0, (%rax,%rcx)
movsbl -0x15(%rbp), %eax
cmpl $0x0, %eax
jne 0x217fb
jmp 0x2180d
jmp 0x217fd
jmp 0x217ff
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x215b0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)