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

/* Variables and functions */
int A_CHARTEXT;
int A_STANDOUT;
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ getyx(int /*<<< orphan*/ *, int, int);
scalar_t__ is_digitable(int);
int /*<<< orphan*/ waddch(int /*<<< orphan*/ *, int);
int winch(int /*<<< orphan*/ *);
int /*<<< orphan*/ wmove(int /*<<< orphan*/ *, int, int);
int interface_w_invert_line_min(WINDOW *window, int not_until) {
  int c;
  int col;
  int i;
  int row;
  int max_row, max_col;
  int inverse;
  int up_to;
  getyx(window, row, col);
  getmaxyx(window, max_row, max_col);
  for (i = max_col - 1; i >= 0 && i >= not_until; i--) {
    wmove(window, row, i);
    c = (winch(window));
    inverse = c & A_STANDOUT;
    c = c & A_CHARTEXT;
    if (inverse || (is_digitable(c) && c != ' '))
      break;
  }
  i++;
  wmove(window, row, 0);
  up_to = ((i) > (4) ? (i) : (4));
  for (i = 0, c = winch(window); i < up_to; i++, c = winch(window)) {
    waddch(window, (c ^ A_STANDOUT));
  }
  wmove(window, row, col);
  return (0);
}


x86 assembly (clang, -O0):
<interface_w_invert_line_min>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <getyx@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1050 <getmaxyx@plt>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x2d(%rbp)
jl     11b1 <interface_w_invert_line_min+0x51>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
setge  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    11c1 <interface_w_invert_line_min+0x61>
jmp    1238 <interface_w_invert_line_min+0xd8>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1080 <wmove@plt>
mov    -0x8(%rbp),%rdi
call   1060 <winch@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2df2(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2df3(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1220 <interface_w_invert_line_min+0xc0>
mov    -0x10(%rbp),%edi
call   1070 <is_digitable@plt>
cmp    $0x0,%rax
je     1225 <interface_w_invert_line_min+0xc5>
cmpl   $0x20,-0x10(%rbp)
je     1225 <interface_w_invert_line_min+0xc5>
jmp    1238 <interface_w_invert_line_min+0xd8>
jmp    122a <interface_w_invert_line_min+0xca>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1196 <interface_w_invert_line_min+0x36>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %edx,%edx
call   1080 <wmove@plt>
cmpl   $0x4,-0x18(%rbp)
jle    1264 <interface_w_invert_line_min+0x104>
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1271 <interface_w_invert_line_min+0x111>
mov    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    1271 <interface_w_invert_line_min+0x111>
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <winch@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12c5 <interface_w_invert_line_min+0x165>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    0x2d34(%rip),%rax
xor    (%rax),%esi
call   1030 <waddch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <winch@plt>
mov    %eax,-0x10(%rbp)
jmp    128a <interface_w_invert_line_min+0x12a>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1080 <wmove@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interface_w_invert_line_min>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <getyx@plt>
mov    %rbx,%rdi
call   1050 <getmaxyx@plt>
mov    %rbx,%rdi
xor    %edx,%edx
call   1070 <wmove@plt>
mov    %rbx,%rdi
call   1060 <winch@plt>
mov    0x2e63(%rip),%r14
xor    (%r14),%eax
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <waddch@plt>
mov    %rbx,%rdi
call   1060 <winch@plt>
xor    (%r14),%eax
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <waddch@plt>
mov    %rbx,%rdi
call   1060 <winch@plt>
xor    (%r14),%eax
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <waddch@plt>
mov    %rbx,%rdi
call   1060 <winch@plt>
xor    (%r14),%eax
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <waddch@plt>
mov    %rbx,%rdi
call   1060 <winch@plt>
mov    %rbx,%rdi
call   1070 <wmove@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@A_STANDOUT = global i32 0
@A_CHARTEXT = global i32 0
define i32 @interface_w_invert_line_min(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%13 = load i32*, i32** %3
%14 = load i32, i32* %8
%15 = load i32, i32* %6
%16 = call i32 @getyx(i32* %13, i32 %14, i32 %15)
%17 = load i32*, i32** %3
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = call i32 @getmaxyx(i32* %17, i32 %18, i32 %19)
%21 = load i32, i32* %10
%22 = sub nsw i32 %21, 1
store i32 %22, i32* %7
br label %23
23: ; preds = %56, %2
%24 = load i32, i32* %7
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %7
%28 = load i32, i32* %4
%29 = icmp sge i32 %27, %28
br label %30
30: ; preds = %26, %23
%31 = phi i1 [ false, %23 ], [ %29, %26 ]
br i1 %31, label %32, label %59
32: ; preds = %30
%33 = load i32*, i32** %3
%34 = load i32, i32* %8
%35 = load i32, i32* %7
%36 = call i32 @wmove(i32* %33, i32 %34, i32 %35)
%37 = load i32*, i32** %3
%38 = call i32 @winch(i32* %37)
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = load i32, i32* @A_STANDOUT
%41 = and i32 %39, %40
store i32 %41, i32* %11
%42 = load i32, i32* %5
%43 = load i32, i32* @A_CHARTEXT
%44 = and i32 %42, %43
store i32 %44, i32* %5
%45 = load i32, i32* %11
%46 = icmp ne i32 %45, 0
br i1 %46, label %54, label %47
47: ; preds = %32
%48 = load i32, i32* %5
%49 = call i64 @is_digitable(i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = load i32, i32* %5
%53 = icmp ne i32 %52, 32
br i1 %53, label %54, label %55
54: ; preds = %51, %32
br label %59
55: ; preds = %51, %47
br label %56
56: ; preds = %55
%57 = load i32, i32* %7
%58 = add nsw i32 %57, -1
store i32 %58, i32* %7
br label %23
59: ; preds = %54, %30
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
%62 = load i32*, i32** %3
%63 = load i32, i32* %8
%64 = call i32 @wmove(i32* %62, i32 %63, i32 0)
%65 = load i32, i32* %7
%66 = icmp sgt i32 %65, 4
br i1 %66, label %67, label %69
67: ; preds = %59
%68 = load i32, i32* %7
br label %70
69: ; preds = %59
br label %70
70: ; preds = %69, %67
%71 = phi i32 [ %68, %67 ], [ 4, %69 ]
store i32 %71, i32* %12
store i32 0, i32* %7
%72 = load i32*, i32** %3
%73 = call i32 @winch(i32* %72)
store i32 %73, i32* %5
br label %74
74: ; preds = %84, %70
%75 = load i32, i32* %7
%76 = load i32, i32* %12
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %89
78: ; preds = %74
%79 = load i32*, i32** %3
%80 = load i32, i32* %5
%81 = load i32, i32* @A_STANDOUT
%82 = xor i32 %80, %81
%83 = call i32 @waddch(i32* %79, i32 %82)
br label %84
84: ; preds = %78
%85 = load i32, i32* %7
%86 = add nsw i32 %85, 1
store i32 %86, i32* %7
%87 = load i32*, i32** %3
%88 = call i32 @winch(i32* %87)
store i32 %88, i32* %5
br label %74
89: ; preds = %74
%90 = load i32*, i32** %3
%91 = load i32, i32* %8
%92 = load i32, i32* %6
%93 = call i32 @wmove(i32* %90, i32 %91, i32 %92)
ret i32 0
}

LLVM IR (-O2):
@A_STANDOUT = global i32 0
@A_CHARTEXT = global i32 0
define i32 @interface_w_invert_line_min(i32* %0, i32 %1) {
%3 = tail call i32 @getyx(i32* %0, i32 undef, i32 undef)
%4 = tail call i32 @getmaxyx(i32* %0, i32 undef, i32 undef)
%5 = tail call i32 @wmove(i32* %0, i32 undef, i32 0)
%6 = tail call i32 @winch(i32* %0)
%7 = load i32, i32* @A_STANDOUT
%8 = xor i32 %7, %6
%9 = tail call i32 @waddch(i32* %0, i32 %8)
%10 = tail call i32 @winch(i32* %0)
%11 = load i32, i32* @A_STANDOUT
%12 = xor i32 %11, %10
%13 = tail call i32 @waddch(i32* %0, i32 %12)
%14 = tail call i32 @winch(i32* %0)
%15 = load i32, i32* @A_STANDOUT
%16 = xor i32 %15, %14
%17 = tail call i32 @waddch(i32* %0, i32 %16)
%18 = tail call i32 @winch(i32* %0)
%19 = load i32, i32* @A_STANDOUT
%20 = xor i32 %19, %18
%21 = tail call i32 @waddch(i32* %0, i32 %20)
%22 = tail call i32 @winch(i32* %0)
%23 = tail call i32 @wmove(i32* %0, i32 undef, i32 undef)
ret i32 0
}