// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathui.cpp
// Function: dump_cal_file()
void dump_cal_file()
{
FILE *file;

   if(edit_buffer[0] == 0) {
      file = topen("luxcal.scr", "w");
      if(file == 0) {
         sprintf(out, "ERROR: could not write file: luxcal.scr");
         edit_error(out);
         return;
      }
   }
   else {
//    strupr(edit_buffer);
      if(strstr(edit_buffer, ".") == 0) strcat(edit_buffer, ".scr");
      file = topen(edit_buffer, "w");
      if(file == 0) {
         sprintf(out, "ERROR: could not write file: %s", edit_buffer);
         edit_error(out);
         return;
      }
   }
   if(file == 0) return;

   fprintf(file, "&c0                     ;exit calibration mode\n");
   fprintf(file, "&s  %.4f   SERIAL     ;serial number\n", vref_b);
   fprintf(file, "&v  %.6f VREF       ;ADC reference voltage\n", vref_m);
   fprintf(file, "gd& %.6f %.6f   ;battery/led voltage calibration\n", vcal_m, vcal_b);
   fprintf(file, "go& %.6f %.6f   ;battery current calibration\n", batti_m, batti_b);
   fprintf(file, "g3& %.6f %.6f   ;led current calibration\n", ledi_m, ledi_b);
   fprintf(file, "gt& %.6f %.6f   ;temp sensor 1 calibration\n", temp1_m, temp1_b);
   fprintf(file, "g5& %.6f %.6f   ;temp sensor 2 calibration\n", temp2_m, temp2_b);
   fprintf(file, "gp& %.6f %.6f   ;lux sensor calibration\n", lux1_m, lux1_b);
   fprintf(file, "g1& %.6f %.6f   ;lumen sensor calibration\n", lux2_m, lux2_b);
   fprintf(file, "gl& %.6f %.6f   ;r/b color temperature calibration\n", rb_m, rb_b);
   fprintf(file, "g0& %.6f %.6f   ;aux ADC channel calibration\n", adc2_m, adc2_b);

   fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x2f8efd(%rip), %rax    # 0x3292e0
cmpb $0x0, (%rax)
je 0x30452
leaq 0x2f8ef1(%rip), %rbx    # 0x3292e0
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0x9100
testq %rax, %rax
jne 0x30413
movq %rbx, %rdi
callq 0x9120
movl $0x7263732e, (%rbx,%rax) # imm = 0x7263732E
movb $0x0, 0x4(%rbx,%rax)
leaq 0x2f8ec6(%rip), %rdi    # 0x3292e0
leaq 0xdaee2(%rip), %rsi     # 0x10b303
callq 0x9a22
testq %rax, %rax
jne 0x3046e
leaq 0x2f5dee(%rip), %rbx    # 0x326220
leaq 0xcef15(%rip), %rsi     # 0xff34e
leaq 0x2f8ea0(%rip), %rdx    # 0x3292e0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
jmp 0x30655
leaq 0xceeea(%rip), %rdi     # 0xff343
leaq 0xdaea3(%rip), %rsi     # 0x10b303
callq 0x9a22
testq %rax, %rax
je 0x3062b
movq %rax, %rbx
leaq 0xceef6(%rip), %rdi     # 0xff36e
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x9750
leaq 0x1d4cdb(%rip), %rax    # 0x205168
movsd (%rax), %xmm0
leaq 0xcef06(%rip), %rsi     # 0xff39e
movq %rbx, %rdi
movb $0x1, %al
callq 0x9560
leaq 0x1d4cb7(%rip), %rax    # 0x205160
movsd (%rax), %xmm0
leaq 0xcef10(%rip), %rsi     # 0xff3c4
movq %rbx, %rdi
movb $0x1, %al
callq 0x9560
leaq 0x1d4ccb(%rip), %rax    # 0x205190
movsd (%rax), %xmm0
leaq 0x1d4cc8(%rip), %rax    # 0x205198
movsd (%rax), %xmm1
leaq 0xcef15(%rip), %rsi     # 0xff3f0
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4cb4(%rip), %rax    # 0x2051a0
movsd (%rax), %xmm0
leaq 0x1d4cb1(%rip), %rax    # 0x2051a8
movsd (%rax), %xmm1
leaq 0xcef20(%rip), %rsi     # 0xff422
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4c9d(%rip), %rax    # 0x2051b0
movsd (%rax), %xmm0
leaq 0x1d4c9a(%rip), %rax    # 0x2051b8
movsd (%rax), %xmm1
leaq 0xcef27(%rip), %rsi     # 0xff450
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4c36(%rip), %rax    # 0x205170
movsd (%rax), %xmm0
leaq 0x1d4c33(%rip), %rax    # 0x205178
movsd (%rax), %xmm1
leaq 0xcef2a(%rip), %rsi     # 0xff47a
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4c1f(%rip), %rax    # 0x205180
movsd (%rax), %xmm0
leaq 0x1d4c1c(%rip), %rax    # 0x205188
movsd (%rax), %xmm1
leaq 0xcef2f(%rip), %rsi     # 0xff4a6
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4c38(%rip), %rax    # 0x2051c0
movsd (%rax), %xmm0
leaq 0x1d4c35(%rip), %rax    # 0x2051c8
movsd (%rax), %xmm1
leaq 0xcef34(%rip), %rsi     # 0xff4d2
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4c21(%rip), %rax    # 0x2051d0
movsd (%rax), %xmm0
leaq 0x1d4c1e(%rip), %rax    # 0x2051d8
movsd (%rax), %xmm1
leaq 0xcef36(%rip), %rsi     # 0xff4fb
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4c1a(%rip), %rax    # 0x2051f0
movsd (%rax), %xmm0
leaq 0x1d4c17(%rip), %rax    # 0x2051f8
movsd (%rax), %xmm1
leaq 0xcef3a(%rip), %rsi     # 0xff526
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
leaq 0x1d4be3(%rip), %rax    # 0x2051e0
movsd (%rax), %xmm0
leaq 0x1d4be0(%rip), %rax    # 0x2051e8
movsd (%rax), %xmm1
leaq 0xcef47(%rip), %rsi     # 0xff55a
movq %rbx, %rdi
movb $0x2, %al
callq 0x9560
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x9360
movups 0xced04(%rip), %xmm0    # 0xff336
leaq 0x2f5be7(%rip), %rdi    # 0x326220
movaps %xmm0, 0x10(%rdi)
movups 0xcece2(%rip), %xmm0    # 0xff326
movaps %xmm0, (%rdi)
movabsq $0x7263732e6c6163, %rax # imm = 0x7263732E6C6163
movq %rax, 0x20(%rdi)
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x214df