#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*/ copyMatrix(double ***, double **, unsigned int,
                              unsigned int);
int /*<<< orphan*/ dampMatrix(double **, double, unsigned int, unsigned int);
int /*<<< orphan*/ expontiationUntilConverge(double ***, double **,
                                             unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ matrixAlloc(double ***, unsigned int, unsigned int);
int /*<<< orphan*/ matrixFree(double **, unsigned int);
int /*<<< orphan*/ printIndexedVector(double *, unsigned int);
int scanf(char *, unsigned int *, ...);
int /*<<< orphan*/ stochasticMatrix(double **, unsigned int, unsigned int);
int main(int argc, char const *argv[]) {
  unsigned D;
  double dampingFactor;
  double **matriz = NULL;
  double **saida = NULL;
  unsigned i, j;
  scanf("%u %lf", &D, &dampingFactor);
  matrixAlloc(&matriz, D, D);
  while (scanf("%u %u", &i, &j) == 2) {
    matriz[i][j] = 1;
  }
  stochasticMatrix(matriz, D, D);
  dampMatrix(matriz, dampingFactor, D, D);
  copyMatrix(&saida, matriz, D, D);
  expontiationUntilConverge(&saida, matriz, D, 0);
  printIndexedVector(saida[0], D);
  matrixFree(saida, D);
  matrixFree(matriz, D);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe5b(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0x28(%rbp),%rdi
call   1070 <matrixAlloc@plt>
lea    0xe3d(%rip),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    120a <main+0x8a>
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
movsd  0xe00(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    11cb <main+0x4b>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <stochasticMatrix@plt>
mov    -0x28(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <dampMatrix@plt>
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    -0x30(%rbp),%rdi
call   10a0 <copyMatrix@plt>
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x30(%rbp),%rdi
xor    %ecx,%ecx
call   1060 <expontiationUntilConverge@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x14(%rbp),%esi
call   1040 <printIndexedVector@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <matrixFree@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <matrixFree@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
lea    0xe5c(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x4(%rsp),%edx
lea    0x8(%rsp),%rdi
mov    %edx,%esi
call   1070 <matrixAlloc@plt>
lea    0xe3b(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    122a <main+0xaa>
movabs $0x3ff0000000000000,%r12
lea    0xe14(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%rbx
nopl   (%rax)
mov    0x8(%rsp),%rax
mov    0x14(%rsp),%ecx
mov    (%rax,%rcx,8),%rax
mov    0x10(%rsp),%ecx
mov    %r12,(%rax,%rcx,8)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x2,%eax
je     1200 <main+0x80>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
mov    %edx,%esi
call   1030 <stochasticMatrix@plt>
mov    0x8(%rsp),%rdi
movsd  0x20(%rsp),%xmm0
mov    0x4(%rsp),%edx
mov    %edx,%esi
call   1050 <dampMatrix@plt>
mov    0x8(%rsp),%rsi
mov    0x4(%rsp),%ecx
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %ecx,%edx
call   10a0 <copyMatrix@plt>
mov    0x8(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
xor    %ecx,%ecx
call   1060 <expontiationUntilConverge@plt>
mov    0x18(%rsp),%rax
mov    (%rax),%rdi
mov    0x4(%rsp),%esi
call   1040 <printIndexedVector@plt>
mov    0x18(%rsp),%rdi
mov    0x4(%rsp),%esi
call   1090 <matrixFree@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
call   1090 <matrixFree@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%u %lf\00"
@.str.1 = [6 x i8] c"%u %u\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double**
%9 = alloca double**
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double** null, double*** %8
store double** null, double*** %9
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %6, double* %7)
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = call i32 @matrixAlloc(double*** %8, i32 %13, i32 %14)
br label %16
16: ; preds = %19, %2
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %11)
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load double**, double*** %8
%21 = load i32, i32* %10
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds double*, double** %20, i64 %22
%24 = load double*, double** %23
%25 = load i32, i32* %11
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
store double 1.000000e+00, double* %27
br label %16
28: ; preds = %16
%29 = load double**, double*** %8
%30 = load i32, i32* %6
%31 = load i32, i32* %6
%32 = call i32 @stochasticMatrix(double** %29, i32 %30, i32 %31)
%33 = load double**, double*** %8
%34 = load double, double* %7
%35 = load i32, i32* %6
%36 = load i32, i32* %6
%37 = call i32 @dampMatrix(double** %33, double %34, i32 %35, i32 %36)
%38 = load double**, double*** %8
%39 = load i32, i32* %6
%40 = load i32, i32* %6
%41 = call i32 @copyMatrix(double*** %9, double** %38, i32 %39, i32 %40)
%42 = load double**, double*** %8
%43 = load i32, i32* %6
%44 = call i32 @expontiationUntilConverge(double*** %9, double** %42, i32 %43, i32 0)
%45 = load double**, double*** %9
%46 = getelementptr inbounds double*, double** %45, i64 0
%47 = load double*, double** %46
%48 = load i32, i32* %6
%49 = call i32 @printIndexedVector(double* %47, i32 %48)
%50 = load double**, double*** %9
%51 = load i32, i32* %6
%52 = call i32 @matrixFree(double** %50, i32 %51)
%53 = load double**, double*** %8
%54 = load i32, i32* %6
%55 = call i32 @matrixFree(double** %53, i32 %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%u %lf\00"
@.str.1 = [6 x i8] c"%u %u\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double**
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
%10 = bitcast double* %4 to i8*
%11 = bitcast double*** %5 to i8*
store double** null, double*** %5
%12 = bitcast double*** %6 to i8*
store double** null, double*** %6
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %3, double* %4)
%16 = load i32, i32* %3
%17 = call i32 @matrixAlloc(double*** %5, i32 %16, i32 %16)
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8)
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %31
20: ; preds = %2, %20
%21 = load double**, double*** %5
%22 = load i32, i32* %7
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
%25 = load double*, double** %24
%26 = load i32, i32* %8
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
store double 1.000000e+00, double* %28
%29 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8)
%30 = icmp eq i32 %29, 2
br i1 %30, label %20, label %31
31: ; preds = %20, %2
%32 = load double**, double*** %5
%33 = load i32, i32* %3
%34 = call i32 @stochasticMatrix(double** %32, i32 %33, i32 %33)
%35 = load double**, double*** %5
%36 = load double, double* %4
%37 = load i32, i32* %3
%38 = call i32 @dampMatrix(double** %35, double %36, i32 %37, i32 %37)
%39 = load double**, double*** %5
%40 = load i32, i32* %3
%41 = call i32 @copyMatrix(double*** %6, double** %39, i32 %40, i32 %40)
%42 = load double**, double*** %5
%43 = load i32, i32* %3
%44 = call i32 @expontiationUntilConverge(double*** %6, double** %42, i32 %43, i32 0)
%45 = load double**, double*** %6
%46 = load double*, double** %45
%47 = load i32, i32* %3
%48 = call i32 @printIndexedVector(double* %46, i32 %47)
%49 = load double**, double*** %6
%50 = load i32, i32* %3
%51 = call i32 @matrixFree(double** %49, i32 %50)
%52 = load double**, double*** %5
%53 = load i32, i32* %3
%54 = call i32 @matrixFree(double** %52, i32 %53)
ret i32 0
}