// File: /workspace/github_cpp_makefile_star2_O3/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, %r14d
andl $0x7f, %edi
callq 0x9700
movl %eax, %ebx
leaq 0x31340a(%rip), %r15    # 0x33f608
cmpw $0x180, (%r15)          # imm = 0x180
jne 0x2c222
leaq 0x30f61b(%rip), %r12    # 0x33b828
movl (%r12), %r13d
movl $0x1, (%r12)
callq 0x72683
movl %r13d, (%r12)
movl %r14d, %edi
callq 0x2b879
movzwl (%r15), %edi
cmpl $0x251, %edi            # imm = 0x251
je 0x2c250
cmpl $0x250, %edi            # imm = 0x250
jne 0x2c292
addl $-0x43, %ebx
cmpl $0x17, %ebx
ja 0x2c292
movl $0xa20001, %ecx         # imm = 0xA20001
btl %ebx, %ecx
jae 0x2c285
leaq 0x212c79(%rip), %rax    # 0x23eed0
movb $0x0, (%rax)
callq 0x2c345
movw $0x0, (%r15)
cmpb $0x1, %al
je 0x2c2cf
movzbl %al, %eax
cmpl $0x2, %eax
jne 0x2c2d6
movl $0x7, %edi
movl $0xa, %esi
callq 0x1118c
jmp 0x2c308
cmpl $0x4, %ebx
jne 0x2c292
movw $0x252, (%r15)          # imm = 0x252
jmp 0x2c250
cmpb $0x1b, %al
je 0x2c2b3
cmpb $0xd, %al
jne 0x2c31e
leaq 0x31303b(%rip), %rcx    # 0x33f2e0
cmpb $0x0, (%rcx)
jne 0x2c31e
callq 0x2bf15
testl %eax, %eax
je 0x2c250
movw $0x0, (%r15)
leaq 0x212c10(%rip), %rax    # 0x23eed0
movb $0x0, (%rax)
leaq 0x1ec50e(%rip), %rax    # 0x2187d8
cmpl $0x0, (%rax)
je 0x2c2d6
callq 0xfa97
jmp 0x2c308
leaq 0x1ec5f3(%rip), %rax    # 0x2188d0
cmpq $0x400, (%rax)          # imm = 0x400
je 0x2c2fe
leaq 0x1ec597(%rip), %rax    # 0x218884
movl (%rax), %eax
leaq 0x1ec51a(%rip), %rcx    # 0x218810
cltd
idivl (%rcx)
cmpl $0x50, %eax
jg 0x2c308
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xf035
callq 0x27570
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0xd, %al
je 0x2c250
cmpw $0x7e, %di
je 0x2c250
cmpw $0x61, %di
je 0x2c250
cmpw $0x51, %di
jne 0x2c30d
jmp 0x2c250