// File: /workspace/github_cpp_makefile_star2_O3/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 0x233bc
movl %esi, %r14d
leaq 0xfdab8(%rip), %rsi     # 0x120d8d
callq 0x9a47
testq %rax, %rax
je 0x233c6
movq %rax, %r15
leaq 0x31853b(%rip), %r13    # 0x33b828
movl (%r13), %eax
movl %eax, -0x30(%rbp)
movl $0x0, 0x32141a(%rip)    # 0x344718
leaq 0x318f1b(%rip), %r12    # 0x33c220
movq %r12, %rdi
movl $0x201, %esi            # imm = 0x201
movq %r15, %rdx
callq 0x9600
xorl %ebx, %ebx
testq %rax, %rax
je 0x233dd
movl %r14d, -0x2c(%rbp)
leaq 0x318919(%rip), %r14    # 0x33bc44
leaq 0x31870e(%rip), %r13    # 0x33ba40
movabsq $0x100000201, %rbx      # imm = 0x100000201
movl $0x0, (%r14)
movb $0x0, (%r13)
movq %r12, %rdi
movl $0xd, %esi
callq 0x9100
testq %rax, %rax
je 0x2335d
movb $0x0, (%rax)
movq %r12, %rdi
movl $0xa, %esi
callq 0x9100
testq %rax, %rax
je 0x23372
movb $0x0, (%rax)
movzbl (%r12), %eax
cmpq $0x20, %rax
ja 0x23383
btq %rax, %rbx
jb 0x233a3
movq %r12, %rdi
callq 0x986c
leaq 0x31bf4e(%rip), %rdi    # 0x33f2e0
movq %r12, %rsi
callq 0x9340
callq 0x23464
testl %eax, %eax
jne 0x233cd
movq %r12, %rdi
movl $0x201, %esi            # imm = 0x201
movq %r15, %rdx
callq 0x9600
testq %rax, %rax
jne 0x2333c
xorl %ebx, %ebx
jmp 0x233d2
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x23453
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x23432
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movl -0x2c(%rbp), %r14d
leaq 0x31844b(%rip), %r13    # 0x33b828
movq %r15, %rdi
callq 0x9370
movl -0x30(%rbp), %eax
movl %eax, (%r13)
testl %r14d, %r14d
je 0x23432
leaq 0x31b5a8(%rip), %rax    # 0x33e9a0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x31b6ed(%rip), %rax    # 0x33eaf0
movb %cl, (%rax)
leaq 0x31b834(%rip), %rax    # 0x33ec40
movb %cl, (%rax)
leaq 0x31b97b(%rip), %rax    # 0x33ed90
movb %cl, (%rax)
leaq 0x31bac2(%rip), %rax    # 0x33eee0
movb %cl, (%rax)
leaq 0x31bc09(%rip), %rax    # 0x33f030
movb %cl, (%rax)
leaq 0x31bd50(%rip), %rax    # 0x33f180
movb %cl, (%rax)
leaq 0x31bea7(%rip), %rax    # 0x33f2e0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x3183ec(%rip), %rax    # 0x33b830
movb %cl, (%rax)
leaq 0x3187f7(%rip), %rax    # 0x33bc44
movl $0x0, (%rax)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq