#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(char);
int /*<<< orphan*/ addstr(char *);
int /*<<< orphan*/ draw_symbol(int, int, char);
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ refresh();
void display(int cx, int cy, char (*row_ptr)[40 + 1]) {
  int x, y = 0, x_coord, y_coord;
  char ch;
  while (y < (cy - 3)) {
    y++;
    row_ptr++;
  };
  move(0, 0);
  addstr("+---------------------------------+");
  move(15, 0);
  addstr("+---------------------------------+");
  for (y = (cy - 3); y <= (cy + 3); y++) {
    y_coord = (y + 3 - cy) * 2;
    if ((y < 0) || (y >= 16)) {
      move(y_coord + 1, 0);
      addstr("|#################################|");
      move(y_coord + 2, 0);
      addstr("|#################################|");
    } else {
      move(y_coord + 1, 0);
      addch('|');
      move(y_coord + 1, 34);
      addch('|');
      move(y_coord + 2, 0);
      addch('|');
      move(y_coord + 2, 34);
      addch('|');
      for (x = (cx - 5); x <= (cx + 5); x++) {
        x_coord = (x + 5 - cx) * 3;
        if ((x < 0) || (x > 40 - 1))
          draw_symbol(x_coord, y_coord, '#');
        else {
          ch = (*row_ptr)[x];
          draw_symbol(x_coord, y_coord, ch);
        }
      };
      row_ptr++;
    }
  }
  move(16, 0);
  refresh();
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    1194 <display+0x44>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x29,%rax
mov    %rax,-0x10(%rbp)
jmp    1169 <display+0x19>
xor    %esi,%esi
mov    %esi,%edi
call   1070 <move@plt>
lea    0xe5c(%rip),%rdi
call   1060 <addstr@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1070 <move@plt>
lea    0xe44(%rip),%rdi
call   1060 <addstr@plt>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x3,%ecx
cmp    %ecx,%eax
jg     1338 <display+0x1e8>
mov    -0x18(%rbp),%eax
add    $0x3,%eax
sub    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11fe <display+0xae>
cmpl   $0x10,-0x18(%rbp)
jl     1235 <display+0xe5>
mov    -0x20(%rbp),%edi
add    $0x1,%edi
xor    %esi,%esi
call   1070 <move@plt>
lea    0xe12(%rip),%rdi
call   1060 <addstr@plt>
mov    -0x20(%rbp),%edi
add    $0x2,%edi
xor    %esi,%esi
call   1070 <move@plt>
lea    0xdf9(%rip),%rdi
call   1060 <addstr@plt>
jmp    1325 <display+0x1d5>
mov    -0x20(%rbp),%edi
add    $0x1,%edi
xor    %esi,%esi
call   1070 <move@plt>
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    -0x20(%rbp),%edi
add    $0x1,%edi
mov    $0x22,%esi
call   1070 <move@plt>
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    -0x20(%rbp),%edi
add    $0x2,%edi
xor    %esi,%esi
call   1070 <move@plt>
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    -0x20(%rbp),%edi
add    $0x2,%edi
mov    $0x22,%esi
call   1070 <move@plt>
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    -0x4(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x5,%ecx
cmp    %ecx,%eax
jg     1319 <display+0x1c9>
mov    -0x14(%rbp),%eax
add    $0x5,%eax
sub    -0x4(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12d4 <display+0x184>
cmpl   $0x27,-0x14(%rbp)
jle    12e9 <display+0x199>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    $0x23,%edx
call   1030 <draw_symbol@plt>
jmp    1306 <display+0x1b6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
movsbl -0x21(%rbp),%edx
call   1030 <draw_symbol@plt>
jmp    130b <display+0x1bb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a0 <display+0x150>
mov    -0x10(%rbp),%rax
add    $0x29,%rax
mov    %rax,-0x10(%rbp)
jmp    132a <display+0x1da>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ca <display+0x7a>
mov    $0x10,%edi
xor    %esi,%esi
call   1070 <move@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r13d
mov    %edi,%ebp
lea    -0x3(%r13),%r14d
lea    -0x4(%r13),%eax
cmp    $0x4,%esi
lea    (%rax,%rax,4),%rcx
lea    (%rax,%rcx,8),%rax
lea    0x29(%rdx,%rax,1),%r15
cmovl  %rdx,%r15
xor    %edi,%edi
xor    %esi,%esi
call   1070 <move@plt>
lea    0xe71(%rip),%rbx
mov    %rbx,%rdi
call   1060 <addstr@plt>
mov    $0xf,%edi
xor    %esi,%esi
call   1070 <move@plt>
mov    %rbx,%rdi
mov    %r14,%rbx
call   1060 <addstr@plt>
mov    $0x3,%eax
sub    %r13d,%eax
mov    %rax,0x10(%rsp)
add    $0x3,%r13d
lea    -0x5(%rbp),%eax
lea    0x5(%rbp),%r12d
cmp    %r12d,%eax
cmovg  %eax,%r12d
cmp    %r13d,%ebx
cmovg  %ebx,%r13d
add    $0xfffffffa,%ebp
mov    %rbp,(%rsp)
jmp    11f7 <display+0xa7>
nopl   (%rax)
add    $0x29,%r15
mov    0x8(%rsp),%rbx
lea    0x1(%rbx),%eax
cmp    %r13d,%ebx
mov    %eax,%ebx
je     12dc <display+0x18c>
mov    0x10(%rsp),%rax
lea    (%rax,%rbx,1),%r14d
lea    (%r14,%r14,1),%ebp
add    $0x1,%ebp
add    %r14d,%r14d
mov    %ebp,%edi
xor    %esi,%esi
call   1070 <move@plt>
cmp    $0x10,%ebx
jb     1240 <display+0xf0>
lea    0xe05(%rip),%rbp
mov    %rbp,%rdi
call   1060 <addstr@plt>
add    $0x2,%r14d
mov    %r14d,%edi
xor    %esi,%esi
call   1070 <move@plt>
mov    %rbp,%rdi
call   1060 <addstr@plt>
jmp    11e9 <display+0x99>
nop
mov    %rbx,0x8(%rsp)
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    %ebp,%edi
mov    $0x22,%esi
call   1070 <move@plt>
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    %r13,%rbx
lea    0x2(%r14),%r13d
xor    %ebp,%ebp
mov    %r13d,%edi
xor    %esi,%esi
call   1070 <move@plt>
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    %r13d,%edi
mov    %rbx,%r13
mov    $0x22,%esi
call   1070 <move@plt>
mov    $0x7c,%edi
call   1040 <addch@plt>
mov    (%rsp),%rax
mov    %eax,%ebx
jmp    12c9 <display+0x179>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edx
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <draw_symbol@plt>
add    $0x3,%ebp
cmp    %ebx,%r12d
je     11e0 <display+0x90>
add    $0x1,%ebx
mov    $0x23,%al
cmp    $0x27,%ebx
ja     12b0 <display+0x160>
mov    %ebx,%eax
movzbl (%r15,%rax,1),%eax
jmp    12b0 <display+0x160>
mov    $0x10,%edi
xor    %esi,%esi
call   1070 <move@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <refresh@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"+---------------------------------+\00"
@.str.1 = [36 x i8] c"|#################################|\00"
define void @display(i32 %0, i32 %1, [41 x i8]* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca [41 x i8]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store [41 x i8]* %2, [41 x i8]** %6
store i32 0, i32* %8
br label %12
12: ; preds = %17, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %5
%15 = sub nsw i32 %14, 3
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i32, i32* %8
%19 = add nsw i32 %18, 1
store i32 %19, i32* %8
%20 = load [41 x i8]*, [41 x i8]** %6
%21 = getelementptr inbounds [41 x i8], [41 x i8]* %20, i32 1
store [41 x i8]* %21, [41 x i8]** %6
br label %12
22: ; preds = %12
%23 = call i32 @move(i32 0, i32 0)
%24 = call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @move(i32 15, i32 0)
%26 = call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 3
store i32 %28, i32* %8
br label %29
29: ; preds = %111, %22
%30 = load i32, i32* %8
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 3
%33 = icmp sle i32 %30, %32
br i1 %33, label %34, label %114
34: ; preds = %29
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 3
%37 = load i32, i32* %5
%38 = sub nsw i32 %36, %37
%39 = mul nsw i32 %38, 2
store i32 %39, i32* %10
%40 = load i32, i32* %8
%41 = icmp slt i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %34
%43 = load i32, i32* %8
%44 = icmp sge i32 %43, 16
br i1 %44, label %45, label %54
45: ; preds = %42, %34
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
%48 = call i32 @move(i32 %47, i32 0)
%49 = call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 2
%52 = call i32 @move(i32 %51, i32 0)
%53 = call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %110
54: ; preds = %42
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
%57 = call i32 @move(i32 %56, i32 0)
%58 = call i32 @addch(i8 signext 124)
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
%61 = call i32 @move(i32 %60, i32 34)
%62 = call i32 @addch(i8 signext 124)
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 2
%65 = call i32 @move(i32 %64, i32 0)
%66 = call i32 @addch(i8 signext 124)
%67 = load i32, i32* %10
%68 = add nsw i32 %67, 2
%69 = call i32 @move(i32 %68, i32 34)
%70 = call i32 @addch(i8 signext 124)
%71 = load i32, i32* %4
%72 = sub nsw i32 %71, 5
store i32 %72, i32* %7
br label %73
73: ; preds = %104, %54
%74 = load i32, i32* %7
%75 = load i32, i32* %4
%76 = add nsw i32 %75, 5
%77 = icmp sle i32 %74, %76
br i1 %77, label %78, label %107
78: ; preds = %73
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 5
%81 = load i32, i32* %4
%82 = sub nsw i32 %80, %81
%83 = mul nsw i32 %82, 3
store i32 %83, i32* %9
%84 = load i32, i32* %7
%85 = icmp slt i32 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %78
%87 = load i32, i32* %7
%88 = icmp sgt i32 %87, 39
br i1 %88, label %89, label %93
89: ; preds = %86, %78
%90 = load i32, i32* %9
%91 = load i32, i32* %10
%92 = call i32 @draw_symbol(i32 %90, i32 %91, i8 signext 35)
br label %103
93: ; preds = %86
%94 = load [41 x i8]*, [41 x i8]** %6
%95 = load i32, i32* %7
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [41 x i8], [41 x i8]* %94, i64 0, i64 %96
%98 = load i8, i8* %97
store i8 %98, i8* %11
%99 = load i32, i32* %9
%100 = load i32, i32* %10
%101 = load i8, i8* %11
%102 = call i32 @draw_symbol(i32 %99, i32 %100, i8 signext %101)
br label %103
103: ; preds = %93, %89
br label %104
104: ; preds = %103
%105 = load i32, i32* %7
%106 = add nsw i32 %105, 1
store i32 %106, i32* %7
br label %73
107: ; preds = %73
%108 = load [41 x i8]*, [41 x i8]** %6
%109 = getelementptr inbounds [41 x i8], [41 x i8]* %108, i32 1
store [41 x i8]* %109, [41 x i8]** %6
br label %110
110: ; preds = %107, %45
br label %111
111: ; preds = %110
%112 = load i32, i32* %8
%113 = add nsw i32 %112, 1
store i32 %113, i32* %8
br label %29
114: ; preds = %29
%115 = call i32 @move(i32 16, i32 0)
%116 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"+---------------------------------+\00"
@.str.1 = [36 x i8] c"|#################################|\00"
define void @display(i32 %0, i32 %1, [41 x i8]* nocapture %2) {
%4 = add i32 %1, -3
%5 = icmp sgt i32 %1, 3
%6 = add nsw i32 %1, -4
%7 = zext i32 %6 to i64
%8 = add nuw nsw i64 %7, 1
%9 = getelementptr [41 x i8], [41 x i8]* %2, i64 %8, i64 0
%10 = bitcast i8* %9 to [41 x i8]*
%11 = select i1 %5, [41 x i8]* %10, [41 x i8]* %2
%12 = tail call i32 @move(i32 0, i32 0)
%13 = tail call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @move(i32 15, i32 0)
%15 = tail call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%16 = add i32 %1, 3
%17 = sub i32 3, %1
%18 = add i32 %0, -5
%19 = add i32 %0, 5
%20 = sub i32 5, %0
%21 = call i32 @llvm.smax.i32(i32 %18, i32 %19)
%22 = call i32 @llvm.smax.i32(i32 %4, i32 %16)
br label %23
23: ; preds = %3, %61
%24 = phi [41 x i8]* [ %11, %3 ], [ %62, %61 ]
%25 = phi i32 [ %4, %3 ], [ %63, %61 ]
%26 = add i32 %17, %25
%27 = shl nsw i32 %26, 1
%28 = icmp ugt i32 %25, 15
%29 = or i32 %27, 1
%30 = tail call i32 @move(i32 %29, i32 0)
br i1 %28, label %31, label %36
31: ; preds = %23
%32 = tail call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%33 = add nuw nsw i32 %27, 2
%34 = tail call i32 @move(i32 %33, i32 0)
%35 = tail call i32 @addstr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %61
36: ; preds = %23
%37 = tail call i32 @addch(i8 signext 124)
%38 = tail call i32 @move(i32 %29, i32 34)
%39 = tail call i32 @addch(i8 signext 124)
%40 = add nuw nsw i32 %27, 2
%41 = tail call i32 @move(i32 %40, i32 0)
%42 = tail call i32 @addch(i8 signext 124)
%43 = tail call i32 @move(i32 %40, i32 34)
%44 = tail call i32 @addch(i8 signext 124)
br label %45
45: ; preds = %36, %54
%46 = phi i32 [ %18, %36 ], [ %57, %54 ]
%47 = add i32 %20, %46
%48 = mul nuw nsw i32 %47, 3
%49 = icmp ugt i32 %46, 39
br i1 %49, label %54, label %50
50: ; preds = %45
%51 = zext i32 %46 to i64
%52 = getelementptr inbounds [41 x i8], [41 x i8]* %24, i64 0, i64 %51
%53 = load i8, i8* %52
br label %54
54: ; preds = %45, %50
%55 = phi i8 [ %53, %50 ], [ 35, %45 ]
%56 = tail call i32 @draw_symbol(i32 %48, i32 %27, i8 signext %55)
%57 = add i32 %46, 1
%58 = icmp eq i32 %46, %21
br i1 %58, label %59, label %45
59: ; preds = %54
%60 = getelementptr inbounds [41 x i8], [41 x i8]* %24, i64 1
br label %61
61: ; preds = %31, %59
%62 = phi [41 x i8]* [ %24, %31 ], [ %60, %59 ]
%63 = add i32 %25, 1
%64 = icmp eq i32 %25, %22
br i1 %64, label %65, label %23
65: ; preds = %61
%66 = tail call i32 @move(i32 16, i32 0)
%67 = tail call i32 (...) @refresh()
ret void
}