#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*/ COLOR_PAIR(int);
int COLS;
unsigned int LINES;
int /*<<< orphan*/ addch(char);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
scalar_t__ isgraph(char);
int /*<<< orphan*/ mvaddch(unsigned int, int /*<<< orphan*/, char);
int /*<<< orphan*/ yank_item(char **, unsigned int *, unsigned int);
unsigned int yank_sz();
void drawyanks() {
  char *ytext;
  unsigned lines, nyanks, linestodraw, ysz, previewsz, i, j;
  char c;
  nyanks = yank_sz();
  lines = LINES;
  linestodraw = nyanks < lines ? nyanks : lines;
  for (i = 0; i < linestodraw; i++) {
    attron(COLOR_PAIR(3));
    mvaddch(i, 0, 'a' + i);
    attroff(COLOR_PAIR(3));
    yank_item(&ytext, &ysz, i);
    previewsz = COLS - 2;
    if (ysz < previewsz)
      previewsz = ysz;
    for (j = 0; j < previewsz; j++) {
      c = ytext[j];
      c = (isgraph(c) || c == ' ') ? c : '?';
      addch(c);
    }
  }
}


x86 assembly (clang, -O0):
<drawyanks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   10a0 <yank_sz@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b5 <drawyanks+0x35>
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    11bb <drawyanks+0x3b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    12c3 <drawyanks+0x143>
mov    $0x3,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
mov    -0x20(%rbp),%edi
mov    -0x20(%rbp),%eax
add    $0x61,%eax
xor    %esi,%esi
movsbl %al,%edx
call   1080 <mvaddch@plt>
mov    $0x3,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    -0x20(%rbp),%edx
lea    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <yank_item@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    123a <drawyanks+0xba>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    12b0 <drawyanks+0x130>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%edi
call   1090 <isgraph@plt>
cmp    $0x0,%rax
jne    127a <drawyanks+0xfa>
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jne    1286 <drawyanks+0x106>
movsbl -0x25(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1293 <drawyanks+0x113>
mov    $0x3f,%eax
mov    %eax,-0x30(%rbp)
jmp    1293 <drawyanks+0x113>
mov    -0x30(%rbp),%eax
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%edi
call   1060 <addch@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1241 <drawyanks+0xc1>
jmp    12b5 <drawyanks+0x135>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c8 <drawyanks+0x48>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawyanks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <yank_sz@plt>
mov    0x2e4a(%rip),%rcx
mov    (%rcx),%r12d
cmp    %r12d,%eax
cmovb  %eax,%r12d
test   %r12d,%r12d
je     1265 <drawyanks+0xe5>
lea    0xc(%rsp),%r15
jmp    11cc <drawyanks+0x4c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %r12d,%ebx
je     1265 <drawyanks+0xe5>
mov    $0x3,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
lea    0x61(%rbx),%eax
movsbl %al,%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1080 <mvaddch@plt>
mov    $0x3,%edi
call   1050 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1070 <yank_item@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
add    $0xfffffffe,%eax
mov    0xc(%rsp),%ecx
cmp    %eax,%ecx
cmovb  %ecx,%eax
test   %eax,%eax
je     11c0 <drawyanks+0x40>
mov    %eax,%r14d
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
movsbl (%rax,%r13,1),%ebp
mov    %ebp,%edi
call   1090 <isgraph@plt>
test   %rax,%rax
mov    $0x3f,%edi
cmovne %ebp,%edi
cmp    $0x20,%ebp
cmove  %ebp,%edi
call   1060 <addch@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    1230 <drawyanks+0xb0>
jmp    11c0 <drawyanks+0x40>
add    $0x18,%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
define void @drawyanks() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = call i32 (...) @yank_sz()
store i32 %10, i32* %3
%11 = load i32, i32* @LINES
store i32 %11, i32* %2
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = load i32, i32* %3
br label %19
17: ; preds = %0
%18 = load i32, i32* %2
br label %19
19: ; preds = %17, %15
%20 = phi i32 [ %16, %15 ], [ %18, %17 ]
store i32 %20, i32* %4
store i32 0, i32* %7
br label %21
21: ; preds = %75, %19
%22 = load i32, i32* %7
%23 = load i32, i32* %4
%24 = icmp ult i32 %22, %23
br i1 %24, label %25, label %78
25: ; preds = %21
%26 = call i32 @COLOR_PAIR(i32 3)
%27 = call i32 @attron(i32 %26)
%28 = load i32, i32* %7
%29 = load i32, i32* %7
%30 = add i32 97, %29
%31 = trunc i32 %30 to i8
%32 = call i32 @mvaddch(i32 %28, i32 0, i8 signext %31)
%33 = call i32 @COLOR_PAIR(i32 3)
%34 = call i32 @attroff(i32 %33)
%35 = load i32, i32* %7
%36 = call i32 @yank_item(i8** %1, i32* %5, i32 %35)
%37 = load i32, i32* @COLS
%38 = sub nsw i32 %37, 2
store i32 %38, i32* %6
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = icmp ult i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %25
%43 = load i32, i32* %5
store i32 %43, i32* %6
br label %44
44: ; preds = %42, %25
store i32 0, i32* %8
br label %45
45: ; preds = %71, %44
%46 = load i32, i32* %8
%47 = load i32, i32* %6
%48 = icmp ult i32 %46, %47
br i1 %48, label %49, label %74
49: ; preds = %45
%50 = load i8*, i8** %1
%51 = load i32, i32* %8
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
store i8 %54, i8* %9
%55 = load i8, i8* %9
%56 = call i64 @isgraph(i8 signext %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %49
%59 = load i8, i8* %9
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 32
br i1 %61, label %62, label %65
62: ; preds = %58, %49
%63 = load i8, i8* %9
%64 = sext i8 %63 to i32
br label %66
65: ; preds = %58
br label %66
66: ; preds = %65, %62
%67 = phi i32 [ %64, %62 ], [ 63, %65 ]
%68 = trunc i32 %67 to i8
store i8 %68, i8* %9
%69 = load i8, i8* %9
%70 = call i32 @addch(i8 signext %69)
br label %71
71: ; preds = %66
%72 = load i32, i32* %8
%73 = add i32 %72, 1
store i32 %73, i32* %8
br label %45
74: ; preds = %45
br label %75
75: ; preds = %74
%76 = load i32, i32* %7
%77 = add i32 %76, 1
store i32 %77, i32* %7
br label %21
78: ; preds = %21
ret void
}

LLVM IR (-O2):
@LINES = global i32 0
@COLS = global i32 0
define void @drawyanks() {
%1 = alloca i8*
%2 = alloca i32
%3 = bitcast i8** %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @yank_sz()
%6 = load i32, i32* @LINES
%7 = icmp ult i32 %5, %6
%8 = select i1 %7, i32 %5, i32 %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %44, label %10
10: ; preds = %0, %41
%11 = phi i32 [ %42, %41 ], [ 0, %0 ]
%12 = call i32 @COLOR_PAIR(i32 3)
%13 = call i32 @attron(i32 %12)
%14 = trunc i32 %11 to i8
%15 = add i8 %14, 97
%16 = call i32 @mvaddch(i32 %11, i32 0, i8 signext %15)
%17 = call i32 @COLOR_PAIR(i32 3)
%18 = call i32 @attroff(i32 %17)
%19 = call i32 @yank_item(i8** %1, i32* %2, i32 %11)
%20 = load i32, i32* @COLS
%21 = add nsw i32 %20, -2
%22 = load i32, i32* %2
%23 = icmp ult i32 %22, %21
%24 = select i1 %23, i32 %22, i32 %21
%25 = icmp eq i32 %24, 0
br i1 %25, label %41, label %26
26: ; preds = %10
%27 = zext i32 %24 to i64
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ 0, %26 ], [ %39, %28 ]
%30 = load i8*, i8** %1
%31 = getelementptr inbounds i8, i8* %30, i64 %29
%32 = load i8, i8* %31
%33 = call i64 @isgraph(i8 signext %32)
%34 = icmp ne i64 %33, 0
%35 = icmp eq i8 %32, 32
%36 = or i1 %35, %34
%37 = select i1 %36, i8 %32, i8 63
%38 = call i32 @addch(i8 signext %37)
%39 = add nuw nsw i64 %29, 1
%40 = icmp eq i64 %39, %27
br i1 %40, label %41, label %28
41: ; preds = %28, %10
%42 = add nuw i32 %11, 1
%43 = icmp eq i32 %42, %8
br i1 %43, label %44, label %10
44: ; preds = %41, %0
ret void
}