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

/* Variables and functions */
int LINES;
char *getbufend();
char *getbufstart();
int /*<<< orphan*/ move(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvaddch(int, int /*<<< orphan*/, char);
scalar_t__ screenlines(char *);
int scroll_line();
char *skipscreenlines(char *, int);
void draw_eof(void) {
  char *start = skipscreenlines(getbufstart(), scroll_line());
  int r = 0;
  while (start != getbufend() && r < LINES - 1) {
    r += screenlines(start);
    start = skipscreenlines(start, 1);
  }
  for (; r < LINES - 1; ++r)
    mvaddch(r, 0, '~');
  move(0, 0);
}


x86 assembly (clang, -O0):
<draw_eof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1040 <getbufstart@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <scroll_line@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1060 <skipscreenlines@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <getbufend@plt>
mov    -0x28(%rbp),%rcx
mov    %rax,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x19(%rbp)
je     11db <draw_eof+0x6b>
mov    -0xc(%rbp),%eax
mov    0x2e1a(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11eb <draw_eof+0x7b>
jmp    1218 <draw_eof+0xa8>
mov    -0x8(%rbp),%rdi
call   1050 <screenlines@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1060 <skipscreenlines@plt>
mov    %rax,-0x8(%rbp)
jmp    11a0 <draw_eof+0x30>
jmp    121d <draw_eof+0xad>
mov    -0xc(%rbp),%eax
mov    0x2dc1(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1251 <draw_eof+0xe1>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
mov    $0x7e,%edx
call   1080 <mvaddch@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    121d <draw_eof+0xad>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <move@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_eof>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getbufstart@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1070 <scroll_line@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <skipscreenlines@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <getbufend@plt>
mov    0x2e43(%rip),%r15
mov    (%r15),%ecx
cmp    %rax,%r14
je     11f7 <draw_eof+0x87>
cmp    $0x2,%ecx
jl     11f7 <draw_eof+0x87>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%ebp
mov    %r14,%rdi
call   1050 <screenlines@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %r14,%rdi
mov    $0x1,%esi
call   1060 <skipscreenlines@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <getbufend@plt>
mov    (%r15),%ecx
add    $0xffffffff,%ecx
cmp    %rax,%r14
je     11fa <draw_eof+0x8a>
cmp    %ecx,%ebx
jl     11c0 <draw_eof+0x50>
jmp    11fa <draw_eof+0x8a>
add    $0xffffffff,%ecx
cmp    %ecx,%ebx
jge    121b <draw_eof+0xab>
xchg   %ax,%ax
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x7e,%edx
call   1080 <mvaddch@plt>
add    $0x1,%ebx
mov    (%r15),%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     1200 <draw_eof+0x90>
xor    %edi,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <move@plt>

LLVM IR (-O0):
@LINES = global i32 0
define void @draw_eof() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i8* (...) @getbufstart()
%4 = call i32 (...) @scroll_line()
%5 = call i8* @skipscreenlines(i8* %3, i32 %4)
store i8* %5, i8** %1
store i32 0, i32* %2
br label %6
6: ; preds = %17, %0
%7 = load i8*, i8** %1
%8 = call i8* (...) @getbufend()
%9 = icmp ne i8* %7, %8
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = load i32, i32* %2
%12 = load i32, i32* @LINES
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br label %15
15: ; preds = %10, %6
%16 = phi i1 [ false, %6 ], [ %14, %10 ]
br i1 %16, label %17, label %26
17: ; preds = %15
%18 = load i8*, i8** %1
%19 = call i64 @screenlines(i8* %18)
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = add nsw i64 %21, %19
%23 = trunc i64 %22 to i32
store i32 %23, i32* %2
%24 = load i8*, i8** %1
%25 = call i8* @skipscreenlines(i8* %24, i32 1)
store i8* %25, i8** %1
br label %6
26: ; preds = %15
br label %27
27: ; preds = %35, %26
%28 = load i32, i32* %2
%29 = load i32, i32* @LINES
%30 = sub nsw i32 %29, 1
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = load i32, i32* %2
%34 = call i32 @mvaddch(i32 %33, i32 0, i8 signext 126)
br label %35
35: ; preds = %32
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %27
38: ; preds = %27
%39 = call i32 @move(i32 0, i32 0)
ret void
}

LLVM IR (-O2):
@LINES = global i32 0
define void @draw_eof() {
%1 = tail call i8* (...) @getbufstart()
%2 = tail call i32 (...) @scroll_line()
%3 = tail call i8* @skipscreenlines(i8* %1, i32 %2)
%4 = tail call i8* (...) @getbufend()
%5 = icmp ne i8* %3, %4
%6 = load i32, i32* @LINES
%7 = icmp sgt i32 %6, 1
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %15, label %9
9: ; preds = %0
%10 = add nsw i32 %6, -1
br label %11
11: ; preds = %15, %9
%12 = phi i32 [ %10, %9 ], [ %25, %15 ]
%13 = phi i32 [ 0, %9 ], [ %20, %15 ]
%14 = icmp slt i32 %13, %12
br i1 %14, label %28, label %35
15: ; preds = %0, %15
%16 = phi i32 [ %20, %15 ], [ 0, %0 ]
%17 = phi i8* [ %21, %15 ], [ %3, %0 ]
%18 = tail call i64 @screenlines(i8* %17)
%19 = trunc i64 %18 to i32
%20 = add i32 %16, %19
%21 = tail call i8* @skipscreenlines(i8* %17, i32 1)
%22 = tail call i8* (...) @getbufend()
%23 = icmp ne i8* %21, %22
%24 = load i32, i32* @LINES
%25 = add nsw i32 %24, -1
%26 = icmp slt i32 %20, %25
%27 = select i1 %23, i1 %26, i1 false
br i1 %27, label %15, label %11
28: ; preds = %11, %28
%29 = phi i32 [ %31, %28 ], [ %13, %11 ]
%30 = tail call i32 @mvaddch(i32 %29, i32 0, i8 signext 126)
%31 = add nsw i32 %29, 1
%32 = load i32, i32* @LINES
%33 = add nsw i32 %32, -1
%34 = icmp slt i32 %31, %33
br i1 %34, label %28, label %35
35: ; preds = %28, %11
%36 = tail call i32 @move(i32 0, i32 0)
ret void
}