#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int _cury;
  int _curx;
};

/* Variables and functions */
int COLS;
int LINES;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ clearok(TYPE_1__ *, int /*<<< orphan*/);
TYPE_1__ *curscr;
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ getyx(TYPE_1__ *, int, int);
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int);
int /*<<< orphan*/ md_tstpresume();
int /*<<< orphan*/ md_tstpsignal();
int /*<<< orphan*/ mvcur(int, int, int, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ playltchars();
int /*<<< orphan*/ raw();
int /*<<< orphan*/ resetltchars();
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ wrefresh(TYPE_1__ *);
void tstp(int ignored) {
  int y, x;
  int oy, ox;
  (ignored += 0);
  getyx(curscr, oy, ox);
  mvcur(0, COLS - 1, LINES - 1, 0);
  endwin();
  resetltchars();
  fflush(stdout);
  md_tstpsignal();
  md_tstpresume();
  raw();
  noecho();
  keypad(stdscr, 1);
  playltchars();
  clearok(curscr, TRUE);
  wrefresh(curscr);
  getyx(curscr, y, x);
  mvcur(y, x, oy, ox);
  fflush(stdout);
  curscr->_cury = oy;
  curscr->_curx = ox;
}


x86 assembly (clang, -O0):
<tstp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0x4(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <getyx@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
sub    $0x1,%esi
mov    0x2ddc(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
xor    %ecx,%ecx
mov    %ecx,%edi
call   1050 <mvcur@plt>
mov    $0x0,%al
call   10d0 <endwin@plt>
mov    $0x0,%al
call   1040 <resetltchars@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    $0x0,%al
call   10a0 <md_tstpsignal@plt>
mov    $0x0,%al
call   10c0 <md_tstpresume@plt>
mov    $0x0,%al
call   1090 <raw@plt>
mov    $0x0,%al
call   10e0 <noecho@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1080 <keypad@plt>
mov    $0x0,%al
call   10f0 <playltchars@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%rdi
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
call   1030 <clearok@plt>
mov    0x2d25(%rip),%rax
mov    (%rax),%rdi
call   1070 <wrefresh@plt>
mov    0x2d16(%rip),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <getyx@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1050 <mvcur@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    -0x10(%rbp),%ecx
mov    0x2cdf(%rip),%rax
mov    (%rax),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    0x2cd0(%rip),%rax
mov    (%rax),%rax
mov    %ecx,0x4(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tstp>:
push   %r14
push   %rbx
push   %rax
mov    0x2dd5(%rip),%rbx
mov    (%rbx),%rdi
call   1060 <getyx@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
add    $0xffffffff,%esi
mov    0x2df2(%rip),%rax
mov    (%rax),%edx
add    $0xffffffff,%edx
xor    %edi,%edi
xor    %ecx,%ecx
call   1050 <mvcur@plt>
xor    %eax,%eax
call   10d0 <endwin@plt>
xor    %eax,%eax
call   1040 <resetltchars@plt>
mov    0x2da7(%rip),%r14
mov    (%r14),%edi
call   10b0 <fflush@plt>
xor    %eax,%eax
call   10a0 <md_tstpsignal@plt>
xor    %eax,%eax
call   10c0 <md_tstpresume@plt>
xor    %eax,%eax
call   1090 <raw@plt>
xor    %eax,%eax
call   10e0 <noecho@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1080 <keypad@plt>
xor    %eax,%eax
call   10f0 <playltchars@plt>
mov    (%rbx),%rdi
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
call   1030 <clearok@plt>
mov    (%rbx),%rdi
call   1070 <wrefresh@plt>
mov    (%rbx),%rdi
call   1060 <getyx@plt>
call   1050 <mvcur@plt>
mov    (%r14),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    10b0 <fflush@plt>

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32 }
@curscr = global %struct.TYPE_5__* null
@COLS = global i32 0
@LINES = global i32 0
@stdout = global i32 0
@stdscr = global i32 0
@TRUE = global i32 0
define void @tstp(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 0
store i32 %8, i32* %2
%9 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @getyx(%struct.TYPE_5__* %9, i32 %10, i32 %11)
%13 = load i32, i32* @COLS
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* @LINES
%16 = sub nsw i32 %15, 1
%17 = call i32 @mvcur(i32 0, i32 %14, i32 %16, i32 0)
%18 = call i32 (...) @endwin()
%19 = call i32 (...) @resetltchars()
%20 = load i32, i32* @stdout
%21 = call i32 @fflush(i32 %20)
%22 = call i32 (...) @md_tstpsignal()
%23 = call i32 (...) @md_tstpresume()
%24 = call i32 (...) @raw()
%25 = call i32 (...) @noecho()
%26 = load i32, i32* @stdscr
%27 = call i32 @keypad(i32 %26, i32 1)
%28 = call i32 (...) @playltchars()
%29 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%30 = load i32, i32* @TRUE
%31 = call i32 @clearok(%struct.TYPE_5__* %29, i32 %30)
%32 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%33 = call i32 @wrefresh(%struct.TYPE_5__* %32)
%34 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = call i32 @getyx(%struct.TYPE_5__* %34, i32 %35, i32 %36)
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = call i32 @mvcur(i32 %38, i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* @stdout
%44 = call i32 @fflush(i32 %43)
%45 = load i32, i32* %5
%46 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%47 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %46, i32 0, i32 0
store i32 %45, i32* %47
%48 = load i32, i32* %6
%49 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%50 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %49, i32 0, i32 1
store i32 %48, i32* %50
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32 }
@curscr = global %struct.TYPE_5__* null
@COLS = global i32 0
@LINES = global i32 0
@stdout = global i32 0
@stdscr = global i32 0
@TRUE = global i32 0
define void @tstp(i32 %0) {
%2 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%3 = tail call i32 @getyx(%struct.TYPE_5__* %2, i32 undef, i32 undef)
%4 = load i32, i32* @COLS
%5 = add nsw i32 %4, -1
%6 = load i32, i32* @LINES
%7 = add nsw i32 %6, -1
%8 = tail call i32 @mvcur(i32 0, i32 %5, i32 %7, i32 0)
%9 = tail call i32 (...) @endwin()
%10 = tail call i32 (...) @resetltchars()
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
%13 = tail call i32 (...) @md_tstpsignal()
%14 = tail call i32 (...) @md_tstpresume()
%15 = tail call i32 (...) @raw()
%16 = tail call i32 (...) @noecho()
%17 = load i32, i32* @stdscr
%18 = tail call i32 @keypad(i32 %17, i32 1)
%19 = tail call i32 (...) @playltchars()
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%21 = load i32, i32* @TRUE
%22 = tail call i32 @clearok(%struct.TYPE_5__* %20, i32 %21)
%23 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%24 = tail call i32 @wrefresh(%struct.TYPE_5__* %23)
%25 = load %struct.TYPE_5__*, %struct.TYPE_5__** @curscr
%26 = tail call i32 @getyx(%struct.TYPE_5__* %25, i32 undef, i32 undef)
%27 = tail call i32 @mvcur(i32 undef, i32 undef, i32 undef, i32 undef)
%28 = load i32, i32* @stdout
%29 = tail call i32 @fflush(i32 %28)
ret void
}