#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ chtype;
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int A_BOLD;
int A_REVERSE;
#define ERR 134
int FALSE;
int KEY_BACKSPACE;
#define KEY_DOWN 133
#define KEY_EIC 132
#define KEY_IC 131
#define KEY_LEFT 130
#define KEY_RIGHT 129
#define KEY_UP 128
int TRUE;
int /*<<< orphan*/ colorbox(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ curs_set(int);
int /*<<< orphan*/ delwin(int /*<<< orphan*/ *);
int erasechar();
int /*<<< orphan*/ getattrs(int /*<<< orphan*/ *);
int /*<<< orphan*/ getbegyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ getyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ idle();
int /*<<< orphan*/ isprint(int);
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int);
int killchar();
int /*<<< orphan*/ memmove(void *, void const *, scalar_t__);
int /*<<< orphan*/ repainteditbox(int /*<<< orphan*/ *, int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ *subwin(int /*<<< orphan*/ *, int, int, int, int);
int /*<<< orphan*/ wattrset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int wgetch(int /*<<< orphan*/ *);
int wordchar();
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int weditstr(WINDOW *win, char *buf, int field) {
  char org[256], *tp, *bp = buf;
  bool defdisp = TRUE, stop = FALSE, insert = FALSE;
  int cury, curx, begy, begx;
  chtype oldattr;
  WINDOW *wedit;
  int c = 0;
  if ((field >= 256) || (buf == NULL) || ((int)strlen(buf) > field - 1))
    return ERR;
  strcpy(org, buf);
  wrefresh(win);
  getyx(win, cury, curx);
  getbegyx(win, begy, begx);
  wedit = subwin(win, 1, field, begy + cury, begx + curx);
  oldattr = getattrs(wedit);
  colorbox(wedit, (A_BOLD | A_REVERSE), 0);
  keypad(wedit, TRUE);
  curs_set(1);
  while (!stop) {
    idle();
    repainteditbox(wedit, bp - buf, buf);
    switch (c = wgetch(wedit)) {
    case ERR:
      break;
    case 0x1b:
      strcpy(buf, org);
      stop = TRUE;
      break;
    case '\n':
    case KEY_UP:
    case KEY_DOWN:
      stop = TRUE;
      break;
    case KEY_LEFT:
      if (bp > buf)
        bp--;
      break;
    case KEY_RIGHT:
      defdisp = FALSE;
      if (bp - buf < (int)strlen(buf))
        bp++;
      break;
    case '\t':
    case KEY_IC:
    case KEY_EIC:
      defdisp = FALSE;
      insert = !insert;
      curs_set(insert ? 2 : 1);
      break;
    default:
      if (c == erasechar() || c == KEY_BACKSPACE) {
        if (bp > buf) {
          memmove((void *)(bp - 1), (const void *)bp, strlen(bp) + 1);
          bp--;
        }
      } else if (c == killchar()) {
        bp = buf;
        *bp = '\0';
      } else if (c == wordchar()) {
        tp = bp;
        while ((bp > buf) && (*(bp - 1) == ' '))
          bp--;
        while ((bp > buf) && (*(bp - 1) != ' '))
          bp--;
        memmove((void *)bp, (const void *)tp, strlen(tp) + 1);
      } else if (isprint(c)) {
        if (defdisp) {
          bp = buf;
          *bp = '\0';
          defdisp = FALSE;
        }
        if (insert) {
          if ((int)strlen(buf) < field - 1) {
            memmove((void *)(bp + 1), (const void *)bp, strlen(bp) + 1);
            *bp++ = c;
          }
        } else if (bp - buf < field - 1) {
          if (!*bp)
            bp[1] = '\0';
          *bp++ = c;
        }
      }
    }
  }
  curs_set(0);
  wattrset(wedit, oldattr);
  repainteditbox(wedit, bp - buf, buf);
  delwin(wedit);
  return c;
}


x86 assembly (clang, -O0):
<weditstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x138(%rbp)
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x13c(%rbp)
movl   $0x0,-0x15c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
jge    12c7 <weditstr+0x87>
cmpq   $0x0,-0x18(%rbp)
je     12c7 <weditstr+0x87>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    12d3 <weditstr+0x93>
movl   $0x86,-0x4(%rbp)
jmp    1961 <weditstr+0x721>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1090 <wrefresh@plt>
mov    -0x10(%rbp),%rdi
mov    -0x140(%rbp),%esi
mov    -0x144(%rbp),%edx
call   1080 <getyx@plt>
mov    -0x10(%rbp),%rdi
mov    -0x148(%rbp),%esi
mov    -0x14c(%rbp),%edx
call   10e0 <getbegyx@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x148(%rbp),%ecx
add    -0x140(%rbp),%ecx
mov    -0x14c(%rbp),%r8d
add    -0x144(%rbp),%r8d
mov    $0x1,%esi
call   10b0 <subwin@plt>
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rdi
call   1030 <getattrs@plt>
mov    %eax,-0x150(%rbp)
mov    -0x158(%rbp),%rdi
mov    0x2c58(%rip),%rax
mov    (%rax),%esi
mov    0x2c5f(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1050 <colorbox@plt>
mov    -0x158(%rbp),%rdi
mov    0x2c58(%rip),%rax
mov    (%rax),%esi
call   10a0 <keypad@plt>
mov    $0x1,%edi
call   1160 <curs_set@plt>
cmpl   $0x0,-0x138(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13b2 <weditstr+0x172>
jmp    1913 <weditstr+0x6d3>
xor    %eax,%eax
call   10d0 <idle@plt>
mov    -0x158(%rbp),%rdi
mov    -0x130(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    %edx,%eax
sub    %eax,%esi
call   1150 <repainteditbox@plt>
mov    -0x158(%rbp),%rdi
call   1130 <wgetch@plt>
mov    %eax,-0x15c(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x160(%rbp)
sub    $0x9,%eax
je     1569 <weditstr+0x329>
jmp    13fb <weditstr+0x1bb>
mov    -0x160(%rbp),%eax
sub    $0xa,%eax
je     14d3 <weditstr+0x293>
jmp    140f <weditstr+0x1cf>
mov    -0x160(%rbp),%eax
sub    $0x1b,%eax
je     14af <weditstr+0x26f>
jmp    1423 <weditstr+0x1e3>
mov    -0x160(%rbp),%eax
sub    $0x80,%eax
je     14d3 <weditstr+0x293>
jmp    1439 <weditstr+0x1f9>
mov    -0x160(%rbp),%eax
sub    $0x81,%eax
je     150f <weditstr+0x2cf>
jmp    144f <weditstr+0x20f>
mov    -0x160(%rbp),%eax
sub    $0x82,%eax
je     14e7 <weditstr+0x2a7>
jmp    1465 <weditstr+0x225>
mov    -0x160(%rbp),%eax
add    $0xffffff7d,%eax
sub    $0x2,%eax
jb     1569 <weditstr+0x329>
jmp    147e <weditstr+0x23e>
mov    -0x160(%rbp),%eax
sub    $0x85,%eax
je     14d3 <weditstr+0x293>
jmp    1494 <weditstr+0x254>
mov    -0x160(%rbp),%eax
sub    $0x86,%eax
jne    15af <weditstr+0x36f>
jmp    14aa <weditstr+0x26a>
jmp    190e <weditstr+0x6ce>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1040 <strcpy@plt>
mov    0x2b1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x138(%rbp)
jmp    190e <weditstr+0x6ce>
mov    0x2b06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x138(%rbp)
jmp    190e <weditstr+0x6ce>
mov    -0x130(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    150a <weditstr+0x2ca>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x130(%rbp)
jmp    190e <weditstr+0x6ce>
mov    0x2ab2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    -0x130(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x168(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x168(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jge    1564 <weditstr+0x324>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
jmp    190e <weditstr+0x6ce>
mov    0x2a58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x13c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x13c(%rbp)
mov    -0x13c(%rbp),%ecx
mov    $0x1,%edi
mov    $0x2,%eax
cmp    $0x0,%ecx
cmovne %eax,%edi
call   1160 <curs_set@plt>
jmp    190e <weditstr+0x6ce>
mov    -0x15c(%rbp),%eax
mov    %eax,-0x16c(%rbp)
mov    $0x0,%al
call   1140 <erasechar@plt>
mov    %eax,%ecx
mov    -0x16c(%rbp),%eax
cmp    %ecx,%eax
je     15e7 <weditstr+0x3a7>
mov    -0x15c(%rbp),%eax
mov    0x2a09(%rip),%rcx
cmp    (%rcx),%eax
jne    1655 <weditstr+0x415>
mov    -0x130(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1650 <weditstr+0x410>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x180(%rbp)
mov    -0x130(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x130(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x180(%rbp),%rdi
mov    -0x178(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1120 <memmove@plt>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x130(%rbp)
jmp    1909 <weditstr+0x6c9>
mov    -0x15c(%rbp),%eax
mov    %eax,-0x184(%rbp)
mov    $0x0,%al
call   1100 <killchar@plt>
mov    %eax,%ecx
mov    -0x184(%rbp),%eax
cmp    %ecx,%eax
jne    1692 <weditstr+0x452>
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rax
movb   $0x0,(%rax)
jmp    1904 <weditstr+0x6c4>
mov    -0x15c(%rbp),%eax
mov    %eax,-0x188(%rbp)
mov    $0x0,%al
call   10c0 <wordchar@plt>
mov    %eax,%ecx
mov    -0x188(%rbp),%eax
cmp    %ecx,%eax
jne    17c3 <weditstr+0x583>
mov    -0x130(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x130(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x189(%rbp)
jbe    16f3 <weditstr+0x4b3>
mov    -0x130(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x189(%rbp)
mov    -0x189(%rbp),%al
test   $0x1,%al
jne    1706 <weditstr+0x4c6>
jmp    171d <weditstr+0x4dd>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x130(%rbp)
jmp    16c3 <weditstr+0x483>
jmp    1722 <weditstr+0x4e2>
mov    -0x130(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x18a(%rbp)
jbe    1752 <weditstr+0x512>
mov    -0x130(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x18a(%rbp)
mov    -0x18a(%rbp),%al
test   $0x1,%al
jne    1765 <weditstr+0x525>
jmp    177c <weditstr+0x53c>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x130(%rbp)
jmp    1722 <weditstr+0x4e2>
mov    -0x130(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,-0x198(%rbp)
mov    -0x128(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x1a0(%rbp),%rdi
mov    -0x198(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1120 <memmove@plt>
jmp    18ff <weditstr+0x6bf>
mov    -0x15c(%rbp),%edi
call   1110 <isprint@plt>
cmp    $0x0,%eax
je     18fa <weditstr+0x6ba>
cmpl   $0x0,-0x134(%rbp)
je     1808 <weditstr+0x5c8>
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rax
movb   $0x0,(%rax)
mov    0x27c8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x13c(%rbp)
je     1896 <weditstr+0x656>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1891 <weditstr+0x651>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x130(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
mov    -0x130(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x1b0(%rbp),%rdi
mov    -0x1a8(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1120 <memmove@plt>
mov    -0x15c(%rbp),%eax
mov    %al,%cl
mov    -0x130(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x130(%rbp)
mov    %cl,(%rax)
jmp    18f5 <weditstr+0x6b5>
mov    -0x130(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jge    18f0 <weditstr+0x6b0>
mov    -0x130(%rbp),%rax
cmpb   $0x0,(%rax)
jne    18d1 <weditstr+0x691>
mov    -0x130(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x15c(%rbp),%eax
mov    %al,%cl
mov    -0x130(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x130(%rbp)
mov    %cl,(%rax)
jmp    18f5 <weditstr+0x6b5>
jmp    18fa <weditstr+0x6ba>
jmp    18ff <weditstr+0x6bf>
jmp    1904 <weditstr+0x6c4>
jmp    1909 <weditstr+0x6c9>
jmp    190e <weditstr+0x6ce>
jmp    1399 <weditstr+0x159>
xor    %edi,%edi
call   1160 <curs_set@plt>
mov    -0x158(%rbp),%rdi
mov    -0x150(%rbp),%esi
call   1060 <wattrset@plt>
mov    -0x158(%rbp),%rdi
mov    -0x130(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
call   1150 <repainteditbox@plt>
mov    -0x158(%rbp),%rdi
call   10f0 <delwin@plt>
mov    -0x15c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<weditstr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    $0x86,%ebp
test   %rsi,%rsi
je     15d2 <weditstr+0x392>
mov    %edx,%r13d
cmp    $0xff,%edx
jg     15d2 <weditstr+0x392>
mov    %rsi,%r12
mov    %rdi,%rbx
mov    0x2d65(%rip),%r14
mov    (%r14),%r15d
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rsi,%rdi
call   1070 <strlen@plt>
cmp    %r13d,%eax
jge    15d2 <weditstr+0x392>
mov    %r15d,0x4(%rsp)
lea    0x20(%rsp),%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1090 <wrefresh@plt>
mov    %rbx,%rdi
call   1080 <getyx@plt>
mov    %rbx,%rdi
call   10e0 <getbegyx@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
call   10b0 <subwin@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <getattrs@plt>
mov    %r14,%r15
mov    %eax,%r14d
mov    0x2cd3(%rip),%rax
mov    0x2cdc(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <colorbox@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   10a0 <keypad@plt>
mov    $0x1,%edi
call   1160 <curs_set@plt>
mov    %r12,%r15
cmpl   $0x0,(%rsp)
jne    15a7 <weditstr+0x367>
mov    %r14d,0x14(%rsp)
add    $0xffffffff,%r13d
mov    %r13d,0x10(%rsp)
movslq %r13d,%rax
mov    %rax,0x18(%rsp)
mov    %r12,%r15
movl   $0x0,(%rsp)
mov    %rbx,0x8(%rsp)
jmp    136d <weditstr+0x12d>
mov    %r12,%rdi
lea    0x20(%rsp),%rsi
call   1040 <strcpy@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%r14d
test   %r14d,%r14d
jne    15a2 <weditstr+0x362>
xor    %eax,%eax
call   10d0 <idle@plt>
mov    %r15,%r13
sub    %r12,%r13
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r12,%rdx
call   1150 <repainteditbox@plt>
mov    %rbx,%rdi
call   1130 <wgetch@plt>
mov    %eax,%ebp
cmp    $0x7f,%eax
jle    13e0 <weditstr+0x1a0>
lea    -0x80(%rbp),%eax
cmp    $0x6,%eax
ja     13f7 <weditstr+0x1b7>
lea    0xc5a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
xor    %r14d,%r14d
jmp    *%rax
mov    0x2c0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %r12,%rdi
call   1070 <strlen@plt>
cltq
xor    %ecx,%ecx
cmp    %rax,%r13
setl   %cl
add    %rcx,%r15
xor    %r14d,%r14d
jmp    1364 <weditstr+0x124>
nopl   0x0(%rax)
cmp    $0x9,%ebp
je     1430 <weditstr+0x1f0>
cmp    $0xa,%ebp
je     135a <weditstr+0x11a>
cmp    $0x1b,%ebp
je     134d <weditstr+0x10d>
xor    %eax,%eax
call   1140 <erasechar@plt>
cmp    %eax,%ebp
je     146f <weditstr+0x22f>
mov    0x2bdf(%rip),%rax
cmp    (%rax),%ebp
je     146f <weditstr+0x22f>
xor    %eax,%eax
call   1100 <killchar@plt>
cmp    %eax,%ebp
jne    148f <weditstr+0x24f>
movb   $0x0,(%r12)
xor    %r14d,%r14d
mov    %r12,%r15
jmp    1364 <weditstr+0x124>
nopl   0x0(%rax,%rax,1)
mov    0x2b91(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
xor    %ebx,%ebx
cmpl   $0x0,(%rsp)
sete   %bl
lea    0x1(%rbx),%edi
call   1160 <curs_set@plt>
mov    %ebx,%eax
mov    %ebx,(%rsp)
mov    0x8(%rsp),%rbx
xor    %r14d,%r14d
jmp    1364 <weditstr+0x124>
cmp    %r15,%r12
sbb    $0x0,%r15
xor    %r14d,%r14d
jmp    1364 <weditstr+0x124>
cmp    %r12,%r15
jbe    14ea <weditstr+0x2aa>
mov    %r15,%rbx
add    $0xffffffffffffffff,%r15
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
jmp    14e5 <weditstr+0x2a5>
mov    %r15,%r13
xor    %eax,%eax
call   10c0 <wordchar@plt>
cmp    %eax,%ebp
jne    14f7 <weditstr+0x2b7>
mov    %r13,%rcx
mov    %rcx,%rax
cmp    %r12,%rcx
jbe    14c0 <weditstr+0x280>
lea    -0x1(%rax),%rcx
cmpb   $0x20,-0x1(%rax)
je     14a0 <weditstr+0x260>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,%r15
cmp    %r12,%rax
jbe    14d3 <weditstr+0x293>
lea    -0x1(%r15),%rax
cmpb   $0x20,-0x1(%r15)
jne    14c0 <weditstr+0x280>
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %r13,%rsi
call   1120 <memmove@plt>
xor    %r14d,%r14d
mov    0x8(%rsp),%rbx
jmp    1364 <weditstr+0x124>
mov    %ebp,%edi
call   1110 <isprint@plt>
test   %eax,%eax
je     1520 <weditstr+0x2e0>
cmpl   $0x0,0x4(%rsp)
je     1528 <weditstr+0x2e8>
movb   $0x0,(%r12)
mov    0x2ab3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %r12,%r13
jmp    1530 <weditstr+0x2f0>
xor    %r14d,%r14d
jmp    1364 <weditstr+0x124>
movl   $0x0,0x4(%rsp)
mov    0x10(%rsp),%ebx
cmpl   $0x0,(%rsp)
je     156a <weditstr+0x32a>
mov    %r12,%rdi
call   1070 <strlen@plt>
xor    %r14d,%r14d
cmp    %eax,%ebx
jle    159a <weditstr+0x35a>
lea    0x1(%r13),%r15
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %r13,%rsi
call   1120 <memmove@plt>
mov    %bpl,0x0(%r13)
jmp    14ed <weditstr+0x2ad>
mov    %r13,%rax
sub    %r12,%rax
movl   $0x0,(%rsp)
cmp    0x18(%rsp),%rax
jge    1592 <weditstr+0x352>
cmpb   $0x0,0x0(%r13)
jne    158a <weditstr+0x34a>
movb   $0x0,0x1(%r13)
mov    %bpl,0x0(%r13)
add    $0x1,%r13
mov    %r13,%r15
jmp    14ea <weditstr+0x2aa>
mov    %r13,%r15
jmp    14ed <weditstr+0x2ad>
mov    0x14(%rsp),%r14d
xor    %edi,%edi
call   1160 <curs_set@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <wattrset@plt>
sub    %r12d,%r15d
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
call   1150 <repainteditbox@plt>
mov    %rbx,%rdi
call   10f0 <delwin@plt>
mov    %ebp,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@TRUE = global i32 0
@FALSE = global i32 0
@A_BOLD = global i32 0
@A_REVERSE = global i32 0
@KEY_BACKSPACE = global i32 0
define i32 @weditstr(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [256 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
%20 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%21 = load i8*, i8** %6
store i8* %21, i8** %10
%22 = load i32, i32* @TRUE
store i32 %22, i32* %11
%23 = load i32, i32* @FALSE
store i32 %23, i32* %12
%24 = load i32, i32* @FALSE
store i32 %24, i32* %13
store i32 0, i32* %20
%25 = load i32, i32* %7
%26 = icmp sge i32 %25, 256
br i1 %26, label %37, label %27
27: ; preds = %3
%28 = load i8*, i8** %6
%29 = icmp eq i8* %28, null
br i1 %29, label %37, label %30
30: ; preds = %27
%31 = load i8*, i8** %6
%32 = call i64 @strlen(i8* %31)
%33 = trunc i64 %32 to i32
%34 = load i32, i32* %7
%35 = sub nsw i32 %34, 1
%36 = icmp sgt i32 %33, %35
br i1 %36, label %37, label %38
37: ; preds = %30, %27, %3
store i32 134, i32* %4
br label %286
38: ; preds = %30
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%40 = load i8*, i8** %6
%41 = call i32 @strcpy(i8* %39, i8* %40)
%42 = load i32*, i32** %5
%43 = call i32 @wrefresh(i32* %42)
%44 = load i32*, i32** %5
%45 = load i32, i32* %14
%46 = load i32, i32* %15
%47 = call i32 @getyx(i32* %44, i32 %45, i32 %46)
%48 = load i32*, i32** %5
%49 = load i32, i32* %16
%50 = load i32, i32* %17
%51 = call i32 @getbegyx(i32* %48, i32 %49, i32 %50)
%52 = load i32*, i32** %5
%53 = load i32, i32* %7
%54 = load i32, i32* %16
%55 = load i32, i32* %14
%56 = add nsw i32 %54, %55
%57 = load i32, i32* %17
%58 = load i32, i32* %15
%59 = add nsw i32 %57, %58
%60 = call i32* @subwin(i32* %52, i32 1, i32 %53, i32 %56, i32 %59)
store i32* %60, i32** %19
%61 = load i32*, i32** %19
%62 = call i32 @getattrs(i32* %61)
store i32 %62, i32* %18
%63 = load i32*, i32** %19
%64 = load i32, i32* @A_BOLD
%65 = load i32, i32* @A_REVERSE
%66 = or i32 %64, %65
%67 = call i32 @colorbox(i32* %63, i32 %66, i32 0)
%68 = load i32*, i32** %19
%69 = load i32, i32* @TRUE
%70 = call i32 @keypad(i32* %68, i32 %69)
%71 = call i32 @curs_set(i32 1)
br label %72
72: ; preds = %268, %38
%73 = load i32, i32* %12
%74 = icmp ne i32 %73, 0
%75 = xor i1 %74, true
br i1 %75, label %76, label %269
76: ; preds = %72
%77 = call i32 (...) @idle()
%78 = load i32*, i32** %19
%79 = load i8*, i8** %10
%80 = load i8*, i8** %6
%81 = ptrtoint i8* %79 to i64
%82 = ptrtoint i8* %80 to i64
%83 = sub i64 %81, %82
%84 = trunc i64 %83 to i32
%85 = load i8*, i8** %6
%86 = call i32 @repainteditbox(i32* %78, i32 %84, i8* %85)
%87 = load i32*, i32** %19
%88 = call i32 @wgetch(i32* %87)
store i32 %88, i32* %20
switch i32 %88, label %132 [
i32 134, label %89
i32 27, label %90
i32 10, label %95
i32 128, label %95
i32 133, label %95
i32 130, label %97
i32 129, label %105
i32 9, label %121
i32 131, label %121
i32 132, label %121
]
89: ; preds = %76
br label %268
90: ; preds = %76
%91 = load i8*, i8** %6
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%93 = call i32 @strcpy(i8* %91, i8* %92)
%94 = load i32, i32* @TRUE
store i32 %94, i32* %12
br label %268
95: ; preds = %76, %76, %76
%96 = load i32, i32* @TRUE
store i32 %96, i32* %12
br label %268
97: ; preds = %76
%98 = load i8*, i8** %10
%99 = load i8*, i8** %6
%100 = icmp ugt i8* %98, %99
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = load i8*, i8** %10
%103 = getelementptr inbounds i8, i8* %102, i32 -1
store i8* %103, i8** %10
br label %104
104: ; preds = %101, %97
br label %268
105: ; preds = %76
%106 = load i32, i32* @FALSE
store i32 %106, i32* %11
%107 = load i8*, i8** %10
%108 = load i8*, i8** %6
%109 = ptrtoint i8* %107 to i64
%110 = ptrtoint i8* %108 to i64
%111 = sub i64 %109, %110
%112 = load i8*, i8** %6
%113 = call i64 @strlen(i8* %112)
%114 = trunc i64 %113 to i32
%115 = sext i32 %114 to i64
%116 = icmp slt i64 %111, %115
br i1 %116, label %117, label %120
117: ; preds = %105
%118 = load i8*, i8** %10
%119 = getelementptr inbounds i8, i8* %118, i32 1
store i8* %119, i8** %10
br label %120
120: ; preds = %117, %105
br label %268
121: ; preds = %76, %76, %76
%122 = load i32, i32* @FALSE
store i32 %122, i32* %11
%123 = load i32, i32* %13
%124 = icmp ne i32 %123, 0
%125 = xor i1 %124, true
%126 = zext i1 %125 to i32
store i32 %126, i32* %13
%127 = load i32, i32* %13
%128 = icmp ne i32 %127, 0
%129 = zext i1 %128 to i64
%130 = select i1 %128, i32 2, i32 1
%131 = call i32 @curs_set(i32 %130)
br label %268
132: ; preds = %76
%133 = load i32, i32* %20
%134 = call i32 (...) @erasechar()
%135 = icmp eq i32 %133, %134
br i1 %135, label %140, label %136
136: ; preds = %132
%137 = load i32, i32* %20
%138 = load i32, i32* @KEY_BACKSPACE
%139 = icmp eq i32 %137, %138
br i1 %139, label %140, label %155
140: ; preds = %136, %132
%141 = load i8*, i8** %10
%142 = load i8*, i8** %6
%143 = icmp ugt i8* %141, %142
br i1 %143, label %144, label %154
144: ; preds = %140
%145 = load i8*, i8** %10
%146 = getelementptr inbounds i8, i8* %145, i64 -1
%147 = load i8*, i8** %10
%148 = load i8*, i8** %10
%149 = call i64 @strlen(i8* %148)
%150 = add nsw i64 %149, 1
%151 = call i32 @memmove(i8* %146, i8* %147, i64 %150)
%152 = load i8*, i8** %10
%153 = getelementptr inbounds i8, i8* %152, i32 -1
store i8* %153, i8** %10
br label %154
154: ; preds = %144, %140
br label %267
155: ; preds = %136
%156 = load i32, i32* %20
%157 = call i32 (...) @killchar()
%158 = icmp eq i32 %156, %157
br i1 %158, label %159, label %162
159: ; preds = %155
%160 = load i8*, i8** %6
store i8* %160, i8** %10
%161 = load i8*, i8** %10
store i8 0, i8* %161
br label %266
162: ; preds = %155
%163 = load i32, i32* %20
%164 = call i32 (...) @wordchar()
%165 = icmp eq i32 %163, %164
br i1 %165, label %166, label %206
166: ; preds = %162
%167 = load i8*, i8** %10
store i8* %167, i8** %9
br label %168
168: ; preds = %180, %166
%169 = load i8*, i8** %10
%170 = load i8*, i8** %6
%171 = icmp ugt i8* %169, %170
br i1 %171, label %172, label %178
172: ; preds = %168
%173 = load i8*, i8** %10
%174 = getelementptr inbounds i8, i8* %173, i64 -1
%175 = load i8, i8* %174
%176 = sext i8 %175 to i32
%177 = icmp eq i32 %176, 32
br label %178
178: ; preds = %172, %168
%179 = phi i1 [ false, %168 ], [ %177, %172 ]
br i1 %179, label %180, label %183
180: ; preds = %178
%181 = load i8*, i8** %10
%182 = getelementptr inbounds i8, i8* %181, i32 -1
store i8* %182, i8** %10
br label %168
183: ; preds = %178
br label %184
184: ; preds = %196, %183
%185 = load i8*, i8** %10
%186 = load i8*, i8** %6
%187 = icmp ugt i8* %185, %186
br i1 %187, label %188, label %194
188: ; preds = %184
%189 = load i8*, i8** %10
%190 = getelementptr inbounds i8, i8* %189, i64 -1
%191 = load i8, i8* %190
%192 = sext i8 %191 to i32
%193 = icmp ne i32 %192, 32
br label %194
194: ; preds = %188, %184
%195 = phi i1 [ false, %184 ], [ %193, %188 ]
br i1 %195, label %196, label %199
196: ; preds = %194
%197 = load i8*, i8** %10
%198 = getelementptr inbounds i8, i8* %197, i32 -1
store i8* %198, i8** %10
br label %184
199: ; preds = %194
%200 = load i8*, i8** %10
%201 = load i8*, i8** %9
%202 = load i8*, i8** %9
%203 = call i64 @strlen(i8* %202)
%204 = add nsw i64 %203, 1
%205 = call i32 @memmove(i8* %200, i8* %201, i64 %204)
br label %265
206: ; preds = %162
%207 = load i32, i32* %20
%208 = call i32 @isprint(i32 %207)
%209 = icmp ne i32 %208, 0
br i1 %209, label %210, label %264
210: ; preds = %206
%211 = load i32, i32* %11
%212 = icmp ne i32 %211, 0
br i1 %212, label %213, label %217
213: ; preds = %210
%214 = load i8*, i8** %6
store i8* %214, i8** %10
%215 = load i8*, i8** %10
store i8 0, i8* %215
%216 = load i32, i32* @FALSE
store i32 %216, i32* %11
br label %217
217: ; preds = %213, %210
%218 = load i32, i32* %13
%219 = icmp ne i32 %218, 0
br i1 %219, label %220, label %240
220: ; preds = %217
%221 = load i8*, i8** %6
%222 = call i64 @strlen(i8* %221)
%223 = trunc i64 %222 to i32
%224 = load i32, i32* %7
%225 = sub nsw i32 %224, 1
%226 = icmp slt i32 %223, %225
br i1 %226, label %227, label %239
227: ; preds = %220
%228 = load i8*, i8** %10
%229 = getelementptr inbounds i8, i8* %228, i64 1
%230 = load i8*, i8** %10
%231 = load i8*, i8** %10
%232 = call i64 @strlen(i8* %231)
%233 = add nsw i64 %232, 1
%234 = call i32 @memmove(i8* %229, i8* %230, i64 %233)
%235 = load i32, i32* %20
%236 = trunc i32 %235 to i8
%237 = load i8*, i8** %10
%238 = getelementptr inbounds i8, i8* %237, i32 1
store i8* %238, i8** %10
store i8 %236, i8* %237
br label %239
239: ; preds = %227, %220
br label %263
240: ; preds = %217
%241 = load i8*, i8** %10
%242 = load i8*, i8** %6
%243 = ptrtoint i8* %241 to i64
%244 = ptrtoint i8* %242 to i64
%245 = sub i64 %243, %244
%246 = load i32, i32* %7
%247 = sub nsw i32 %246, 1
%248 = sext i32 %247 to i64
%249 = icmp slt i64 %245, %248
br i1 %249, label %250, label %262
250: ; preds = %240
%251 = load i8*, i8** %10
%252 = load i8, i8* %251
%253 = icmp ne i8 %252, 0
br i1 %253, label %257, label %254
254: ; preds = %250
%255 = load i8*, i8** %10
%256 = getelementptr inbounds i8, i8* %255, i64 1
store i8 0, i8* %256
br label %257
257: ; preds = %254, %250
%258 = load i32, i32* %20
%259 = trunc i32 %258 to i8
%260 = load i8*, i8** %10
%261 = getelementptr inbounds i8, i8* %260, i32 1
store i8* %261, i8** %10
store i8 %259, i8* %260
br label %262
262: ; preds = %257, %240
br label %263
263: ; preds = %262, %239
br label %264
264: ; preds = %263, %206
br label %265
265: ; preds = %264, %199
br label %266
266: ; preds = %265, %159
br label %267
267: ; preds = %266, %154
br label %268
268: ; preds = %267, %121, %120, %104, %95, %90, %89
br label %72
269: ; preds = %72
%270 = call i32 @curs_set(i32 0)
%271 = load i32*, i32** %19
%272 = load i32, i32* %18
%273 = call i32 @wattrset(i32* %271, i32 %272)
%274 = load i32*, i32** %19
%275 = load i8*, i8** %10
%276 = load i8*, i8** %6
%277 = ptrtoint i8* %275 to i64
%278 = ptrtoint i8* %276 to i64
%279 = sub i64 %277, %278
%280 = trunc i64 %279 to i32
%281 = load i8*, i8** %6
%282 = call i32 @repainteditbox(i32* %274, i32 %280, i8* %281)
%283 = load i32*, i32** %19
%284 = call i32 @delwin(i32* %283)
%285 = load i32, i32* %20
store i32 %285, i32* %4
br label %286
286: ; preds = %269, %37
%287 = load i32, i32* %4
ret i32 %287
}

LLVM IR (-O2):
@TRUE = global i32 0
@FALSE = global i32 0
@A_BOLD = global i32 0
@A_REVERSE = global i32 0
@KEY_BACKSPACE = global i32 0
define i32 @weditstr(i32* %0, i8* %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @TRUE
%7 = load i32, i32* @FALSE
%8 = icmp sgt i32 %2, 255
%9 = icmp eq i8* %1, null
%10 = or i1 %9, %8
br i1 %10, label %156, label %11
11: ; preds = %3
%12 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%13 = trunc i64 %12 to i32
%14 = add nsw i32 %2, -1
%15 = icmp slt i32 %13, %2
br i1 %15, label %16, label %156
16: ; preds = %11
%17 = call i32 @strcpy(i8* %5, i8* %1)
%18 = call i32 @wrefresh(i32* %0)
%19 = call i32 @getyx(i32* %0, i32 undef, i32 undef)
%20 = call i32 @getbegyx(i32* %0, i32 undef, i32 undef)
%21 = call i32* @subwin(i32* %0, i32 1, i32 %2, i32 undef, i32 undef)
%22 = call i32 @getattrs(i32* %21)
%23 = load i32, i32* @A_BOLD
%24 = load i32, i32* @A_REVERSE
%25 = or i32 %24, %23
%26 = call i32 @colorbox(i32* %21, i32 %25, i32 0)
%27 = load i32, i32* @TRUE
%28 = call i32 @keypad(i32* %21, i32 %27)
%29 = call i32 @curs_set(i32 1)
%30 = icmp eq i32 %7, 0
%31 = ptrtoint i8* %1 to i64
br i1 %30, label %32, label %147
32: ; preds = %16
%33 = sext i32 %14 to i64
br label %34
34: ; preds = %32, %139
%35 = phi i8* [ %1, %32 ], [ %143, %139 ]
%36 = phi i32 [ %6, %32 ], [ %142, %139 ]
%37 = phi i32 [ 0, %32 ], [ %140, %139 ]
%38 = call i32 (...) @idle()
%39 = ptrtoint i8* %35 to i64
%40 = sub i64 %39, %31
%41 = trunc i64 %40 to i32
%42 = call i32 @repainteditbox(i32* %21, i32 %41, i8* %1)
%43 = call i32 @wgetch(i32* %21)
switch i32 %43, label %67 [
i32 134, label %139
i32 27, label %44
i32 10, label %47
i32 128, label %47
i32 133, label %47
i32 130, label %49
i32 129, label %53
i32 9, label %61
i32 131, label %61
i32 132, label %61
]
44: ; preds = %34
%45 = call i32 @strcpy(i8* %1, i8* %5)
%46 = load i32, i32* @TRUE
br label %139
47: ; preds = %34, %34, %34
%48 = load i32, i32* @TRUE
br label %139
49: ; preds = %34
%50 = icmp ugt i8* %35, %1
%51 = sext i1 %50 to i64
%52 = getelementptr i8, i8* %35, i64 %51
br label %139
53: ; preds = %34
%54 = load i32, i32* @FALSE
%55 = call i64 @strlen(i8* dereferenceable(1) %1)
%56 = shl i64 %55, 32
%57 = ashr exact i64 %56, 32
%58 = icmp slt i64 %40, %57
%59 = zext i1 %58 to i64
%60 = getelementptr i8, i8* %35, i64 %59
br label %139
61: ; preds = %34, %34, %34
%62 = load i32, i32* @FALSE
%63 = icmp eq i32 %37, 0
%64 = zext i1 %63 to i32
%65 = select i1 %63, i32 2, i32 1
%66 = call i32 @curs_set(i32 %65)
br label %139
67: ; preds = %34
%68 = call i32 (...) @erasechar()
%69 = icmp eq i32 %43, %68
%70 = load i32, i32* @KEY_BACKSPACE
%71 = icmp eq i32 %43, %70
%72 = select i1 %69, i1 true, i1 %71
br i1 %72, label %73, label %80
73: ; preds = %67
%74 = icmp ugt i8* %35, %1
br i1 %74, label %75, label %139
75: ; preds = %73
%76 = getelementptr inbounds i8, i8* %35, i64 -1
%77 = call i64 @strlen(i8* dereferenceable(1) %35)
%78 = add nsw i64 %77, 1
%79 = call i32 @memmove(i8* %76, i8* %35, i64 %78)
br label %139
80: ; preds = %67
%81 = call i32 (...) @killchar()
%82 = icmp eq i32 %43, %81
br i1 %82, label %83, label %84
83: ; preds = %80
store i8 0, i8* %1
br label %139
84: ; preds = %80
%85 = call i32 (...) @wordchar()
%86 = icmp eq i32 %43, %85
br i1 %86, label %87, label %106
87: ; preds = %84, %90
%88 = phi i8* [ %91, %90 ], [ %35, %84 ]
%89 = icmp ugt i8* %88, %1
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = getelementptr inbounds i8, i8* %88, i64 -1
%92 = load i8, i8* %91
%93 = icmp eq i8 %92, 32
br i1 %93, label %87, label %94
94: ; preds = %87, %90
br label %95
95: ; preds = %94, %98
%96 = phi i8* [ %99, %98 ], [ %88, %94 ]
%97 = icmp ugt i8* %96, %1
br i1 %97, label %98, label %102
98: ; preds = %95
%99 = getelementptr inbounds i8, i8* %96, i64 -1
%100 = load i8, i8* %99
%101 = icmp eq i8 %100, 32
br i1 %101, label %102, label %95
102: ; preds = %95, %98
%103 = call i64 @strlen(i8* dereferenceable(1) %35)
%104 = add nsw i64 %103, 1
%105 = call i32 @memmove(i8* %96, i8* %35, i64 %104)
br label %139
106: ; preds = %84
%107 = call i32 @isprint(i32 %43)
%108 = icmp eq i32 %107, 0
br i1 %108, label %139, label %109
109: ; preds = %106
%110 = icmp eq i32 %36, 0
br i1 %110, label %113, label %111
111: ; preds = %109
store i8 0, i8* %1
%112 = load i32, i32* @FALSE
br label %113
113: ; preds = %111, %109
%114 = phi i32 [ %112, %111 ], [ 0, %109 ]
%115 = phi i8* [ %1, %111 ], [ %35, %109 ]
%116 = icmp eq i32 %37, 0
br i1 %116, label %127, label %117
117: ; preds = %113
%118 = call i64 @strlen(i8* dereferenceable(1) %1)
%119 = trunc i64 %118 to i32
%120 = icmp sgt i32 %14, %119
br i1 %120, label %121, label %139
121: ; preds = %117
%122 = getelementptr inbounds i8, i8* %115, i64 1
%123 = call i64 @strlen(i8* dereferenceable(1) %115)
%124 = add nsw i64 %123, 1
%125 = call i32 @memmove(i8* %122, i8* %115, i64 %124)
%126 = trunc i32 %43 to i8
store i8 %126, i8* %115
br label %139
127: ; preds = %113
%128 = ptrtoint i8* %115 to i64
%129 = sub i64 %128, %31
%130 = icmp slt i64 %129, %33
br i1 %130, label %131, label %139
131: ; preds = %127
%132 = load i8, i8* %115
%133 = icmp eq i8 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %131
%135 = getelementptr inbounds i8, i8* %115, i64 1
store i8 0, i8* %135
br label %136
136: ; preds = %134, %131
%137 = trunc i32 %43 to i8
%138 = getelementptr inbounds i8, i8* %115, i64 1
store i8 %137, i8* %115
br label %139
139: ; preds = %53, %49, %75, %73, %102, %121, %117, %136, %127, %106, %83, %61, %47, %44, %34
%140 = phi i32 [ %37, %75 ], [ %37, %73 ], [ %37, %83 ], [ %37, %102 ], [ %37, %121 ], [ %37, %117 ], [ 0, %136 ], [ 0, %127 ], [ %37, %106 ], [ %64, %61 ], [ %37, %47 ], [ %37, %44 ], [ %37, %34 ], [ %37, %49 ], [ %37, %53 ]
%141 = phi i32 [ 0, %75 ], [ 0, %73 ], [ 0, %83 ], [ 0, %102 ], [ 0, %121 ], [ 0, %117 ], [ 0, %136 ], [ 0, %127 ], [ 0, %106 ], [ 0, %61 ], [ %48, %47 ], [ %46, %44 ], [ 0, %34 ], [ 0, %49 ], [ 0, %53 ]
%142 = phi i32 [ %36, %75 ], [ %36, %73 ], [ %36, %83 ], [ %36, %102 ], [ %114, %121 ], [ %114, %117 ], [ %114, %136 ], [ %114, %127 ], [ %36, %106 ], [ %62, %61 ], [ %36, %47 ], [ %36, %44 ], [ %36, %34 ], [ %36, %49 ], [ %54, %53 ]
%143 = phi i8* [ %76, %75 ], [ %35, %73 ], [ %1, %83 ], [ %96, %102 ], [ %122, %121 ], [ %115, %117 ], [ %138, %136 ], [ %115, %127 ], [ %35, %106 ], [ %35, %61 ], [ %35, %47 ], [ %35, %44 ], [ %35, %34 ], [ %52, %49 ], [ %60, %53 ]
%144 = icmp eq i32 %141, 0
br i1 %144, label %34, label %145
145: ; preds = %139
%146 = ptrtoint i8* %143 to i64
br label %147
147: ; preds = %16, %145
%148 = phi i64 [ %146, %145 ], [ %31, %16 ]
%149 = phi i32 [ %43, %145 ], [ 0, %16 ]
%150 = call i32 @curs_set(i32 0)
%151 = call i32 @wattrset(i32* %21, i32 %22)
%152 = sub i64 %148, %31
%153 = trunc i64 %152 to i32
%154 = call i32 @repainteditbox(i32* %21, i32 %153, i8* %1)
%155 = call i32 @delwin(i32* %21)
br label %156
156: ; preds = %3, %11, %147
%157 = phi i32 [ %149, %147 ], [ 134, %11 ], [ 134, %3 ]
ret i32 %157
}