#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int _regbottom;
  scalar_t__ _scroll;
};
typedef TYPE_1__ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ scroll(TYPE_1__ *);
short newline(WINDOW *win, int lin) {
  if (++lin > win->_regbottom) {
    lin--;
    if (win->_scroll)
      scroll(win);
    else
      return (-1);
  }
  return (lin);
}


x86 assembly (clang, -O0):
<newline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jle    116a <newline+0x5a>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     115a <newline+0x4a>
mov    -0x10(%rbp),%rdi
call   1030 <scroll@plt>
jmp    1165 <newline+0x55>
movw   $0xffff,-0x2(%rbp)
jmp    1171 <newline+0x61>
jmp    116a <newline+0x5a>
mov    -0x14(%rbp),%eax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newline>:
push   %rbx
mov    %esi,%ebx
cmp    %esi,(%rdi)
jle    111c <newline+0xc>
add    $0x1,%ebx
jmp    112e <newline+0x1e>
cmpq   $0x0,0x8(%rdi)
je     112a <newline+0x1a>
call   1030 <scroll@plt>
jmp    112e <newline+0x1e>
mov    $0xffff,%bx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i64 }
define signext i16 @newline(%struct.TYPE_4__* %0, i32 %1) {
%3 = alloca i16
%4 = alloca %struct.TYPE_4__*
%5 = alloca i32
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1
store i32 %7, i32* %5
%8 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = icmp sgt i32 %7, %10
br i1 %11, label %12, label %24
12: ; preds = %2
%13 = load i32, i32* %5
%14 = add nsw i32 %13, -1
store i32 %14, i32* %5
%15 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%21 = call i32 @scroll(%struct.TYPE_4__* %20)
br label %23
22: ; preds = %12
store i16 -1, i16* %3
br label %27
23: ; preds = %19
br label %24
24: ; preds = %23, %2
%25 = load i32, i32* %5
%26 = trunc i32 %25 to i16
store i16 %26, i16* %3
br label %27
27: ; preds = %24, %22
%28 = load i16, i16* %3
ret i16 %28
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i64 }
define signext i16 @newline(%struct.TYPE_4__* %0, i32 %1) {
%3 = add nsw i32 %1, 1
%4 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp sgt i32 %5, %1
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 1
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = tail call i32 @scroll(%struct.TYPE_4__* %0)
br label %13
13: ; preds = %11, %2
%14 = phi i32 [ %1, %11 ], [ %3, %2 ]
%15 = trunc i32 %14 to i16
br label %16
16: ; preds = %7, %13
%17 = phi i16 [ %15, %13 ], [ -1, %7 ]
ret i16 %17
}