#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 /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int, char *, char);
int /*<<< orphan*/ werase(int /*<<< orphan*/ *);
int /*<<< orphan*/ wmove(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ wprintw(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
void printarr(WINDOW *win, int size, char array[size][size]) {
  int i, j;
  werase(win);
  wmove(win, 0, 0);
  wprintw(win, "   ");
  for (i = 0; i < size; i++)
    if (i < 10)
      wprintw(win, " %d ", i);
    else
      wprintw(win, "%d ", i);
  for (i = 0; i < size; i++) {
    wprintw(win, "%d", i);
    for (j = 0; j < size; j++) {
      mvwprintw(win, i + 1, (j * 3) + 3, "[%c]", array[i][j]);
    }
  }
  wrefresh(win);
}


x86 assembly (clang, -O0):
<printarr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <werase@plt>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <wmove@plt>
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1040 <wprintw@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f1 <printarr+0xa1>
cmpl   $0xa,-0x1c(%rbp)
jge    11c9 <printarr+0x79>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1040 <wprintw@plt>
jmp    11de <printarr+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <wprintw@plt>
jmp    11e3 <printarr+0x93>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1199 <printarr+0x49>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1286 <printarr+0x136>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1040 <wprintw@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1273 <printarr+0x123>
mov    -0x28(%rbp),%r8
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
imul   $0x3,-0x20(%rbp),%edx
add    $0x3,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %r8,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%r8
lea    0xdb1(%rip),%rcx
movsbl (%rax,%r8,1),%r8d
call   1050 <mvwprintw@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1220 <printarr+0xd0>
jmp    1278 <printarr+0x128>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f8 <printarr+0xa8>
mov    -0x8(%rbp),%rdi
call   1030 <wrefresh@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printarr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %esi,%ebp
mov    %rdi,%r13
call   1070 <werase@plt>
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <wmove@plt>
lea    0xe84(%rip),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <wprintw@plt>
test   %ebp,%ebp
jle    1243 <printarr+0xf3>
mov    %ebp,%r15d
lea    0xe6c(%rip),%r14
lea    0xe66(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%ebx
mov    %r12,%rsi
cmovb  %r14,%rsi
mov    %r13,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <wprintw@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    11b0 <printarr+0x60>
test   %ebp,%ebp
jle    1243 <printarr+0xf3>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
lea    0xe1f(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <wprintw@plt>
add    $0x1,%rbp
mov    $0x3,%ebx
xor    %r12d,%r12d
mov    %r15,%r14
mov    (%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
movsbl (%r15,%r12,1),%r8d
mov    %r13,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
lea    0xde9(%rip),%rcx
call   1050 <mvwprintw@plt>
add    $0x1,%r12
add    $0x3,%ebx
cmp    %r12,%r14
jne    1210 <printarr+0xc0>
add    %r14,%r15
mov    %r15,(%rsp)
cmp    %r14,%rbp
mov    %r14,%r15
jne    11e0 <printarr+0x90>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <wrefresh@plt>

LLVM IR (-O0):
@.str = [4 x i8] c" \00"
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c"[%c]\00"
define void @printarr(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* %5
%10 = zext i32 %9 to i64
%11 = load i32, i32* %5
%12 = zext i32 %11 to i64
%13 = load i32*, i32** %4
%14 = call i32 @werase(i32* %13)
%15 = load i32*, i32** %4
%16 = call i32 @wmove(i32* %15, i32 0, i32 0)
%17 = load i32*, i32** %4
%18 = call i32 (i32*, i8*, ...) @wprintw(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %19
19: ; preds = %35, %3
%20 = load i32, i32* %7
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = load i32, i32* %7
%29 = call i32 (i32*, i8*, ...) @wprintw(i32* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %34
30: ; preds = %23
%31 = load i32*, i32** %4
%32 = load i32, i32* %7
%33 = call i32 (i32*, i8*, ...) @wprintw(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %26
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %19
38: ; preds = %19
store i32 0, i32* %7
br label %39
39: ; preds = %72, %38
%40 = load i32, i32* %7
%41 = load i32, i32* %5
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %75
43: ; preds = %39
%44 = load i32*, i32** %4
%45 = load i32, i32* %7
%46 = call i32 (i32*, i8*, ...) @wprintw(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %45)
store i32 0, i32* %8
br label %47
47: ; preds = %68, %43
%48 = load i32, i32* %8
%49 = load i32, i32* %5
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %71
51: ; preds = %47
%52 = load i32*, i32** %4
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
%55 = load i32, i32* %8
%56 = mul nsw i32 %55, 3
%57 = add nsw i32 %56, 3
%58 = load i8*, i8** %6
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = mul nsw i64 %60, %12
%62 = getelementptr inbounds i8, i8* %58, i64 %61
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = call i32 @mvwprintw(i32* %52, i32 %54, i32 %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 signext %66)
br label %68
68: ; preds = %51
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
store i32 %70, i32* %8
br label %47
71: ; preds = %47
br label %72
72: ; preds = %71
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %39
75: ; preds = %39
%76 = load i32*, i32** %4
%77 = call i32 @wrefresh(i32* %76)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c" \00"
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c"[%c]\00"
define void @printarr(i32* %0, i32 %1, i8* nocapture %2) {
%4 = zext i32 %1 to i64
%5 = tail call i32 @werase(i32* %0)
%6 = tail call i32 @wmove(i32* %0, i32 0, i32 0)
%7 = tail call i32 (i32*, i8*, ...) @wprintw(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp sgt i32 %1, 0
br i1 %8, label %10, label %37
9: ; preds = %10
br i1 %8, label %17, label %37
10: ; preds = %3, %10
%11 = phi i32 [ %15, %10 ], [ 0, %3 ]
%12 = icmp ult i32 %11, 10
%13 = select i1 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%14 = tail call i32 (i32*, i8*, ...) @wprintw(i32* %0, i8* %13, i32 %11)
%15 = add nuw nsw i32 %11, 1
%16 = icmp eq i32 %15, %1
br i1 %16, label %9, label %10
17: ; preds = %9, %35
%18 = phi i64 [ %21, %35 ], [ 0, %9 ]
%19 = trunc i64 %18 to i32
%20 = tail call i32 (i32*, i8*, ...) @wprintw(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %18, 1
%22 = mul nuw nsw i64 %18, %4
%23 = getelementptr inbounds i8, i8* %2, i64 %22
%24 = trunc i64 %21 to i32
br label %25
25: ; preds = %17, %25
%26 = phi i64 [ 0, %17 ], [ %33, %25 ]
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = load i8, i8* %27
%29 = trunc i64 %26 to i32
%30 = mul i32 %29, 3
%31 = add i32 %30, 3
%32 = tail call i32 @mvwprintw(i32* %0, i32 %24, i32 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 signext %28)
%33 = add nuw nsw i64 %26, 1
%34 = icmp eq i64 %33, %4
br i1 %34, label %35, label %25
35: ; preds = %25
%36 = icmp eq i64 %21, %4
br i1 %36, label %37, label %17
37: ; preds = %35, %3, %9
%38 = tail call i32 @wrefresh(i32* %0)
ret void
}