#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*/ build_solver(double **, double **, double **, int, int, int);
int /*<<< orphan*/ final_print(double **, int, int);
int /*<<< orphan*/ find_factors(double **, int, int, int);
int /*<<< orphan*/ finishSolvingmakeLowerDiag(double **, int);
int /*<<< orphan*/ makeLowerDiag(double **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int cols, rows, distance;
  int i, j;
  double image[10][10];
  double factors[10][10];
  double solver[10 * 10][10 * 10 + 1];
  double temp;
  scanf("%d %d %d", &cols, &rows, &distance);
  while (!(cols == 0 && rows == 0 && distance == 0)) {
    for (i = 0; i < rows; i++) {
      for (j = 0; j < cols; j++) {
        scanf("%lf", &temp);
        image[i][j] = temp;
        factors[i][j] = 0.0;
      }
    }
    find_factors(factors, cols, rows, distance);
    build_solver(solver, factors, image, cols, rows, distance);
    makeLowerDiag(solver, cols * rows);
    finishSolvingmakeLowerDiag(solver, cols * rows);
    final_print(solver, cols, rows);
    printf("\n");
    scanf("%d %d %d", &cols, &rows, &distance);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x14210,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1080 <scanf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x14209(%rbp)
jne    11cd <main+0x5d>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x14209(%rbp)
jne    11cd <main+0x5d>
cmpl   $0x0,-0x10(%rbp)
sete   %al
mov    %al,-0x14209(%rbp)
mov    -0x14209(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    11e2 <main+0x72>
jmp    131c <main+0x1ac>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127f <main+0x10f>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126c <main+0xfc>
lea    0xdfa(%rip),%rdi
lea    -0x14208(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
movsd  -0x14208(%rbp),%xmm0
ff
movslq -0x14(%rbp),%rcx
lea    -0x340(%rbp),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movslq -0x14(%rbp),%rcx
lea    -0x660(%rbp),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fc <main+0x8c>
jmp    1271 <main+0x101>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e9 <main+0x79>
lea    -0x660(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <find_factors@plt>
lea    -0x14200(%rbp),%rdi
lea    -0x660(%rbp),%rsi
lea    -0x340(%rbp),%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x10(%rbp),%r9d
call   1090 <build_solver@plt>
lea    -0x14200(%rbp),%rdi
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
call   1060 <makeLowerDiag@plt>
lea    -0x14200(%rbp),%rdi
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
call   1070 <finishSolvingmakeLowerDiag@plt>
lea    -0x14200(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <final_print@plt>
lea    0xd15(%rip),%rdi
call   1050 <printf@plt>
lea    0xcfc(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1080 <scanf@plt>
jmp    119c <main+0x2c>
xor    %eax,%eax
add    $0x14210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x14208,%rsp
lea    0xe78(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
test   %esi,%esi
jne    11ba <main+0x4a>
test   %edx,%edx
jne    11ba <main+0x4a>
test   %ecx,%ecx
je     130a <main+0x19a>
lea    0x340(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0xe3b(%rip),%r12
lea    0x18(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %edx,%edx
jle    1261 <main+0xf1>
xor    %ebp,%ebp
jmp    1204 <main+0x94>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
movslq %edx,%rax
add    $0x50,%r14
add    $0x50,%r15
cmp    %rax,%rbp
jge    1250 <main+0xe0>
test   %esi,%esi
jle    11f0 <main+0x80>
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r14,%r13,8)
movq   $0x0,(%r15,%r13,8)
add    $0x1,%r13
movslq 0x10(%rsp),%rsi
cmp    %rsi,%r13
jl     1210 <main+0xa0>
mov    0xc(%rsp),%edx
jmp    11f0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x14(%rsp),%ecx
lea    0x340(%rsp),%r14
lea    0x20(%rsp),%r15
mov    %r15,%rdi
call   1040 <find_factors@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x14(%rsp),%r9d
lea    0x660(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1090 <build_solver@plt>
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
mov    %rbp,%rdi
call   1060 <makeLowerDiag@plt>
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
mov    %rbp,%rdi
call   1070 <finishSolvingmakeLowerDiag@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbp,%rdi
call   1050 <final_print@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd30(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
test   %esi,%esi
jne    11e0 <main+0x70>
test   %edx,%edx
jne    11e0 <main+0x70>
test   %ecx,%ecx
jne    11e0 <main+0x70>
xor    %eax,%eax
add    $0x14208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x [10 x double]]
%8 = alloca [10 x [10 x double]]
%9 = alloca [100 x [101 x double]]
%10 = alloca double
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
br label %12
12: ; preds = %56, %0
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 0
br label %21
21: ; preds = %18, %15, %12
%22 = phi i1 [ false, %15 ], [ false, %12 ], [ %20, %18 ]
%23 = xor i1 %22, true
br i1 %23, label %24, label %92
24: ; preds = %21
store i32 0, i32* %5
br label %25
25: ; preds = %53, %24
%26 = load i32, i32* %5
%27 = load i32, i32* %3
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %56
29: ; preds = %25
store i32 0, i32* %6
br label %30
30: ; preds = %49, %29
%31 = load i32, i32* %6
%32 = load i32, i32* %2
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %52
34: ; preds = %30
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %10)
%36 = load double, double* %10
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %7, i64 0, i64 %38
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10 x double], [10 x double]* %39, i64 0, i64 %41
store double %36, double* %42
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %8, i64 0, i64 %44
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [10 x double], [10 x double]* %45, i64 0, i64 %47
store double 0.000000e+00, double* %48
br label %49
49: ; preds = %34
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %30
52: ; preds = %30
br label %53
53: ; preds = %52
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 1
store i32 %55, i32* %5
br label %25
56: ; preds = %25
%57 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %8, i64 0, i64 0
%58 = bitcast [10 x double]* %57 to double**
%59 = load i32, i32* %2
%60 = load i32, i32* %3
%61 = load i32, i32* %4
%62 = call i32 @find_factors(double** %58, i32 %59, i32 %60, i32 %61)
%63 = getelementptr inbounds [100 x [101 x double]], [100 x [101 x double]]* %9, i64 0, i64 0
%64 = bitcast [101 x double]* %63 to double**
%65 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %8, i64 0, i64 0
%66 = bitcast [10 x double]* %65 to double**
%67 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %7, i64 0, i64 0
%68 = bitcast [10 x double]* %67 to double**
%69 = load i32, i32* %2
%70 = load i32, i32* %3
%71 = load i32, i32* %4
%72 = call i32 @build_solver(double** %64, double** %66, double** %68, i32 %69, i32 %70, i32 %71)
%73 = getelementptr inbounds [100 x [101 x double]], [100 x [101 x double]]* %9, i64 0, i64 0
%74 = bitcast [101 x double]* %73 to double**
%75 = load i32, i32* %2
%76 = load i32, i32* %3
%77 = mul nsw i32 %75, %76
%78 = call i32 @makeLowerDiag(double** %74, i32 %77)
%79 = getelementptr inbounds [100 x [101 x double]], [100 x [101 x double]]* %9, i64 0, i64 0
%80 = bitcast [101 x double]* %79 to double**
%81 = load i32, i32* %2
%82 = load i32, i32* %3
%83 = mul nsw i32 %81, %82
%84 = call i32 @finishSolvingmakeLowerDiag(double** %80, i32 %83)
%85 = getelementptr inbounds [100 x [101 x double]], [100 x [101 x double]]* %9, i64 0, i64 0
%86 = bitcast [101 x double]* %85 to double**
%87 = load i32, i32* %2
%88 = load i32, i32* %3
%89 = call i32 @final_print(double** %86, i32 %87, i32 %88)
%90 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%91 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
br label %12
92: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [4 x i8] c"%lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x [10 x double]]
%5 = alloca [10 x [10 x double]]
%6 = alloca [100 x [101 x double]]
%7 = alloca double
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast [10 x [10 x double]]* %4 to i8*
%12 = bitcast [10 x [10 x double]]* %5 to i8*
%13 = bitcast [100 x [101 x double]]* %6 to i8*
%14 = bitcast double* %7 to i8*
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
%20 = select i1 %17, i1 %19, i1 false
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %88, label %24
24: ; preds = %0
%25 = bitcast [10 x [10 x double]]* %5 to double**
%26 = bitcast [100 x [101 x double]]* %6 to double**
%27 = bitcast [10 x [10 x double]]* %4 to double**
br label %28
28: ; preds = %24, %58
%29 = phi i32 [ %21, %24 ], [ %85, %58 ]
%30 = phi i32 [ %16, %24 ], [ %80, %58 ]
%31 = phi i32 [ %18, %24 ], [ %82, %58 ]
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %58
33: ; preds = %28, %50
%34 = phi i32 [ %51, %50 ], [ %31, %28 ]
%35 = phi i32 [ %52, %50 ], [ %30, %28 ]
%36 = phi i64 [ %53, %50 ], [ 0, %28 ]
%37 = icmp sgt i32 %35, 0
br i1 %37, label %38, label %50
38: ; preds = %33, %38
%39 = phi i64 [ %44, %38 ], [ 0, %33 ]
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %7)
%41 = load double, double* %7
%42 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %4, i64 0, i64 %36, i64 %39
store double %41, double* %42
%43 = getelementptr inbounds [10 x [10 x double]], [10 x [10 x double]]* %5, i64 0, i64 %36, i64 %39
store double 0.000000e+00, double* %43
%44 = add nuw nsw i64 %39, 1
%45 = load i32, i32* %1
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %44, %46
br i1 %47, label %38, label %48
48: ; preds = %38
%49 = load i32, i32* %2
br label %50
50: ; preds = %48, %33
%51 = phi i32 [ %49, %48 ], [ %34, %33 ]
%52 = phi i32 [ %45, %48 ], [ %35, %33 ]
%53 = add nuw nsw i64 %36, 1
%54 = sext i32 %51 to i64
%55 = icmp slt i64 %53, %54
br i1 %55, label %33, label %56
56: ; preds = %50
%57 = load i32, i32* %3
br label %58
58: ; preds = %56, %28
%59 = phi i32 [ %29, %28 ], [ %57, %56 ]
%60 = phi i32 [ %30, %28 ], [ %52, %56 ]
%61 = phi i32 [ %31, %28 ], [ %51, %56 ]
%62 = call i32 @find_factors(double** %25, i32 %60, i32 %61, i32 %59)
%63 = load i32, i32* %1
%64 = load i32, i32* %2
%65 = load i32, i32* %3
%66 = call i32 @build_solver(double** %26, double** %25, double** %27, i32 %63, i32 %64, i32 %65)
%67 = load i32, i32* %1
%68 = load i32, i32* %2
%69 = mul nsw i32 %68, %67
%70 = call i32 @makeLowerDiag(double** %26, i32 %69)
%71 = load i32, i32* %1
%72 = load i32, i32* %2
%73 = mul nsw i32 %72, %71
%74 = call i32 @finishSolvingmakeLowerDiag(double** %26, i32 %73)
%75 = load i32, i32* %1
%76 = load i32, i32* %2
%77 = call i32 @final_print(double** %26, i32 %75, i32 %76)
%78 = call i32 @putchar(i32 10)
%79 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%80 = load i32, i32* %1
%81 = icmp eq i32 %80, 0
%82 = load i32, i32* %2
%83 = icmp eq i32 %82, 0
%84 = select i1 %81, i1 %83, i1 false
%85 = load i32, i32* %3
%86 = icmp eq i32 %85, 0
%87 = select i1 %84, i1 %86, i1 false
br i1 %87, label %88, label %28
88: ; preds = %58, %0
ret i32 0
}