#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 COLS;
int LINES;
int /*<<< orphan*/ erase();
int /*<<< orphan*/ printw(char *, int);
void backfill(void) {
  int y, x;
  erase();
  for (y = 0; y < LINES - 1; y++)
    for (x = 0; x < COLS; x++)
      printw("%d", (y + x) % 10);
}


x86 assembly (clang, -O0):
<backfill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <erase@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ea8(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a3 <backfill+0x83>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%eax
jge    1190 <backfill+0x70>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe83(%rip),%rdi
call   1040 <printw@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <backfill+0x34>
jmp    1195 <backfill+0x75>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1136 <backfill+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backfill>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <erase@plt>
mov    0x2eac(%rip),%rax
mov    (%rax),%ecx
cmp    $0x2,%ecx
jl     11b6 <backfill+0x96>
mov    0x2e96(%rip),%r15
mov    (%r15),%eax
mov    $0xcccccccd,%r12d
lea    0xea6(%rip),%r13
jmp    116c <backfill+0x4c>
nopl   0x0(%rax)
add    $0x1,%r14d
lea    -0x1(%rcx),%edx
cmp    %edx,%r14d
jge    11b6 <backfill+0x96>
test   %eax,%eax
jle    1160 <backfill+0x40>
xor    %ebx,%ebx
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
imul   %r12,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %r14d,%esi
sub    %eax,%esi
add    %ebx,%esi
mov    %r13,%rdi
call   1040 <printw@plt>
add    $0x1,%ebx
mov    (%r15),%eax
add    $0x1,%ebp
cmp    %eax,%ebx
jl     1180 <backfill+0x60>
mov    0x2e36(%rip),%rcx
mov    (%rcx),%ecx
jmp    1160 <backfill+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LINES = global i32 0
@COLS = global i32 0
@.str = [3 x i8] c"%d\00"
define void @backfill() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @erase()
store i32 0, i32* %1
br label %4
4: ; preds = %24, %0
%5 = load i32, i32* %1
%6 = load i32, i32* @LINES
%7 = sub nsw i32 %6, 1
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %27
9: ; preds = %4
store i32 0, i32* %2
br label %10
10: ; preds = %20, %9
%11 = load i32, i32* %2
%12 = load i32, i32* @COLS
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = add nsw i32 %15, %16
%18 = srem i32 %17, 10
%19 = call i32 @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %14
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %10
23: ; preds = %10
br label %24
24: ; preds = %23
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
br label %4
27: ; preds = %4
ret void
}

LLVM IR (-O2):
@LINES = global i32 0
@COLS = global i32 0
@.str = [3 x i8] c"%d\00"
define void @backfill() {
%1 = tail call i32 (...) @erase()
%2 = load i32, i32* @LINES
%3 = icmp sgt i32 %2, 1
br i1 %3, label %4, label %27
4: ; preds = %0
%5 = load i32, i32* @COLS
br label %6
6: ; preds = %4, %21
%7 = phi i32 [ %22, %21 ], [ %2, %4 ]
%8 = phi i32 [ %23, %21 ], [ %5, %4 ]
%9 = phi i32 [ %24, %21 ], [ 0, %4 ]
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %21
11: ; preds = %6, %11
%12 = phi i32 [ %16, %11 ], [ 0, %6 ]
%13 = add nuw nsw i32 %12, %9
%14 = urem i32 %13, 10
%15 = tail call i32 @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i32 %12, 1
%17 = load i32, i32* @COLS
%18 = icmp slt i32 %16, %17
br i1 %18, label %11, label %19
19: ; preds = %11
%20 = load i32, i32* @LINES
br label %21
21: ; preds = %19, %6
%22 = phi i32 [ %20, %19 ], [ %7, %6 ]
%23 = phi i32 [ %17, %19 ], [ %8, %6 ]
%24 = add nuw nsw i32 %9, 1
%25 = add nsw i32 %22, -1
%26 = icmp slt i32 %24, %25
br i1 %26, label %6, label %27
27: ; preds = %21, %0
ret void
}