#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__ EOF;
scalar_t__ scanf(char *, int *, int *);
double **constructMatrix(double **m, int dim) {
  int x, y;
  int i, j, k;
  int sum;
  while (scanf("%d %d", &x, &y) != EOF) {
    m[x][y] = 1.00;
  }
  for (i = 0; i < dim; i++) {
    sum = 0;
    for (j = 0; j < dim; j++) {
      sum += m[i][j];
      if (j == dim - 1 && sum == 0) {
        for (k = 0; k < dim; k++) {
          m[i][k] = 1.00;
        }
      }
    }
  }
  return (m);
}


x86 assembly (clang, -O0):
<constructMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xee2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <scanf@plt>
mov    0x2eae(%rip),%rcx
cmp    (%rcx),%rax
je     1165 <constructMatrix+0x55>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    111f <constructMatrix+0xf>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123b <constructMatrix+0x12b>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1228 <constructMatrix+0x118>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1215 <constructMatrix+0x105>
cmpl   $0x0,-0x24(%rbp)
jne    1215 <constructMatrix+0x105>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1210 <constructMatrix+0x100>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  0xe03(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d9 <constructMatrix+0xc9>
jmp    1215 <constructMatrix+0x105>
jmp    121a <constructMatrix+0x10a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <constructMatrix+0x76>
jmp    122d <constructMatrix+0x11d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <constructMatrix+0x5c>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constructMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xee5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <scanf@plt>
mov    0x2ea7(%rip),%rbx
cmp    (%rbx),%rax
je     1190 <constructMatrix+0x80>
lea    0xec3(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
nopw   0x0(%rax,%rax,1)
movslq 0xc(%rsp),%rax
mov    0x0(%rbp,%rax,8),%rax
movslq 0x8(%rsp),%rcx
movabs $0x3ff0000000000000,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <scanf@plt>
cmp    (%rbx),%rax
jne    1160 <constructMatrix+0x50>
test   %r14d,%r14d
mov    %rbp,%rax
jle    1352 <constructMatrix+0x242>
lea    -0x1(%r14),%r13d
mov    %r14d,%ecx
mov    %ecx,%r12d
and    $0xfffffffc,%r12d
lea    -0x4(%r12),%rdx
mov    %rdx,0x20(%rsp)
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %edx,%r10d
and    $0x7,%r10d
and    $0xfffffffffffffff8,%rdx
mov    %rdx,0x10(%rsp)
mov    %r10,%rdi
shl    $0x5,%rdi
xor    %r11d,%r11d
movabs $0x3ff0000000000000,%rsi
movaps 0xe19(%rip),%xmm0
mov    %rax,%r9
jmp    11fd <constructMatrix+0xed>
nopl   0x0(%rax)
add    $0x1,%r11
cmp    %rcx,%r11
je     1352 <constructMatrix+0x242>
mov    (%rax,%r11,8),%rbx
lea    0x10(%rbx),%rdx
mov    %rdx,0x18(%rsp)
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    1229 <constructMatrix+0x119>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rcx,%rbp
je     11f0 <constructMatrix+0xe0>
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
addsd  (%rbx,%rbp,8),%xmm1
cvttsd2si %xmm1,%r15d
cmp    %r13,%rbp
jne    1220 <constructMatrix+0x110>
test   %r15d,%r15d
jne    1220 <constructMatrix+0x110>
cmp    $0x4,%r14d
jae    1260 <constructMatrix+0x150>
xor    %edx,%edx
jmp    1340 <constructMatrix+0x230>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpq   $0x1c,0x20(%rsp)
jae    126f <constructMatrix+0x15f>
xor    %eax,%eax
jmp    12f1 <constructMatrix+0x1e1>
mov    0x10(%rsp),%r8
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movups %xmm0,(%rbx,%rax,8)
movups %xmm0,0x10(%rbx,%rax,8)
movups %xmm0,0x20(%rbx,%rax,8)
movups %xmm0,0x30(%rbx,%rax,8)
movups %xmm0,0x40(%rbx,%rax,8)
movups %xmm0,0x50(%rbx,%rax,8)
movups %xmm0,0x60(%rbx,%rax,8)
movups %xmm0,0x70(%rbx,%rax,8)
movups %xmm0,0x80(%rbx,%rax,8)
movups %xmm0,0x90(%rbx,%rax,8)
movups %xmm0,0xa0(%rbx,%rax,8)
movups %xmm0,0xb0(%rbx,%rax,8)
movups %xmm0,0xc0(%rbx,%rax,8)
movups %xmm0,0xd0(%rbx,%rax,8)
movups %xmm0,0xe0(%rbx,%rax,8)
movups %xmm0,0xf0(%rbx,%rax,8)
add    $0x20,%rax
add    $0xfffffffffffffff8,%r8
jne    1280 <constructMatrix+0x170>
test   %r10,%r10
je     1322 <constructMatrix+0x212>
mov    0x18(%rsp),%rdx
lea    (%rdx,%rax,8),%rax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movups %xmm0,-0x10(%rax,%rdx,1)
movups %xmm0,(%rax,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%rdi
jne    1310 <constructMatrix+0x200>
mov    %r12,%rdx
cmp    %rcx,%r12
mov    %r9,%rax
je     1220 <constructMatrix+0x110>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rsi,(%rbx,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1340 <constructMatrix+0x230>
jmp    1220 <constructMatrix+0x110>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@EOF = global i64 0
define double** @constructMatrix(double** %0, i32 %1) {
%3 = alloca double**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double** %0, double*** %3
store i32 %1, i32* %4
br label %11
11: ; preds = %15, %2
%12 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6)
%13 = load i64, i64* @EOF
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load double**, double*** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double*, double** %16, i64 %18
%20 = load double*, double** %19
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
store double 1.000000e+00, double* %23
br label %11
24: ; preds = %11
store i32 0, i32* %7
br label %25
25: ; preds = %78, %24
%26 = load i32, i32* %7
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %81
29: ; preds = %25
store i32 0, i32* %10
store i32 0, i32* %8
br label %30
30: ; preds = %74, %29
%31 = load i32, i32* %8
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %77
34: ; preds = %30
%35 = load double**, double*** %3
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double*, double** %35, i64 %37
%39 = load double*, double** %38
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = load i32, i32* %10
%45 = sitofp i32 %44 to double
%46 = fadd double %45, %43
%47 = fptosi double %46 to i32
store i32 %47, i32* %10
%48 = load i32, i32* %8
%49 = load i32, i32* %4
%50 = sub nsw i32 %49, 1
%51 = icmp eq i32 %48, %50
br i1 %51, label %52, label %73
52: ; preds = %34
%53 = load i32, i32* %10
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %73
55: ; preds = %52
store i32 0, i32* %9
br label %56
56: ; preds = %69, %55
%57 = load i32, i32* %9
%58 = load i32, i32* %4
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %72
60: ; preds = %56
%61 = load double**, double*** %3
%62 = load i32, i32* %7
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double*, double** %61, i64 %63
%65 = load double*, double** %64
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
store double 1.000000e+00, double* %68
br label %69
69: ; preds = %60
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
br label %56
72: ; preds = %56
br label %73
73: ; preds = %72, %52, %34
br label %74
74: ; preds = %73
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %30
77: ; preds = %30
br label %78
78: ; preds = %77
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %25
81: ; preds = %25
%82 = load double**, double*** %3
ret double** %82
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@EOF = global i64 0
define double** @constructMatrix(double** returned %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %27
10: ; preds = %27, %2
%11 = icmp sgt i32 %1, 0
br i1 %11, label %12, label %126
12: ; preds = %10
%13 = add nsw i32 %1, -1
%14 = zext i32 %13 to i64
%15 = zext i32 %1 to i64
%16 = and i64 %15, 4294967292
%17 = add nsw i64 %16, -4
%18 = lshr exact i64 %17, 2
%19 = add nuw nsw i64 %18, 1
%20 = icmp ult i32 %1, 4
%21 = and i64 %15, 4294967292
%22 = and i64 %19, 7
%23 = icmp ult i64 %17, 28
%24 = and i64 %19, 9223372036854775800
%25 = icmp eq i64 %22, 0
%26 = icmp eq i64 %21, %15
br label %38
27: ; preds = %2, %27
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double*, double** %0, i64 %29
%31 = load double*, double** %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double 1.000000e+00, double* %34
%35 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%36 = load i64, i64* @EOF
%37 = icmp eq i64 %35, %36
br i1 %37, label %10, label %27
38: ; preds = %123, %12
%39 = phi i64 [ 0, %12 ], [ %124, %123 ]
%40 = getelementptr inbounds double*, double** %0, i64 %39
%41 = load double*, double** %40
br label %42
42: ; preds = %38, %120
%43 = phi i64 [ 0, %38 ], [ %121, %120 ]
%44 = phi i32 [ 0, %38 ], [ %49, %120 ]
%45 = getelementptr inbounds double, double* %41, i64 %43
%46 = load double, double* %45
%47 = sitofp i32 %44 to double
%48 = fadd double %46, %47
%49 = fptosi double %48 to i32
%50 = icmp ne i64 %43, %14
%51 = icmp ne i32 %49, 0
%52 = select i1 %50, i1 true, i1 %51
br i1 %52, label %120, label %53
53: ; preds = %42
br i1 %20, label %113, label %54
54: ; preds = %53
br i1 %23, label %100, label %55
55: ; preds = %54, %55
%56 = phi i64 [ %97, %55 ], [ 0, %54 ]
%57 = phi i64 [ %98, %55 ], [ 0, %54 ]
%58 = getelementptr inbounds double, double* %41, i64 %56
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %59
%60 = getelementptr inbounds double, double* %58, i64 2
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %61
%62 = or i64 %56, 4
%63 = getelementptr inbounds double, double* %41, i64 %62
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %64
%65 = getelementptr inbounds double, double* %63, i64 2
%66 = bitcast double* %65 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %66
%67 = or i64 %56, 8
%68 = getelementptr inbounds double, double* %41, i64 %67
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %69
%70 = getelementptr inbounds double, double* %68, i64 2
%71 = bitcast double* %70 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %71
%72 = or i64 %56, 12
%73 = getelementptr inbounds double, double* %41, i64 %72
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %74
%75 = getelementptr inbounds double, double* %73, i64 2
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %76
%77 = or i64 %56, 16
%78 = getelementptr inbounds double, double* %41, i64 %77
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %79
%80 = getelementptr inbounds double, double* %78, i64 2
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %81
%82 = or i64 %56, 20
%83 = getelementptr inbounds double, double* %41, i64 %82
%84 = bitcast double* %83 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %84
%85 = getelementptr inbounds double, double* %83, i64 2
%86 = bitcast double* %85 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %86
%87 = or i64 %56, 24
%88 = getelementptr inbounds double, double* %41, i64 %87
%89 = bitcast double* %88 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %89
%90 = getelementptr inbounds double, double* %88, i64 2
%91 = bitcast double* %90 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %91
%92 = or i64 %56, 28
%93 = getelementptr inbounds double, double* %41, i64 %92
%94 = bitcast double* %93 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %94
%95 = getelementptr inbounds double, double* %93, i64 2
%96 = bitcast double* %95 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %96
%97 = add nuw i64 %56, 32
%98 = add i64 %57, 8
%99 = icmp eq i64 %98, %24
br i1 %99, label %100, label %55
100: ; preds = %55, %54
%101 = phi i64 [ 0, %54 ], [ %97, %55 ]
br i1 %25, label %112, label %102
102: ; preds = %100, %102
%103 = phi i64 [ %109, %102 ], [ %101, %100 ]
%104 = phi i64 [ %110, %102 ], [ 0, %100 ]
%105 = getelementptr inbounds double, double* %41, i64 %103
%106 = bitcast double* %105 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %106
%107 = getelementptr inbounds double, double* %105, i64 2
%108 = bitcast double* %107 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %108
%109 = add nuw i64 %103, 4
%110 = add i64 %104, 1
%111 = icmp eq i64 %110, %22
br i1 %111, label %112, label %102
112: ; preds = %102, %100
br i1 %26, label %120, label %113
113: ; preds = %53, %112
%114 = phi i64 [ 0, %53 ], [ %21, %112 ]
br label %115
115: ; preds = %113, %115
%116 = phi i64 [ %118, %115 ], [ %114, %113 ]
%117 = getelementptr inbounds double, double* %41, i64 %116
store double 1.000000e+00, double* %117
%118 = add nuw nsw i64 %116, 1
%119 = icmp eq i64 %118, %15
br i1 %119, label %120, label %115
120: ; preds = %115, %112, %42
%121 = add nuw nsw i64 %43, 1
%122 = icmp eq i64 %121, %15
br i1 %122, label %123, label %42
123: ; preds = %120
%124 = add nuw nsw i64 %39, 1
%125 = icmp eq i64 %124, %15
br i1 %125, label %126, label %38
126: ; preds = %123, %10
ret double** %0
}