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

/* Variables and functions */
int /*<<< orphan*/ COLOR_PAIR(int);
int LINES;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ mvaddstr(int, int /*<<< orphan*/, char *);
scalar_t__ screenlines(char *);
int scroll_line();
char *skipscreenlines(int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ winstart();
void drawlineoverlay(void) {
  int lineno = scroll_line() + 1;
  int screenline = 0;
  int fileline = 0;
  attron(COLOR_PAIR(3));
  while (screenline < LINES) {
    char nstr[32];
    snprintf(nstr, sizeof(nstr), "%4d", lineno);
    mvaddstr(screenline, 0, nstr);
    char *lstart = skipscreenlines(winstart(), fileline);
    if (lstart == NULL)
      break;
    screenline += screenlines(lstart);
    fileline++;
    lineno++;
  }
  attroff(COLOR_PAIR(3));
}


x86 assembly (clang, -O0):
<drawlineoverlay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   10a0 <scroll_line@plt>
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x3,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    -0x8(%rbp),%eax
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%eax
jge    124e <drawlineoverlay+0xbe>
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x20,%esi
lea    0xe17(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rdx
xor    %esi,%esi
call   10b0 <mvaddstr@plt>
mov    $0x0,%al
call   1070 <winstart@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1090 <skipscreenlines@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1221 <drawlineoverlay+0x91>
jmp    124e <drawlineoverlay+0xbe>
mov    -0x38(%rbp),%rdi
call   1080 <screenlines@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <drawlineoverlay+0x34>
mov    $0x3,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawlineoverlay>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   10a0 <scroll_line@plt>
mov    %eax,%r15d
mov    $0x3,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    0x2e28(%rip),%r13
cmpl   $0x0,0x0(%r13)
jle    1228 <drawlineoverlay+0x98>
add    $0x1,%r15d
lea    0xe2e(%rip),%r14
mov    %rsp,%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%ecx
mov    %r12,%rdi
mov    $0x20,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
mov    %ebp,%edi
xor    %esi,%esi
mov    %r12,%rdx
call   10b0 <mvaddstr@plt>
xor    %eax,%eax
call   1070 <winstart@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1090 <skipscreenlines@plt>
test   %rax,%rax
je     1228 <drawlineoverlay+0x98>
mov    %rax,%rdi
call   1080 <screenlines@plt>
add    %eax,%ebp
add    $0x1,%ebx
cmp    0x0(%r13),%ebp
jl     11e0 <drawlineoverlay+0x50>
mov    $0x3,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LINES = global i32 0
@.str = [4 x i8] c"%4d\00"
define void @drawlineoverlay() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [32 x i8]
%5 = alloca i8*
%6 = call i32 (...) @scroll_line()
%7 = add nsw i32 %6, 1
store i32 %7, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%8 = call i32 @COLOR_PAIR(i32 3)
%9 = call i32 @attron(i32 %8)
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %2
%12 = load i32, i32* @LINES
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %38
14: ; preds = %10
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* %1
%17 = call i32 @snprintf(i8* %15, i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %2
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%20 = call i32 @mvaddstr(i32 %18, i32 0, i8* %19)
%21 = call i32 (...) @winstart()
%22 = load i32, i32* %3
%23 = call i8* @skipscreenlines(i32 %21, i32 %22)
store i8* %23, i8** %5
%24 = load i8*, i8** %5
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %14
br label %38
27: ; preds = %14
%28 = load i8*, i8** %5
%29 = call i64 @screenlines(i8* %28)
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = add nsw i64 %31, %29
%33 = trunc i64 %32 to i32
store i32 %33, i32* %2
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
br label %10
38: ; preds = %26, %10
%39 = call i32 @COLOR_PAIR(i32 3)
%40 = call i32 @attroff(i32 %39)
ret void
}

LLVM IR (-O2):
@LINES = global i32 0
@.str = [4 x i8] c"%4d\00"
define void @drawlineoverlay() {
%1 = alloca [32 x i8]
%2 = tail call i32 (...) @scroll_line()
%3 = tail call i32 @COLOR_PAIR(i32 3)
%4 = tail call i32 @attron(i32 %3)
%5 = load i32, i32* @LINES
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %27
7: ; preds = %0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %9
9: ; preds = %7, %20
%10 = phi i32 [ %2, %7 ], [ %13, %20 ]
%11 = phi i32 [ 0, %7 ], [ %24, %20 ]
%12 = phi i32 [ 0, %7 ], [ %23, %20 ]
%13 = add nsw i32 %10, 1
%14 = call i32 @snprintf(i8* %8, i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @mvaddstr(i32 %12, i32 0, i8* %8)
%16 = call i32 (...) @winstart()
%17 = call i8* @skipscreenlines(i32 %16, i32 %11)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %9
br label %27
20: ; preds = %9
%21 = call i64 @screenlines(i8* %17)
%22 = trunc i64 %21 to i32
%23 = add i32 %12, %22
%24 = add nuw nsw i32 %11, 1
%25 = load i32, i32* @LINES
%26 = icmp slt i32 %23, %25
br i1 %26, label %9, label %27
27: ; preds = %20, %0, %19
%28 = call i32 @COLOR_PAIR(i32 3)
%29 = call i32 @attroff(i32 %28)
ret void
}