#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*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ refresh();
void print(int **a, int n) {
  int i, j;
  int x, y;
  x = 9;
  y = 3;
  mvprintw(1, 30, "MAGIC SQUARE");
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      mvprintw(y, x, "%d", a[i][j]);
      if (n > 9)
        x += 4;
      else
        x += 6;
    }
    x = 9;
    if (n > 7)
      y += 2;
    else
      y += 3;
  }
  refresh();
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x9,-0x18(%rbp)
movl   $0x3,-0x1c(%rbp)
mov    $0x1,%edi
mov    $0x1e,%esi
lea    0xeb2(%rip),%rdx
mov    $0x0,%al
call   1040 <mvprintw@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1211 <print+0xf1>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d6 <print+0xb6>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe72(%rip),%rdx
mov    $0x0,%al
call   1040 <mvprintw@plt>
cmpl   $0x9,-0xc(%rbp)
jle    11ba <print+0x9a>
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    11c3 <print+0xa3>
mov    -0x18(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x18(%rbp)
jmp    11c8 <print+0xa8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <print+0x4f>
movl   $0x9,-0x18(%rbp)
cmpl   $0x7,-0xc(%rbp)
jle    11f5 <print+0xd5>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fe <print+0xde>
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
jmp    1203 <print+0xe3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115c <print+0x3c>
mov    $0x0,%al
call   1030 <refresh@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,0x10(%rsp)
lea    0xec3(%rip),%rdx
mov    $0x1,%edi
mov    $0x1e,%esi
xor    %eax,%eax
call   1040 <mvprintw@plt>
test   %r14d,%r14d
jle    11dd <print+0xbd>
xor    %eax,%eax
cmp    $0xa,%r14d
setb   %al
add    %eax,%eax
add    $0x4,%eax
cmp    $0x8,%r14d
mov    $0x3,%ecx
adc    $0xffffffff,%ecx
mov    %ecx,0x8(%rsp)
mov    $0x3,%esi
mov    %r14d,%ebp
lea    0xe89(%rip),%r12
xor    %r13d,%r13d
mov    %eax,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
mov    $0x9,%ebx
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rax
mov    (%rax,%r15,4),%ecx
mov    %esi,%r14d
mov    %esi,%edi
mov    %ebx,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <mvprintw@plt>
mov    %r14d,%esi
mov    0xc(%rsp),%eax
add    %eax,%ebx
add    $0x1,%r15
cmp    %r15,%rbp
jne    11a0 <print+0x80>
add    0x8(%rsp),%esi
add    $0x1,%r13
cmp    %rbp,%r13
jne    1190 <print+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <refresh@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"MAGIC SQUARE\00"
@.str.1 = [3 x i8] c"%d\00"
define void @print(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32** %0, i32*** %3
store i32 %1, i32* %4
store i32 9, i32* %7
store i32 3, i32* %8
%9 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 1, i32 30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %10
10: ; preds = %54, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %57
14: ; preds = %10
store i32 0, i32* %6
br label %15
15: ; preds = %41, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %44
19: ; preds = %15
%20 = load i32, i32* %8
%21 = load i32, i32* %7
%22 = load i32**, i32*** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32*, i32** %22, i64 %24
%26 = load i32*, i32** %25
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %20, i32 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 9
br i1 %33, label %34, label %37
34: ; preds = %19
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 4
store i32 %36, i32* %7
br label %40
37: ; preds = %19
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 6
store i32 %39, i32* %7
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %15
44: ; preds = %15
store i32 9, i32* %7
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 7
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 2
store i32 %49, i32* %8
br label %53
50: ; preds = %44
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 3
store i32 %52, i32* %8
br label %53
53: ; preds = %50, %47
br label %54
54: ; preds = %53
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %10
57: ; preds = %10
%58 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"MAGIC SQUARE\00"
@.str.1 = [3 x i8] c"%d\00"
define void @print(i32** nocapture %0, i32 %1) {
%3 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 1, i32 30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %29
5: ; preds = %2
%6 = icmp ugt i32 %1, 9
%7 = select i1 %6, i32 4, i32 6
%8 = icmp ugt i32 %1, 7
%9 = select i1 %8, i32 2, i32 3
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %25, %5
%12 = phi i64 [ 0, %5 ], [ %27, %25 ]
%13 = phi i32 [ 3, %5 ], [ %26, %25 ]
%14 = getelementptr inbounds i32*, i32** %0, i64 %12
br label %15
15: ; preds = %11, %15
%16 = phi i64 [ 0, %11 ], [ %23, %15 ]
%17 = phi i32 [ 9, %11 ], [ %22, %15 ]
%18 = load i32*, i32** %14
%19 = getelementptr inbounds i32, i32* %18, i64 %16
%20 = load i32, i32* %19
%21 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 %13, i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i32 %17, %7
%23 = add nuw nsw i64 %16, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %15
25: ; preds = %15
%26 = add nuw nsw i32 %13, %9
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %29, label %11
29: ; preds = %25, %2
%30 = tail call i32 (...) @refresh()
ret void
}