#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*/ WINDOW;

/* Variables and functions */
int getmaxx(int /*<<< orphan*/ *);
int getmaxy(int /*<<< orphan*/ *);
int getparx(int /*<<< orphan*/ *);
int getpary(int /*<<< orphan*/ *);
int /*<<< orphan*/ mvderwin(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ wresize(int /*<<< orphan*/ *, int, int);
void wshrink(WINDOW *win, int top) {
  int x = getparx(win);
  int y = getpary(win);
  int r = getmaxy(win);
  int c = getmaxx(win);
  int rows = r + (y - top);
  if (top < y)
    mvderwin(win, top, x);
  if (rows != r)
    wresize(win, rows, c);
  if (top > y)
    mvderwin(win, top, x);
}


x86 assembly (clang, -O0):
<wshrink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getparx@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <getpary@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getmaxy@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getmaxx@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c8 <wshrink+0x68>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <mvderwin@plt>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11e3 <wshrink+0x83>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <wresize@plt>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11fe <wshrink+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <mvderwin@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wshrink>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1050 <getparx@plt>
mov    %eax,(%rsp)
mov    %rbx,%rdi
call   1080 <getpary@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1030 <getmaxy@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1070 <getmaxx@plt>
mov    %r13d,%r15d
sub    %ebp,%r15d
mov    %r13d,%r14d
sub    %ebp,%r14d
jle    11b9 <wshrink+0x59>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    (%rsp),%edx
mov    %eax,0x4(%rsp)
call   1060 <mvderwin@plt>
mov    0x4(%rsp),%eax
test   %r14d,%r14d
je     11ce <wshrink+0x6e>
add    %r15d,%r12d
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   1040 <wresize@plt>
cmp    %ebp,%r13d
jge    11ee <wshrink+0x8e>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    (%rsp),%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <mvderwin@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @wshrink(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%10 = load i32*, i32** %3
%11 = call i32 @getparx(i32* %10)
store i32 %11, i32* %5
%12 = load i32*, i32** %3
%13 = call i32 @getpary(i32* %12)
store i32 %13, i32* %6
%14 = load i32*, i32** %3
%15 = call i32 @getmaxy(i32* %14)
store i32 %15, i32* %7
%16 = load i32*, i32** %3
%17 = call i32 @getmaxx(i32* %16)
store i32 %17, i32* %8
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = sub nsw i32 %19, %20
%22 = add nsw i32 %18, %21
store i32 %22, i32* %9
%23 = load i32, i32* %4
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %2
%27 = load i32*, i32** %3
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i32 @mvderwin(i32* %27, i32 %28, i32 %29)
br label %31
31: ; preds = %26, %2
%32 = load i32, i32* %9
%33 = load i32, i32* %7
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32*, i32** %3
%37 = load i32, i32* %9
%38 = load i32, i32* %8
%39 = call i32 @wresize(i32* %36, i32 %37, i32 %38)
br label %40
40: ; preds = %35, %31
%41 = load i32, i32* %4
%42 = load i32, i32* %6
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32*, i32** %3
%46 = load i32, i32* %4
%47 = load i32, i32* %5
%48 = call i32 @mvderwin(i32* %45, i32 %46, i32 %47)
br label %49
49: ; preds = %44, %40
ret void
}

LLVM IR (-O2):
define void @wshrink(i32* %0, i32 %1) {
%3 = tail call i32 @getparx(i32* %0)
%4 = tail call i32 @getpary(i32* %0)
%5 = tail call i32 @getmaxy(i32* %0)
%6 = tail call i32 @getmaxx(i32* %0)
%7 = sub nsw i32 %4, %1
%8 = add nsw i32 %5, %7
%9 = icmp sgt i32 %4, %1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @mvderwin(i32* %0, i32 %1, i32 %3)
br label %12
12: ; preds = %10, %2
%13 = icmp eq i32 %7, 0
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i32 @wresize(i32* %0, i32 %8, i32 %6)
br label %16
16: ; preds = %14, %12
%17 = icmp slt i32 %4, %1
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = tail call i32 @mvderwin(i32* %0, i32 %1, i32 %3)
br label %20
20: ; preds = %18, %16
ret void
}