#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 LINES;
int /*<<< orphan*/ doupdate();
int /*<<< orphan*/ update_panels();
void scrollbreakwin(WINDOW *breakwin, int *offset, int total, int direction) {
  if (direction == 1) {
    if ((total - *offset) >= (LINES - 27)) {
      *offset = *offset + 1;
    }
  } else {
    if (*offset > 0) {
      *offset = *offset - 1;
    }
  }
  update_panels();
  doupdate();
}


x86 assembly (clang, -O0):
<scrollbreakwin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1171 <scrollbreakwin+0x51>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%eax
mov    0x2e98(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1b,%ecx
cmp    %ecx,%eax
jl     116c <scrollbreakwin+0x4c>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1192 <scrollbreakwin+0x72>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    118d <scrollbreakwin+0x6d>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1192 <scrollbreakwin+0x72>
mov    $0x0,%al
call   1030 <update_panels@plt>
mov    $0x0,%al
call   1040 <doupdate@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scrollbreakwin>:
push   %rax
mov    (%rsi),%eax
cmp    $0x1,%ecx
jne    1141 <scrollbreakwin+0x21>
sub    %eax,%edx
mov    0x2eb7(%rip),%rcx
mov    (%rcx),%edi
add    $0xffffffe5,%edi
mov    $0x1,%ecx
cmp    %edi,%edx
jge    114a <scrollbreakwin+0x2a>
jmp    114e <scrollbreakwin+0x2e>
mov    $0xffffffff,%ecx
test   %eax,%eax
jle    114e <scrollbreakwin+0x2e>
add    %ecx,%eax
mov    %eax,(%rsi)
xor    %eax,%eax
call   1030 <update_panels@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <doupdate@plt>

LLVM IR (-O0):
@LINES = global i32 0
define void @scrollbreakwin(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %25
11: ; preds = %4
%12 = load i32, i32* %7
%13 = load i32*, i32** %6
%14 = load i32, i32* %13
%15 = sub nsw i32 %12, %14
%16 = load i32, i32* @LINES
%17 = sub nsw i32 %16, 27
%18 = icmp sge i32 %15, %17
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = load i32*, i32** %6
store i32 %22, i32* %23
br label %24
24: ; preds = %19, %11
br label %35
25: ; preds = %4
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = sub nsw i32 %31, 1
%33 = load i32*, i32** %6
store i32 %32, i32* %33
br label %34
34: ; preds = %29, %25
br label %35
35: ; preds = %34, %24
%36 = call i32 (...) @update_panels()
%37 = call i32 (...) @doupdate()
ret void
}

LLVM IR (-O2):
@LINES = global i32 0
define void @scrollbreakwin(i32* nocapture readnone %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 1
%6 = load i32, i32* %1
br i1 %5, label %7, label %12
7: ; preds = %4
%8 = sub nsw i32 %2, %6
%9 = load i32, i32* @LINES
%10 = add nsw i32 %9, -27
%11 = icmp slt i32 %8, %10
br i1 %11, label %17, label %14
12: ; preds = %4
%13 = icmp sgt i32 %6, 0
br i1 %13, label %14, label %17
14: ; preds = %12, %7
%15 = phi i32 [ 1, %7 ], [ -1, %12 ]
%16 = add nsw i32 %6, %15
store i32 %16, i32* %1
br label %17
17: ; preds = %14, %12, %7
%18 = tail call i32 (...) @update_panels()
%19 = tail call i32 (...) @doupdate()
ret void
}