#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__ calloc(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int rand();
int main(void) {
  int **v;
  int n = 2000;
  int i;
  int j;
  v = (int **)calloc(n, sizeof(int *));
  for (i = 0; i < n; i++) {
    v[i] = (int *)calloc(n, sizeof(int));
  }
  for (i = 0; i < n; i++) {
  }
  puts("Matriz sem os valores do grafo");
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      printf("%d ", v[i][j]);
    }
    printf("\n");
  }
  printf("\n\n");
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      v[i][j] = rand() % 2000;
    }
  }
  puts("Matriz com os valores do grafo");
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      printf("%d ", v[i][j]);
    }
    printf("\n");
  }
  puts("\nA primeira vez que cada vértice é a origem (Dijkstra é usado)\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7d0,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a4 <main+0x64>
mov    -0x14(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116e <main+0x2e>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ca <main+0x8a>
jmp    11bc <main+0x7c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ab <main+0x6b>
lea    0xe2f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1247 <main+0x107>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122b <main+0xeb>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f0 <main+0xb0>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11dd <main+0x9d>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12be <main+0x17e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ab <main+0x16b>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x7d0,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    126f <main+0x12f>
jmp    12b0 <main+0x170>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    125c <main+0x11c>
lea    0xd61(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    133b <main+0x1fb>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    131f <main+0x1df>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12e4 <main+0x1a4>
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12d1 <main+0x191>
lea    0xd03(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x7d0,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0x7d0,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x7d0,%rbx
jne    1170 <main+0x20>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7c(%rip),%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%r12,8),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x7d0,%rbx
jne    11c0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    $0x7d0,%r12
jne    11b0 <main+0x60>
lea    0xe87(%rip),%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x27,%rcx
add    %edx,%ecx
imul   $0x7d0,%ecx,%ecx
sub    %ecx,%eax
mov    (%r15,%r14,8),%rcx
mov    %eax,(%rcx,%rbx,4)
add    $0x1,%rbx
cmp    $0x7d0,%rbx
jne    1220 <main+0xd0>
add    $0x1,%r14
cmp    $0x7d0,%r14
jne    1210 <main+0xc0>
lea    0xdb6(%rip),%rdi
call   1040 <puts@plt>
lea    0xda6(%rip),%r14
xor    %r12d,%r12d
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%r12,8),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x7d0,%rbx
jne    1290 <main+0x140>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    $0x7d0,%r12
jne    1280 <main+0x130>
lea    0xd76(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Matriz sem os valores do grafo\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@.str.4 = [31 x i8] c"Matriz com os valores do grafo\00"
@.str.5 = [67 x i8] c"\0AA primeira vez que cada v\C3\A9rtice \C3\A9 a origem (Dijkstra \C3\A9 usado)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 2000, i32* %3
%6 = load i32, i32* %3
%7 = call i64 @calloc(i32 %6, i32 8)
%8 = inttoptr i64 %7 to i32**
store i32** %8, i32*** %2
store i32 0, i32* %4
br label %9
9: ; preds = %21, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i32, i32* %3
%15 = call i64 @calloc(i32 %14, i32 4)
%16 = inttoptr i64 %15 to i32*
%17 = load i32**, i32*** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32*, i32** %17, i64 %19
store i32* %16, i32** %20
br label %21
21: ; preds = %13
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %9
24: ; preds = %9
store i32 0, i32* %4
br label %25
25: ; preds = %30, %24
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %25
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %25
33: ; preds = %25
%34 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %35
35: ; preds = %60, %33
%36 = load i32, i32* %4
%37 = load i32, i32* %3
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %63
39: ; preds = %35
store i32 0, i32* %5
br label %40
40: ; preds = %55, %39
%41 = load i32, i32* %5
%42 = load i32, i32* %3
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %58
44: ; preds = %40
%45 = load i32**, i32*** %2
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32*, i32** %45, i64 %47
%49 = load i32*, i32** %48
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %44
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %40
58: ; preds = %40
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %60
60: ; preds = %58
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %35
63: ; preds = %35
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %65
65: ; preds = %89, %63
%66 = load i32, i32* %4
%67 = load i32, i32* %3
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %92
69: ; preds = %65
store i32 0, i32* %5
br label %70
70: ; preds = %85, %69
%71 = load i32, i32* %5
%72 = load i32, i32* %3
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %88
74: ; preds = %70
%75 = call i32 (...) @rand()
%76 = srem i32 %75, 2000
%77 = load i32**, i32*** %2
%78 = load i32, i32* %4
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32*, i32** %77, i64 %79
%81 = load i32*, i32** %80
%82 = load i32, i32* %5
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %81, i64 %83
store i32 %76, i32* %84
br label %85
85: ; preds = %74
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
store i32 %87, i32* %5
br label %70
88: ; preds = %70
br label %89
89: ; preds = %88
%90 = load i32, i32* %4
%91 = add nsw i32 %90, 1
store i32 %91, i32* %4
br label %65
92: ; preds = %65
%93 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %94
94: ; preds = %119, %92
%95 = load i32, i32* %4
%96 = load i32, i32* %3
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %122
98: ; preds = %94
store i32 0, i32* %5
br label %99
99: ; preds = %114, %98
%100 = load i32, i32* %5
%101 = load i32, i32* %3
%102 = icmp slt i32 %100, %101
br i1 %102, label %103, label %117
103: ; preds = %99
%104 = load i32**, i32*** %2
%105 = load i32, i32* %4
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i32*, i32** %104, i64 %106
%108 = load i32*, i32** %107
%109 = load i32, i32* %5
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32, i32* %108, i64 %110
%112 = load i32, i32* %111
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %112)
br label %114
114: ; preds = %103
%115 = load i32, i32* %5
%116 = add nsw i32 %115, 1
store i32 %116, i32* %5
br label %99
117: ; preds = %99
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %119
119: ; preds = %117
%120 = load i32, i32* %4
%121 = add nsw i32 %120, 1
store i32 %121, i32* %4
br label %94
122: ; preds = %94
%123 = call i32 @puts(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0))
%124 = load i32, i32* %1
ret i32 %124
}

LLVM IR (-O2):
@.str = [31 x i8] c"Matriz sem os valores do grafo\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.4 = [31 x i8] c"Matriz com os valores do grafo\00"
@.str.5 = [67 x i8] c"\0AA primeira vez que cada v\C3\A9rtice \C3\A9 a origem (Dijkstra \C3\A9 usado)\0A\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call i64 @calloc(i32 2000, i32 8)
%2 = inttoptr i64 %1 to i32**
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %8, %3 ]
%5 = tail call i64 @calloc(i32 2000, i32 4)
%6 = inttoptr i64 %5 to i32*
%7 = getelementptr inbounds i32*, i32** %2, i64 %4
store i32* %6, i32** %7
%8 = add nuw nsw i64 %4, 1
%9 = icmp eq i64 %8, 2000
br i1 %9, label %10, label %3
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %23
%13 = phi i64 [ 0, %10 ], [ %25, %23 ]
%14 = getelementptr inbounds i32*, i32** %2, i64 %13
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ 0, %12 ], [ %21, %15 ]
%17 = load i32*, i32** %14
%18 = getelementptr inbounds i32, i32* %17, i64 %16
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, 2000
br i1 %22, label %23, label %15
23: ; preds = %15
%24 = tail call i32 @putchar(i32 10)
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, 2000
br i1 %26, label %27, label %12
27: ; preds = %23
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %27, %40
%30 = phi i64 [ 0, %27 ], [ %41, %40 ]
%31 = getelementptr inbounds i32*, i32** %2, i64 %30
br label %32
32: ; preds = %29, %32
%33 = phi i64 [ 0, %29 ], [ %38, %32 ]
%34 = tail call i32 (...) @rand()
%35 = srem i32 %34, 2000
%36 = load i32*, i32** %31
%37 = getelementptr inbounds i32, i32* %36, i64 %33
store i32 %35, i32* %37
%38 = add nuw nsw i64 %33, 1
%39 = icmp eq i64 %38, 2000
br i1 %39, label %40, label %32
40: ; preds = %32
%41 = add nuw nsw i64 %30, 1
%42 = icmp eq i64 %41, 2000
br i1 %42, label %43, label %29
43: ; preds = %40
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %43, %56
%46 = phi i64 [ 0, %43 ], [ %58, %56 ]
%47 = getelementptr inbounds i32*, i32** %2, i64 %46
br label %48
48: ; preds = %45, %48
%49 = phi i64 [ 0, %45 ], [ %54, %48 ]
%50 = load i32*, i32** %47
%51 = getelementptr inbounds i32, i32* %50, i64 %49
%52 = load i32, i32* %51
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = add nuw nsw i64 %49, 1
%55 = icmp eq i64 %54, 2000
br i1 %55, label %56, label %48
56: ; preds = %48
%57 = tail call i32 @putchar(i32 10)
%58 = add nuw nsw i64 %46, 1
%59 = icmp eq i64 %58, 2000
br i1 %59, label %60, label %45
60: ; preds = %56
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}