// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathui.cpp
// Function: read_rpn_file(char*, int)
int read_rpn_file(char *rpn_name, int erase)
{
FILE *file;
int i;
char *s;
int old_mode;

   // read in user defined calculator functions from a file

   i = 0;
   if(rpn_name == 0) return (-1);
   s = strchr(rpn_name, '.');
   if(s == 0) {  // add .rpn extension if none given
//    strcat(rpn_name, ".rpn");
   }
   file = topen(rpn_name, "r");

   if(file) {
      old_mode = rpn_mode;
      rpn_err_flag = 0;
      while(fgets(out, sizeof out, file) != NULL) {
         msg_col = 0;
         msg_field[0] = 0;

         s = strchr(out, 0x0D);  // trim trailing CR and LF
         if(s) *s = 0;
         s = strchr(out, 0x0A);
         if(s) *s = 0;

         if(out[0] == 0) continue;
         if(out[0] == ' ') continue;
         if(out[0] == '\t') continue;

         strlwr(out);
         strcpy(edit_buffer, out);
         i = rpn_calc(); // execute the line
         if(i) {  // error in RPN file
            i = (-2);
            break;
         }
      }

      fclose(file);
      file = 0;

      rpn_mode = old_mode;
      if(erase) {  // erase calculator results from the plot area
         debug_text[0] = 0;
         debug_text2[0] = 0;
         debug_text3[0] = 0;
         debug_text4[0] = 0;
         debug_text5[0] = 0;
         debug_text6[0] = 0;
         debug_text7[0] = 0;
      }
   }
   else i = (-1);  // bad file name

   edit_buffer[0] = 0;
   nmea_msg[0] = 0;
   msg_col = 0;

   return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2185d
movl %esi, %ebx
leaq 0xe9541(%rip), %rsi     # 0x10acd5
callq 0x9a22
testq %rax, %rax
je 0x218c4
movq %rax, %r15
movl %ebx, -0x30(%rbp)
leaq 0x304079(%rip), %rax    # 0x325828
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
andl $0x0, 0x30cf5d(%rip)    # 0x32e718
leaq 0x304a5e(%rip), %r12    # 0x326220
leaq 0x304277(%rip), %rbx    # 0x325a40
pushq $0xd
popq %r13
pushq $0xa
popq %r14
movq %r12, %rdi
movl $0x201, %esi            # imm = 0x201
movq %r15, %rdx
callq 0x9600
testq %rax, %rax
je 0x21865
leaq 0x304457(%rip), %rax    # 0x325c44
andl $0x0, (%rax)
movb $0x0, (%rbx)
movq %r12, %rdi
movl %r13d, %esi
callq 0x9100
testq %rax, %rax
je 0x21806
movb $0x0, (%rax)
movq %r12, %rdi
movl %r14d, %esi
callq 0x9100
testq %rax, %rax
je 0x21819
movb $0x0, (%rax)
movzbl (%r12), %eax
cmpq $0x20, %rax
ja 0x21834
movabsq $0x100000201, %rcx      # imm = 0x100000201
btq %rax, %rcx
jb 0x217d1
movq %r12, %rdi
callq 0x986c
leaq 0x307a9d(%rip), %rdi    # 0x3292e0
movq %r12, %rsi
callq 0x9330
callq 0x218f6
testl %eax, %eax
je 0x217d1
pushq $-0x2
popq %rbx
jmp 0x21867
pushq $-0x1
popq %rbx
jmp 0x218e5
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x9360
leaq 0x303fb2(%rip), %rax    # 0x325828
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
cmpl $0x0, -0x30(%rbp)
je 0x218c7
leaq 0x307118(%rip), %rax    # 0x3289a0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x30725d(%rip), %rax    # 0x328af0
movb %cl, (%rax)
leaq 0x3073a4(%rip), %rax    # 0x328c40
movb %cl, (%rax)
leaq 0x3074eb(%rip), %rax    # 0x328d90
movb %cl, (%rax)
leaq 0x307632(%rip), %rax    # 0x328ee0
movb %cl, (%rax)
leaq 0x307779(%rip), %rax    # 0x329030
movb %cl, (%rax)
leaq 0x3078c0(%rip), %rax    # 0x329180
movb %cl, (%rax)
jmp 0x218c7
pushq $-0x1
popq %rbx
leaq 0x307a12(%rip), %rax    # 0x3292e0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x303f57(%rip), %rax    # 0x325830
movb %cl, (%rax)
leaq 0x304362(%rip), %rax    # 0x325c44
andl $0x0, (%rax)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq