#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 COLS;
int LINES;
int /*<<< orphan*/ board(int /*<<< orphan*/, int, int, int, int, int, int);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
void shuffle_board(int **s_board, int n) {
  int i, j, deltax, deltay;
  int startx, starty;
  starty = (LINES - n * 4) / 2;
  startx = (COLS - n * 6) / 2;
  clear();
  mvprintw(24, 0, "Press F1 to Exit");
  board(stdscr, starty, startx, n, n, 6, 4);
  deltay = 4 / 2;
  deltax = 6 / 2;
  for (j = 0; j < n; ++j)
    for (i = 0; i < n; ++i)
      if (s_board[i][j] != 0)
        mvprintw(starty + j * 4 + deltay, startx + i * 6 + deltax, "%-2d",
                 s_board[i][j]);
  refresh();
}


x86 assembly (clang, -O0):
<shuffle_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
imul   $0x6,-0xc(%rbp),%ecx
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <clear@plt>
mov    $0x18,%edi
xor    %esi,%esi
lea    0xe66(%rip),%rdx
mov    $0x0,%al
call   1060 <mvprintw@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    $0x6,%r9d
movl   $0x4,(%rsp)
call   1030 <board@plt>
movl   $0x2,-0x1c(%rbp)
movl   $0x3,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1278 <shuffle_board+0x138>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1265 <shuffle_board+0x125>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1252 <shuffle_board+0x112>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
add    %eax,%edi
add    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
imul   $0x6,-0x10(%rbp),%eax
add    %eax,%esi
add    -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    0xdc6(%rip),%rdx
mov    $0x0,%al
call   1060 <mvprintw@plt>
jmp    1257 <shuffle_board+0x117>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f1 <shuffle_board+0xb1>
jmp    126a <shuffle_board+0x12a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <shuffle_board+0x9e>
mov    $0x0,%al
call   1040 <refresh@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle_board>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r15d
mov    %rdi,%r13
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
lea    0x0(,%r15,4),%ecx
sub    %ecx,%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
lea    (%r15,%r15,1),%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
xor    %eax,%eax
call   1050 <clear@plt>
lea    0xe67(%rip),%rdx
mov    $0x18,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <mvprintw@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
movl   $0x4,(%rsp)
mov    %rbx,0x10(%rsp)
mov    %ebx,%esi
mov    %ebp,0xc(%rsp)
mov    %ebp,%edx
mov    %r15d,%ecx
mov    %r15d,%r8d
mov    $0x6,%r9d
call   1030 <board@plt>
test   %r15d,%r15d
jle    124d <shuffle_board+0x10d>
mov    0x10(%rsp),%rax
add    $0x2,%eax
mov    %rax,0x10(%rsp)
mov    %r15d,%r14d
addl   $0x3,0xc(%rsp)
xor    %r12d,%r12d
jmp    1209 <shuffle_board+0xc9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12
cmp    %r14,%r12
je     124d <shuffle_board+0x10d>
mov    0x10(%rsp),%rax
lea    (%rax,%r12,4),%ebp
mov    0xc(%rsp),%ebx
xor    %r15d,%r15d
jmp    122c <shuffle_board+0xec>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x6,%ebx
cmp    %r15,%r14
je     1200 <shuffle_board+0xc0>
mov    0x0(%r13,%r15,8),%rax
mov    (%rax,%r12,4),%ecx
test   %ecx,%ecx
je     1220 <shuffle_board+0xe0>
mov    %ebp,%edi
mov    %ebx,%esi
lea    0xdcd(%rip),%rdx
xor    %eax,%eax
call   1060 <mvprintw@plt>
jmp    1220 <shuffle_board+0xe0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <refresh@plt>

LLVM IR (-O0):
@LINES = global i32 0
@COLS = global i32 0
@.str = [17 x i8] c"Press F1 to Exit\00"
@stdscr = global i32 0
@.str.1 = [5 x i8] c"%-2d\00"
define void @shuffle_board(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
store i32** %0, i32*** %3
store i32 %1, i32* %4
%11 = load i32, i32* @LINES
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 4
%14 = sub nsw i32 %11, %13
%15 = sdiv i32 %14, 2
store i32 %15, i32* %10
%16 = load i32, i32* @COLS
%17 = load i32, i32* %4
%18 = mul nsw i32 %17, 6
%19 = sub nsw i32 %16, %18
%20 = sdiv i32 %19, 2
store i32 %20, i32* %9
%21 = call i32 (...) @clear()
%22 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 24, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @stdscr
%24 = load i32, i32* %10
%25 = load i32, i32* %9
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = call i32 @board(i32 %23, i32 %24, i32 %25, i32 %26, i32 %27, i32 6, i32 4)
store i32 2, i32* %8
store i32 3, i32* %7
store i32 0, i32* %6
br label %29
29: ; preds = %77, %2
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %80
33: ; preds = %29
store i32 0, i32* %5
br label %34
34: ; preds = %73, %33
%35 = load i32, i32* %5
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %76
38: ; preds = %34
%39 = load i32**, i32*** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32*, i32** %39, i64 %41
%43 = load i32*, i32** %42
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %72
49: ; preds = %38
%50 = load i32, i32* %10
%51 = load i32, i32* %6
%52 = mul nsw i32 %51, 4
%53 = add nsw i32 %50, %52
%54 = load i32, i32* %8
%55 = add nsw i32 %53, %54
%56 = load i32, i32* %9
%57 = load i32, i32* %5
%58 = mul nsw i32 %57, 6
%59 = add nsw i32 %56, %58
%60 = load i32, i32* %7
%61 = add nsw i32 %59, %60
%62 = load i32**, i32*** %3
%63 = load i32, i32* %5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32*, i32** %62, i64 %64
%66 = load i32*, i32** %65
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
%70 = load i32, i32* %69
%71 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %55, i32 %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %49, %38
br label %73
73: ; preds = %72
%74 = load i32, i32* %5
%75 = add nsw i32 %74, 1
store i32 %75, i32* %5
br label %34
76: ; preds = %34
br label %77
77: ; preds = %76
%78 = load i32, i32* %6
%79 = add nsw i32 %78, 1
store i32 %79, i32* %6
br label %29
80: ; preds = %29
%81 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
@LINES = global i32 0
@COLS = global i32 0
@.str = [17 x i8] c"Press F1 to Exit\00"
@stdscr = global i32 0
@.str.1 = [5 x i8] c"%-2d\00"
define void @shuffle_board(i32** nocapture %0, i32 %1) {
%3 = load i32, i32* @LINES
%4 = mul i32 %1, -4
%5 = add i32 %3, %4
%6 = sdiv i32 %5, 2
%7 = load i32, i32* @COLS
%8 = mul i32 %1, -6
%9 = add i32 %7, %8
%10 = sdiv i32 %9, 2
%11 = tail call i32 (...) @clear()
%12 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 24, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stdscr
%14 = tail call i32 @board(i32 %13, i32 %6, i32 %10, i32 %1, i32 %1, i32 6, i32 4)
%15 = icmp sgt i32 %1, 0
br i1 %15, label %16, label %43
16: ; preds = %2
%17 = add nsw i32 %6, 2
%18 = add nsw i32 %10, 3
%19 = zext i32 %1 to i64
br label %20
20: ; preds = %40, %16
%21 = phi i64 [ 0, %16 ], [ %41, %40 ]
%22 = trunc i64 %21 to i32
%23 = shl nsw i32 %22, 2
%24 = add i32 %17, %23
br label %25
25: ; preds = %20, %37
%26 = phi i64 [ 0, %20 ], [ %38, %37 ]
%27 = getelementptr inbounds i32*, i32** %0, i64 %26
%28 = load i32*, i32** %27
%29 = getelementptr inbounds i32, i32* %28, i64 %21
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %25
%33 = trunc i64 %26 to i32
%34 = mul nsw i32 %33, 6
%35 = add i32 %18, %34
%36 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 %24, i32 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %37
37: ; preds = %25, %32
%38 = add nuw nsw i64 %26, 1
%39 = icmp eq i64 %38, %19
br i1 %39, label %40, label %25
40: ; preds = %37
%41 = add nuw nsw i64 %21, 1
%42 = icmp eq i64 %41, %19
br i1 %42, label %43, label %20
43: ; preds = %40, %2
%44 = tail call i32 (...) @refresh()
ret void
}