// File: /workspace/github_cpp_makefile_star2_O1/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 0x235f8
movl %esi, %r14d
leaq 0xfd79c(%rip), %rsi     # 0x120cad
callq 0x9a4d
testq %rax, %rax
je 0x23602
movq %rax, %r15
leaq 0x3182ff(%rip), %r13    # 0x33b828
movl (%r13), %eax
movl %eax, -0x30(%rbp)
movl $0x0, 0x3211de(%rip)    # 0x344718
leaq 0x318cdf(%rip), %r12    # 0x33c220
movq %r12, %rdi
movl $0x201, %esi            # imm = 0x201
movq %r15, %rdx
callq 0x9600
xorl %ebx, %ebx
testq %rax, %rax
je 0x23619
movl %r14d, -0x2c(%rbp)
leaq 0x3186dd(%rip), %r14    # 0x33bc44
leaq 0x3184d2(%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 0x23599
movb $0x0, (%rax)
movq %r12, %rdi
movl $0xa, %esi
callq 0x9100
testq %rax, %rax
je 0x235ae
movb $0x0, (%rax)
movzbl (%r12), %eax
cmpq $0x20, %rax
ja 0x235bf
btq %rax, %rbx
jb 0x235df
movq %r12, %rdi
callq 0x986c
leaq 0x31bd12(%rip), %rdi    # 0x33f2e0
movq %r12, %rsi
callq 0x9340
callq 0x236a0
testl %eax, %eax
jne 0x23609
movq %r12, %rdi
movl $0x201, %esi            # imm = 0x201
movq %r15, %rdx
callq 0x9600
testq %rax, %rax
jne 0x23578
xorl %ebx, %ebx
jmp 0x2360e
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x2368f
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x2366e
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movl -0x2c(%rbp), %r14d
leaq 0x31820f(%rip), %r13    # 0x33b828
movq %r15, %rdi
callq 0x9370
movl -0x30(%rbp), %eax
movl %eax, (%r13)
testl %r14d, %r14d
je 0x2366e
leaq 0x31b36c(%rip), %rax    # 0x33e9a0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x31b4b1(%rip), %rax    # 0x33eaf0
movb %cl, (%rax)
leaq 0x31b5f8(%rip), %rax    # 0x33ec40
movb %cl, (%rax)
leaq 0x31b73f(%rip), %rax    # 0x33ed90
movb %cl, (%rax)
leaq 0x31b886(%rip), %rax    # 0x33eee0
movb %cl, (%rax)
leaq 0x31b9cd(%rip), %rax    # 0x33f030
movb %cl, (%rax)
leaq 0x31bb14(%rip), %rax    # 0x33f180
movb %cl, (%rax)
leaq 0x31bc6b(%rip), %rax    # 0x33f2e0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x3181b0(%rip), %rax    # 0x33b830
movb %cl, (%rax)
leaq 0x3185bb(%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