#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 /*<<< orphan*/ addch(int);
int inch();
int /*<<< orphan*/ move(int, int);
void repaint(int x, int y, int len, int attron, int attroff) {
  while (len-- > 0) {
    (void)move(y, x);
    addch((inch() | attron) & ~attroff);
    x++;
  }
}


x86 assembly (clang, -O0):
<repaint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    118e <repaint+0x5e>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <move@plt>
mov    $0x0,%al
call   1040 <inch@plt>
mov    %eax,%edi
or     -0x10(%rbp),%edi
mov    -0x14(%rbp),%eax
xor    $0xffffffff,%eax
and    %eax,%edi
call   1030 <addch@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1148 <repaint+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<repaint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    1179 <repaint+0x49>
mov    %r8d,%r12d
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r15d
mov    %edi,%ebx
not    %r12d
add    $0x1,%ebp
nop
mov    %r15d,%edi
mov    %ebx,%esi
call   1050 <move@plt>
xor    %eax,%eax
call   1040 <inch@plt>
or     %r14d,%eax
and    %r12d,%eax
mov    %eax,%edi
call   1030 <addch@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1150 <repaint+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @repaint(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
br label %11
11: ; preds = %15, %5
%12 = load i32, i32* %8
%13 = add nsw i32 %12, -1
store i32 %13, i32* %8
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %28
15: ; preds = %11
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = call i32 @move(i32 %16, i32 %17)
%19 = call i32 (...) @inch()
%20 = load i32, i32* %9
%21 = or i32 %19, %20
%22 = load i32, i32* %10
%23 = xor i32 %22, -1
%24 = and i32 %21, %23
%25 = call i32 @addch(i32 %24)
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %11
28: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @repaint(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %20
7: ; preds = %5
%8 = xor i32 %4, -1
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %0, %7 ], [ %18, %9 ]
%11 = phi i32 [ %2, %7 ], [ %12, %9 ]
%12 = add nsw i32 %11, -1
%13 = tail call i32 @move(i32 %1, i32 %10)
%14 = tail call i32 (...) @inch()
%15 = or i32 %14, %3
%16 = and i32 %15, %8
%17 = tail call i32 @addch(i32 %16)
%18 = add nsw i32 %10, 1
%19 = icmp ugt i32 %11, 1
br i1 %19, label %9, label %20
20: ; preds = %9, %5
ret void
}