#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 **new_matrix();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ show_matrix(int **);
int **solve(int **);
int main(int argc, const char *argv[]) {
  int m, n, i, j, **a = new_matrix();
  scanf("%d", &n);
  for (m = 0; m < n; m++) {
    for (i = 0; i < 9; i++)
      for (j = 0; j < 9; j++)
        scanf("%1d", &a[i][j]);
    a = solve(a);
    show_matrix(a);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <new_matrix@plt>
mov    %rax,-0x28(%rbp)
lea    0xe88(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122a <main+0xda>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jge    11fa <main+0xaa>
movl   $0x0,-0x20(%rbp)
cmpl   $0x9,-0x20(%rbp)
jge    11e7 <main+0x97>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2f(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ac <main+0x5c>
jmp    11ec <main+0x9c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119b <main+0x4b>
mov    -0x28(%rbp),%rdi
call   1030 <solve@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <show_matrix@plt>
lea    0xdf0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <main+0x38>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
xor    %eax,%eax
call   1060 <new_matrix@plt>
mov    %rax,%r12
lea    0xe94(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1266 <main+0x116>
lea    0xe7b(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x4,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x8,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0xc,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x10,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x14,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x18,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x1c,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    (%r12,%rbx,8),%rsi
add    $0x20,%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
add    $0x1,%rbx
cmp    $0x9,%rbx
jne    11a0 <main+0x50>
mov    %r12,%rdi
call   1030 <solve@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <show_matrix@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r15d
cmp    0x4(%rsp),%r15d
jl     1190 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%1d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32** (...) @new_matrix()
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %50
9: ; preds = %2, %43
%10 = phi i32** [ %44, %43 ], [ %5, %2 ]
%11 = phi i32 [ %47, %43 ], [ 0, %2 ]
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ 0, %9 ], [ %41, %12 ]
%14 = getelementptr inbounds i32*, i32** %10, i64 %13
%15 = load i32*, i32** %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = load i32*, i32** %14
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = load i32*, i32** %14
%21 = getelementptr inbounds i32, i32* %20, i64 2
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = load i32*, i32** %14
%24 = getelementptr inbounds i32, i32* %23, i64 3
%25 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%26 = load i32*, i32** %14
%27 = getelementptr inbounds i32, i32* %26, i64 4
%28 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %27)
%29 = load i32*, i32** %14
%30 = getelementptr inbounds i32, i32* %29, i64 5
%31 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %30)
%32 = load i32*, i32** %14
%33 = getelementptr inbounds i32, i32* %32, i64 6
%34 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %33)
%35 = load i32*, i32** %14
%36 = getelementptr inbounds i32, i32* %35, i64 7
%37 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %36)
%38 = load i32*, i32** %14
%39 = getelementptr inbounds i32, i32* %38, i64 8
%40 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %39)
%41 = add nuw nsw i64 %13, 1
%42 = icmp eq i64 %41, 9
br i1 %42, label %43, label %12
43: ; preds = %12
%44 = call i32** @solve(i32** %10)
%45 = call i32 @show_matrix(i32** %44)
%46 = call i32 @putchar(i32 10)
%47 = add nuw nsw i32 %11, 1
%48 = load i32, i32* %3
%49 = icmp slt i32 %47, %48
br i1 %49, label %9, label %50
50: ; preds = %43, %2
ret i32 0
}