// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathui.cpp
// Function: build_string(int)
int build_string(int c)
{
u32 val;
int not_upper;
int i;

   // add a character to or edit the input string

   val = toupper(c & 0x7F);
if(getting_string == CALC_CMD) {
   i = rpn_mode;
   rpn_mode = 1;
   show_version_header();
   rpn_mode = i;
}

   // we are building a text string from the keystrokes / script input
   c = edit_string(c);     // attempt to add char to the string
   if(getting_string == SORT_CMD) {  // royal kuldge for GCC, GCG, GCZ, and GCT keyboard commands
      if(val == 'C') goto quick_cmd;  // GCC
      if(val == 'T') goto quick_cmd;  // GCT
      if(val == 'X') goto quick_cmd;  // GCX
      if(val == 'Z') goto quick_cmd;  // GCZ
      if(val == 'G') {
         getting_string = SAT_PLOT_CMD;
         goto quick_cmd;  // GCG
      }
   }
   else if(getting_string == TIDE_CMD) {  // royal kludge for GKx earth tide / gravity plot control
      goto quick_cmd;
   }

   if(getting_string < 0x0100) not_upper = !isupper(getting_string);
   else                        not_upper = 1;

   if(c == ESC_CHAR) {     // edit abandoned
      goto abandon_edit;
   }
   else if((c == 0x0D) && (edit_buffer[0] == 0) && ignore_blank_line(getting_string)) {  // blank input line
      // CR with no text in edit buffer
      abandon_edit:
      getting_string = 0;
      script_pause = 0;
      if(text_mode) redraw_screen();
      else if(rcvr_type == NO_RCVR) erase_plot(FULL_ERASE_OK);
      else if((PLOT_WIDTH/TEXT_WIDTH) <= 80) erase_plot(FULL_ERASE_OK);
   }
   else if(c == 0x0D) { // edit done, parameter available,  do the command
      quick_cmd:
      script_pause = 0;
      val = string_param();  // evaluate and act upon the text string
      getting_string = 0;

      if(val == NEED_NEW_QUEUES) new_queue(RESET_ALL_QUEUES, 10);
      else if(val == NEED_SCREEN_REDRAW) redraw_screen();
      else if(rcvr_type == NO_RCVR) erase_plot(FULL_ERASE_OK);
      else if((PLOT_WIDTH/TEXT_WIDTH) <= 80) erase_plot(FULL_ERASE_OK);
   }
   else if(getting_string == ADEV_CMD) {  // !!! kludge to make parsing command easier !!!
      goto quick_cmd;
   }
// else if(getting_string == ADEV_BIN_CMD) {  // !!! kludge to make parsing command easier !!!
//    goto quick_cmd;
// }
   else if(getting_string == SIGNAL_CMD) {  // !!! kludge to make parsing command easier !!!
      goto quick_cmd;
   }
   else if(getting_string == STAT_CMD) {  // !!! kludge to make parsing command easier !!!
      goto quick_cmd;
   }
   else return 0;  // character was added to the edit string

   return sure_exit();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
andl $0x7f, %edi
callq 0x9700
movl %eax, %r15d
leaq 0x313751(%rip), %r12    # 0x33f608
cmpw $0x180, (%r12)          # imm = 0x180
jne 0x2bed9
leaq 0x30f961(%rip), %r14    # 0x33b828
movl (%r14), %r13d
movl $0x1, (%r14)
callq 0x727c3
movl %r13d, (%r14)
movl %ebx, %edi
callq 0x2b55b
movzwl (%r12), %ebx
cmpl $0x251, %ebx            # imm = 0x251
je 0x2bf0d
movl %eax, %r14d
cmpl $0x250, %ebx            # imm = 0x250
jne 0x2bf52
addl $-0x43, %r15d
cmpl $0x17, %r15d
ja 0x2bf52
movl $0xa20001, %eax         # imm = 0xA20001
btl %r15d, %eax
jae 0x2bf43
leaq 0x212fbc(%rip), %rax    # 0x23eed0
movb $0x0, (%rax)
callq 0x2c00e
movw $0x0, (%r12)
cmpb $0x1, %al
je 0x2bf96
movzbl %al, %eax
cmpl $0x2, %eax
jne 0x2bf9d
movl $0x7, %edi
movl $0xa, %esi
callq 0x1120f
jmp 0x2bfcf
cmpl $0x4, %r15d
jne 0x2bf52
movw $0x252, (%r12)          # imm = 0x252
jmp 0x2bf0d
cmpb $0x1b, %r14b
je 0x2bf79
cmpb $0xd, %r14b
jne 0x2bfe5
leaq 0x313377(%rip), %rax    # 0x33f2e0
cmpb $0x0, (%rax)
jne 0x2bfe5
movl %ebx, %edi
callq 0x2bbce
testl %eax, %eax
je 0x2bfe5
movw $0x0, (%r12)
leaq 0x212f49(%rip), %rax    # 0x23eed0
movb $0x0, (%rax)
leaq 0x1ec847(%rip), %rax    # 0x2187d8
cmpl $0x0, (%rax)
je 0x2bf9d
callq 0xfb1a
jmp 0x2bfcf
leaq 0x1ec92c(%rip), %rax    # 0x2188d0
cmpq $0x400, (%rax)          # imm = 0x400
je 0x2bfc5
leaq 0x1ec8d0(%rip), %rax    # 0x218884
movl (%rax), %eax
leaq 0x1ec853(%rip), %rcx    # 0x218810
cltd
idivl (%rcx)
cmpl $0x50, %eax
jg 0x2bfcf
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xf0ad
callq 0x2781b
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0xd, %r14b
je 0x2bf0d
cmpw $0x7e, %bx
je 0x2bf0d
cmpw $0x61, %bx
je 0x2bf0d
cmpw $0x51, %bx
jne 0x2bfd4
jmp 0x2bf0d