#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 */
scalar_t__ isStableGrid(int **, int);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int grid[100][100], T, mSize, caseId, row, col;
  scanf("%d", &T);
  caseId = 1;
  while (caseId <= T) {
    scanf("%d", &mSize);
    for (row = 0; row < mSize; row++)
      for (col = 0; col < mSize; col++)
        scanf("%d", &grid[row][col]);
    printf("Case %d: %s\n", caseId, isStableGrid(grid, mSize) ? "yes" : "no");
    caseId++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x9c54(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x9c5c(%rbp)
mov    -0x9c5c(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jg     1278 <main+0x148>
lea    0xe88(%rip),%rdi
lea    -0x9c58(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x9c60(%rbp)
mov    -0x9c60(%rbp),%eax
cmp    -0x9c58(%rbp),%eax
jge    121b <main+0xeb>
movl   $0x0,-0x9c64(%rbp)
mov    -0x9c64(%rbp),%eax
cmp    -0x9c58(%rbp),%eax
jge    1202 <main+0xd2>
movslq -0x9c60(%rbp),%rax
lea    -0x9c50(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
movslq -0x9c64(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe17(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x9c64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c64(%rbp)
jmp    11aa <main+0x7a>
jmp    1207 <main+0xd7>
mov    -0x9c60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c60(%rbp)
jmp    118e <main+0x5e>
mov    -0x9c5c(%rbp),%eax
mov    %eax,-0x9c68(%rbp)
lea    -0x9c50(%rbp),%rdi
mov    -0x9c58(%rbp),%esi
call   1040 <isStableGrid@plt>
mov    -0x9c68(%rbp),%esi
mov    %rax,%rcx
lea    0xdcb(%rip),%rdx
lea    0xdc0(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xda4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x9c5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c5c(%rbp)
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0x9c70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c58,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    120f <main+0xdf>
mov    $0x1,%r14d
lea    0xe96(%rip),%rbx
jmp    11ac <main+0x7c>
nopl   0x0(%rax)
lea    0x10(%rsp),%rdi
call   1040 <isStableGrid@plt>
test   %rax,%rax
lea    0xe8c(%rip),%rdx
lea    0xe89(%rip),%rax
cmove  %rax,%rdx
lea    0xe6d(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
lea    0x1(%r14),%eax
cmp    0xc(%rsp),%r14d
mov    %eax,%r14d
jge    120f <main+0xdf>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    1170 <main+0x40>
lea    0x10(%rsp),%r12
xor    %r13d,%r13d
jmp    11e3 <main+0xb3>
nopl   0x0(%rax,%rax,1)
movslq %esi,%rax
add    $0x1,%r13
add    $0x190,%r12
cmp    %rax,%r13
jge    1170 <main+0x40>
test   %esi,%esi
jle    11d0 <main+0xa0>
mov    %r12,%rbp
xor    %r15d,%r15d
nopl   (%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
add    $0x1,%r15
movslq 0x8(%rsp),%rsi
add    $0x4,%rbp
cmp    %rsi,%r15
jl     11f0 <main+0xc0>
jmp    11d0 <main+0xa0>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [13 x i8] c"Case %d: %s\0A\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [3 x i8] c"no\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x [100 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 1, i32* %5
br label %9
9: ; preds = %39, %0
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %51
13: ; preds = %9
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %6
br label %15
15: ; preds = %36, %13
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %39
19: ; preds = %15
store i32 0, i32* %7
br label %20
20: ; preds = %32, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %26
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %27, i64 0, i64 %29
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %30)
br label %32
32: ; preds = %24
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %20
35: ; preds = %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %15
39: ; preds = %15
%40 = load i32, i32* %5
%41 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 0
%42 = bitcast [100 x i32]* %41 to i32**
%43 = load i32, i32* %4
%44 = call i64 @isStableGrid(i32** %42, i32 %43)
%45 = icmp ne i64 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%48 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %40, i8* %47)
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %9
51: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [13 x i8] c"Case %d: %s\0A\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [3 x i8] c"no\00"
define i32 @main() {
%1 = alloca [100 x [100 x i32]]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [100 x [100 x i32]]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 1
br i1 %9, label %43, label %10
10: ; preds = %0
%11 = bitcast [100 x [100 x i32]]* %1 to i32**
br label %12
12: ; preds = %10, %34
%13 = phi i32 [ 1, %10 ], [ %40, %34 ]
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %34
17: ; preds = %12, %29
%18 = phi i32 [ %30, %29 ], [ %15, %12 ]
%19 = phi i64 [ %32, %29 ], [ 0, %12 ]
%20 = icmp sgt i32 %18, 0
br i1 %20, label %21, label %29
21: ; preds = %17, %21
%22 = phi i64 [ %25, %21 ], [ 0, %17 ]
%23 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %19, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %22, 1
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %21, label %29
29: ; preds = %21, %17
%30 = phi i32 [ %18, %17 ], [ %26, %21 ]
%31 = sext i32 %30 to i64
%32 = add nuw nsw i64 %19, 1
%33 = icmp slt i64 %32, %31
br i1 %33, label %17, label %34
34: ; preds = %29, %12
%35 = phi i32 [ %15, %12 ], [ %30, %29 ]
%36 = call i64 @isStableGrid(i32** %11, i32 %35)
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%39 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %38)
%40 = add nuw nsw i32 %13, 1
%41 = load i32, i32* %2
%42 = icmp slt i32 %13, %41
br i1 %42, label %12, label %43
43: ; preds = %34, %0
ret i32 0
}