#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int atoi(char *);
int ceil(double);
scalar_t__ clock();
int *dijkstra(int, int **, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int **floyd(int **, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(int **);
int get_nodes(char *);
int /*<<< orphan*/ get_progress(char *, int, int, int);
int /*<<< orphan*/ graph_to_text(int **, int, char *);
int **init_graph(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int **text_to_graph(char *);
scalar_t__ time(int /*<<< orphan*/ *);
char *usage();
int main(int argc, char *argv[]) {
  if (argc < 3) {
    fprintf(stderr, "%s", usage());
    exit(1);
  }
  srand((unsigned int)time(NULL));
  int nodes = 0;
  char *file = NULL;
  bool file_flag = false;
  if (strcmp(argv[1], "-n") == 0) {
    nodes = atoi(argv[2]);
    file = "generated.txt";
  } else if (strcmp(argv[1], "-f") == 0) {
    file_flag = true;
    file = argv[2];
    nodes = get_nodes(file);
  } else {
    fprintf(stderr, "%s", usage());
    exit(1);
  }
  int **gen = file_flag ? text_to_graph(file) : init_graph(nodes, true);
  int **result = init_graph(nodes, false);
  if (!file_flag) {
    printf("\n-----------------------------------------------------------------"
           "---\n"
           "Generated graph:\n"
           " Output: %s\n\n",
           file);
    graph_to_text(gen, nodes, file);
  }
  int steps = 20;
  char *progress = (char *)malloc(sizeof(char) * (steps + ((int)steps / 3)));
  double time_spent;
  double time_step[4];
  clock_t begin, end, begin_step, end_step;
  printf("Dijkstra:\n");
  begin = clock();
  for (int i = 0; i < nodes; i++) {
    begin_step = clock();
    result[i] = dijkstra(i, gen, nodes);
    end_step = clock();
    get_progress(progress, i, nodes, steps);
    time_step[0] = (double)(end_step - begin_step) / CLOCKS_PER_SEC;
    time_step[0] *= (nodes - i);
    time_step[0] =
        ceil(time_step[3] + time_step[2] + time_step[1] + time_step[0]) / 4;
    time_step[3] = ceil(time_step[2]);
    time_step[2] = ceil(time_step[1]);
    time_step[1] = ceil(time_step[0]);
    printf(" vertex %i in:\t%.6f sec\t\tETA: %.0f sec %s %.1f%%\r", i + 1,
           ((double)(clock()) / CLOCKS_PER_SEC),
           (i == nodes - 1) ? 0 : time_step[0], progress,
           (i == nodes - 1) ? 100 : 100 * ((float)i / nodes));
    fflush(stdout);
  }
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  file = "dijkstra.txt";
  printf(" Execution time: %.6f sec\n"
         " Output: %s",
         time_spent, file);
  graph_to_text(result, nodes, file);
  printf("\n\nFloyd-Warshall:\n");
  begin = clock();
  result = floyd(gen, nodes, steps);
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  file = "floyd.txt";
  printf(" Execution time: %.6f sec\n"
         " Output: %s\n",
         time_spent, file);
  graph_to_text(result, nodes, file);
  free(gen);
  free(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1298 <main+0x58>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    $0x0,%al
call   1120 <usage@plt>
mov    -0x98(%rbp),%edi
mov    %rax,%rdx
lea    0xe61(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <time@plt>
mov    %eax,%edi
call   10a0 <srand@plt>
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd37(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    12fc <main+0xbc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xd14(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1378 <main+0x138>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd0a(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    133e <main+0xfe>
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10d0 <get_nodes@plt>
mov    %eax,-0x14(%rbp)
jmp    1373 <main+0x133>
mov    0x2c93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
mov    $0x0,%al
call   1120 <usage@plt>
mov    -0x9c(%rbp),%edi
mov    %rax,%rdx
lea    0xd86(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
jmp    1378 <main+0x138>
cmpl   $0x0,-0x24(%rbp)
je     1397 <main+0x157>
mov    -0x20(%rbp),%rdi
call   1050 <text_to_graph@plt>
mov    %rax,-0xa8(%rbp)
jmp    13ab <main+0x16b>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1160 <init_graph@plt>
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1160 <init_graph@plt>
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    13f0 <main+0x1b0>
mov    -0x20(%rbp),%rsi
lea    0xc3f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1080 <graph_to_text@plt>
movl   $0x14,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
add    %ecx,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1100 <malloc@plt>
mov    %rax,-0x48(%rbp)
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    166b <main+0x42b>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x88(%rbp)
mov    -0x94(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1130 <dijkstra@plt>
mov    %rax,%rdx
mov    -0x38(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x90(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x94(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x3c(%rbp),%ecx
call   1040 <get_progress@plt>
mov    -0x90(%rbp),%rax
sub    -0x88(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2b21(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x94(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
call   1060 <ceil@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1060 <ceil@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1060 <ceil@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1060 <ceil@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
mov    $0x0,%al
call   1070 <clock@plt>
cvtsi2sd %rax,%xmm0
mov    0x2a7c(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x94(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    159c <main+0x35c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
jmp    15a9 <main+0x369>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0xd8(%rbp)
ff
mov    -0x48(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x94(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    15ed <main+0x3ad>
movss  0xa20(%rip),%xmm0
movss  %xmm0,-0xdc(%rbp)
ff
jmp    1612 <main+0x3d2>
cvtsi2ssl -0x94(%rbp),%xmm1
ff
cvtsi2ssl -0x14(%rbp),%xmm0
divss  %xmm0,%xmm1
movss  0x9fa(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0xdc(%rbp)
ff
mov    -0xd0(%rbp),%rdx
movsd  -0xd8(%rbp),%xmm1
ff
movsd  -0xb8(%rbp),%xmm0
ff
mov    -0xbc(%rbp),%esi
movss  -0xdc(%rbp),%xmm2
ff
cvtss2sd %xmm2,%xmm2
lea    0xa46(%rip),%rdi
mov    $0x3,%al
call   1090 <printf@plt>
mov    0x2980(%rip),%rax
mov    (%rax),%edi
call   1110 <fflush@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1449 <main+0x209>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
sub    -0x78(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x295e(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    0xa20(%rip),%rax
mov    %rax,-0x20(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x20(%rbp),%rsi
lea    0xa19(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1080 <graph_to_text@plt>
lea    0xa21(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x78(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x3c(%rbp),%edx
call   10f0 <floyd@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1070 <clock@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
sub    -0x78(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x28d8(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    0x9e0(%rip),%rax
mov    %rax,-0x20(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x20(%rbp),%rsi
lea    0x9d6(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1080 <graph_to_text@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cmp    $0x2,%edi
jle    15e6 <main+0x396>
mov    %rsi,%rbx
xor    %edi,%edi
call   10f0 <time@plt>
mov    %eax,%edi
call   10b0 <srand@plt>
mov    0x8(%rbx),%rdi
lea    0xd81(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     12d3 <main+0x83>
mov    0x8(%rbx),%rdi
lea    0xd7d(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    15e6 <main+0x396>
mov    0x10(%rbx),%rbx
mov    %rbx,%rdi
call   10e0 <get_nodes@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1060 <text_to_graph@plt>
mov    %rax,0x10(%rsp)
mov    %r15d,%edi
xor    %esi,%esi
call   1170 <init_graph@plt>
mov    %rax,0x8(%rsp)
jmp    1328 <main+0xd8>
mov    0x10(%rbx),%rdi
call   1150 <atoi@plt>
mov    %eax,%r15d
mov    %eax,%edi
mov    $0x1,%esi
call   1170 <init_graph@plt>
mov    %rax,%rbp
mov    %r15d,%edi
xor    %esi,%esi
call   1170 <init_graph@plt>
mov    %rax,0x8(%rsp)
lea    0xd14(%rip),%rdi
lea    0xcfc(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %rbp,0x10(%rsp)
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1090 <graph_to_text@plt>
mov    $0x1a,%edi
call   1110 <malloc@plt>
mov    %rax,%rbx
lea    0xdd7(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1080 <clock@plt>
mov    %rax,0x30(%rsp)
test   %r15d,%r15d
jle    1512 <main+0x2c2>
mov    %r15d,%ebp
lea    -0x1(%r15),%eax
mov    %rax,0x38(%rsp)
cvtsi2ss %r15d,%xmm0
movss  %xmm0,0x1c(%rsp)
mov    %r15d,%r14d
xor    %r13d,%r13d
mov    %r15,0x50(%rsp)
mov    %rbx,0x48(%rsp)
mov    %rbp,0x40(%rsp)
jmp    1401 <main+0x1b1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cvtsi2sd %ebx,%xmm3
movsd  %xmm3,(%rsp)
xorps  %xmm3,%xmm3
cvtsi2sd %r15d,%xmm3
movsd  %xmm3,0x20(%rsp)
xorps  %xmm3,%xmm3
cvtsi2sd %r12d,%xmm3
movsd  %xmm3,0x28(%rsp)
cvtss2sd %xmm2,%xmm2
add    $0x1,%r13d
lea    0xcb9(%rip),%rdi
mov    %r13d,%esi
mov    0x48(%rsp),%rbx
mov    %rbx,%rdx
mov    $0x3,%al
call   10a0 <printf@plt>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
add    $0xffffffff,%r14d
mov    %rbp,%r13
mov    0x40(%rsp),%rax
cmp    %rbp,%rax
mov    %rax,%rbp
mov    0x50(%rsp),%r15
je     1512 <main+0x2c2>
xor    %eax,%eax
call   1080 <clock@plt>
mov    %rax,%r12
mov    %r13d,%edi
mov    0x10(%rsp),%rsi
mov    %ebp,%edx
call   1140 <dijkstra@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx,%r13,8)
xor    %eax,%eax
call   1080 <clock@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    $0x14,%ecx
call   1040 <get_progress@plt>
sub    %r12,%rbp
xorps  %xmm0,%xmm0
cvtsi2sd %rbp,%xmm0
mov    0x2b96(%rip),%rax
divsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
mulsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
addsd  %xmm1,%xmm0
call   1070 <ceil@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1070 <ceil@plt>
mov    %eax,%ebx
movsd  0x28(%rsp),%xmm0
call   1070 <ceil@plt>
mov    %eax,%r15d
movsd  (%rsp),%xmm0
call   1070 <ceil@plt>
mov    %eax,%r12d
lea    0x1(%r13),%rbp
xor    %eax,%eax
call   1080 <clock@plt>
xorpd  %xmm1,%xmm1
cmp    %r13,0x38(%rsp)
je     14d6 <main+0x286>
movsd  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2b03(%rip),%rax
divsd  (%rax),%xmm0
movss  0xb0f(%rip),%xmm2
je     1390 <main+0x140>
xorps  %xmm2,%xmm2
cvtsi2ss %r13d,%xmm2
divss  0x1c(%rsp),%xmm2
mulss  0xaf3(%rip),%xmm2
jmp    1390 <main+0x140>
xor    %eax,%eax
call   1080 <clock@plt>
sub    0x30(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2abb(%rip),%r14
divsd  (%r14),%xmm0
lea    0xb83(%rip),%rdi
lea    0xb6f(%rip),%rbx
mov    %rbx,%rsi
mov    $0x1,%al
call   10a0 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1090 <graph_to_text@plt>
lea    0xbbc(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1080 <clock@plt>
mov    %rax,%r12
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15d,%esi
mov    $0x14,%edx
call   1100 <floyd@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <clock@plt>
sub    %r12,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
lea    0xb46(%rip),%rdi
lea    0xb35(%rip),%r14
mov    %r14,%rsi
mov    $0x1,%al
call   10a0 <printf@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1090 <graph_to_text@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x29eb(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1130 <usage@plt>
lea    0xae2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [14 x i8] c"generated.txt\00"
@.str.3 = [3 x i8] c"-f\00"
@.str.4 = [101 x i8] c"\0A--------------------------------------------------------------------\0AGenerated graph:\0A Output: %s\0A\0A\00"
@.str.5 = [11 x i8] c"Dijkstra:\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.6 = [50 x i8] c" vertex %i in:\09%.6f sec\09\09ETA: %.0f sec %s %.1f%%\0D\00"
@stdout = global i32 0
@.str.7 = [13 x i8] c"dijkstra.txt\00"
@.str.8 = [38 x i8] c" Execution time: %.6f sec\0A Output: %s\00"
@.str.9 = [19 x i8] c"\0A\0AFloyd-Warshall:\0A\00"
@.str.10 = [10 x i8] c"floyd.txt\00"
@.str.11 = [39 x i8] c" Execution time: %.6f sec\0A Output: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32**
%10 = alloca i32**
%11 = alloca i32
%12 = alloca i8*
%13 = alloca double
%14 = alloca [4 x double]
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %27
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i8* (...) @usage()
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = call i64 @time(i32* null)
%29 = trunc i64 %28 to i32
%30 = call i32 @srand(i32 %29)
store i32 0, i32* %6
store i8* null, i8** %7
store i32 0, i32* %8
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %27
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
store i32 %40, i32* %6
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %59
41: ; preds = %27
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %41
store i32 1, i32* %8
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
store i8* %50, i8** %7
%51 = load i8*, i8** %7
%52 = call i32 @get_nodes(i8* %51)
store i32 %52, i32* %6
br label %58
53: ; preds = %41
%54 = load i32, i32* @stderr
%55 = call i8* (...) @usage()
%56 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %47
br label %59
59: ; preds = %58, %36
%60 = load i32, i32* %8
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i8*, i8** %7
%64 = call i32** @text_to_graph(i8* %63)
br label %68
65: ; preds = %59
%66 = load i32, i32* %6
%67 = call i32** @init_graph(i32 %66, i32 1)
br label %68
68: ; preds = %65, %62
%69 = phi i32** [ %64, %62 ], [ %67, %65 ]
store i32** %69, i32*** %9
%70 = load i32, i32* %6
%71 = call i32** @init_graph(i32 %70, i32 0)
store i32** %71, i32*** %10
%72 = load i32, i32* %8
%73 = icmp ne i32 %72, 0
br i1 %73, label %81, label %74
74: ; preds = %68
%75 = load i8*, i8** %7
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.4, i64 0, i64 0), i8* %75)
%77 = load i32**, i32*** %9
%78 = load i32, i32* %6
%79 = load i8*, i8** %7
%80 = call i32 @graph_to_text(i32** %77, i32 %78, i8* %79)
br label %81
81: ; preds = %74, %68
store i32 20, i32* %11
%82 = load i32, i32* %11
%83 = load i32, i32* %11
%84 = sdiv i32 %83, 3
%85 = add nsw i32 %82, %84
%86 = sext i32 %85 to i64
%87 = mul i64 1, %86
%88 = trunc i64 %87 to i32
%89 = call i64 @malloc(i32 %88)
%90 = inttoptr i64 %89 to i8*
store i8* %90, i8** %12
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%92 = call i64 (...) @clock()
store i64 %92, i64* %15
store i32 0, i32* %19
br label %93
93: ; preds = %192, %81
%94 = load i32, i32* %19
%95 = load i32, i32* %6
%96 = icmp slt i32 %94, %95
br i1 %96, label %97, label %195
97: ; preds = %93
%98 = call i64 (...) @clock()
store i64 %98, i64* %17
%99 = load i32, i32* %19
%100 = load i32**, i32*** %9
%101 = load i32, i32* %6
%102 = call i32* @dijkstra(i32 %99, i32** %100, i32 %101)
%103 = load i32**, i32*** %10
%104 = load i32, i32* %19
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i32*, i32** %103, i64 %105
store i32* %102, i32** %106
%107 = call i64 (...) @clock()
store i64 %107, i64* %18
%108 = load i8*, i8** %12
%109 = load i32, i32* %19
%110 = load i32, i32* %6
%111 = load i32, i32* %11
%112 = call i32 @get_progress(i8* %108, i32 %109, i32 %110, i32 %111)
%113 = load i64, i64* %18
%114 = load i64, i64* %17
%115 = sub nsw i64 %113, %114
%116 = sitofp i64 %115 to double
%117 = load double, double* @CLOCKS_PER_SEC
%118 = fdiv double %116, %117
%119 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 0
store double %118, double* %119
%120 = load i32, i32* %6
%121 = load i32, i32* %19
%122 = sub nsw i32 %120, %121
%123 = sitofp i32 %122 to double
%124 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 0
%125 = load double, double* %124
%126 = fmul double %125, %123
store double %126, double* %124
%127 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 3
%128 = load double, double* %127
%129 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 2
%130 = load double, double* %129
%131 = fadd double %128, %130
%132 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 1
%133 = load double, double* %132
%134 = fadd double %131, %133
%135 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 0
%136 = load double, double* %135
%137 = fadd double %134, %136
%138 = call i32 @ceil(double %137)
%139 = sdiv i32 %138, 4
%140 = sitofp i32 %139 to double
%141 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 0
store double %140, double* %141
%142 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 2
%143 = load double, double* %142
%144 = call i32 @ceil(double %143)
%145 = sitofp i32 %144 to double
%146 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 3
store double %145, double* %146
%147 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 1
%148 = load double, double* %147
%149 = call i32 @ceil(double %148)
%150 = sitofp i32 %149 to double
%151 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 2
store double %150, double* %151
%152 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 0
%153 = load double, double* %152
%154 = call i32 @ceil(double %153)
%155 = sitofp i32 %154 to double
%156 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 1
store double %155, double* %156
%157 = load i32, i32* %19
%158 = add nsw i32 %157, 1
%159 = call i64 (...) @clock()
%160 = sitofp i64 %159 to double
%161 = load double, double* @CLOCKS_PER_SEC
%162 = fdiv double %160, %161
%163 = load i32, i32* %19
%164 = load i32, i32* %6
%165 = sub nsw i32 %164, 1
%166 = icmp eq i32 %163, %165
br i1 %166, label %167, label %168
167: ; preds = %97
br label %171
168: ; preds = %97
%169 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 0
%170 = load double, double* %169
br label %171
171: ; preds = %168, %167
%172 = phi double [ 0.000000e+00, %167 ], [ %170, %168 ]
%173 = load i8*, i8** %12
%174 = load i32, i32* %19
%175 = load i32, i32* %6
%176 = sub nsw i32 %175, 1
%177 = icmp eq i32 %174, %176
br i1 %177, label %178, label %179
178: ; preds = %171
br label %186
179: ; preds = %171
%180 = load i32, i32* %19
%181 = sitofp i32 %180 to float
%182 = load i32, i32* %6
%183 = sitofp i32 %182 to float
%184 = fdiv float %181, %183
%185 = fmul float 1.000000e+02, %184
br label %186
186: ; preds = %179, %178
%187 = phi float [ 1.000000e+02, %178 ], [ %185, %179 ]
%188 = fpext float %187 to double
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %158, double %162, double %172, i8* %173, double %188)
%190 = load i32, i32* @stdout
%191 = call i32 @fflush(i32 %190)
br label %192
192: ; preds = %186
%193 = load i32, i32* %19
%194 = add nsw i32 %193, 1
store i32 %194, i32* %19
br label %93
195: ; preds = %93
%196 = call i64 (...) @clock()
store i64 %196, i64* %16
%197 = load i64, i64* %16
%198 = load i64, i64* %15
%199 = sub nsw i64 %197, %198
%200 = sitofp i64 %199 to double
%201 = load double, double* @CLOCKS_PER_SEC
%202 = fdiv double %200, %201
store double %202, double* %13
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %7
%203 = load double, double* %13
%204 = load i8*, i8** %7
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), double %203, i8* %204)
%206 = load i32**, i32*** %10
%207 = load i32, i32* %6
%208 = load i8*, i8** %7
%209 = call i32 @graph_to_text(i32** %206, i32 %207, i8* %208)
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%211 = call i64 (...) @clock()
store i64 %211, i64* %15
%212 = load i32**, i32*** %9
%213 = load i32, i32* %6
%214 = load i32, i32* %11
%215 = call i32** @floyd(i32** %212, i32 %213, i32 %214)
store i32** %215, i32*** %10
%216 = call i64 (...) @clock()
store i64 %216, i64* %16
%217 = load i64, i64* %16
%218 = load i64, i64* %15
%219 = sub nsw i64 %217, %218
%220 = sitofp i64 %219 to double
%221 = load double, double* @CLOCKS_PER_SEC
%222 = fdiv double %220, %221
store double %222, double* %13
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8** %7
%223 = load double, double* %13
%224 = load i8*, i8** %7
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), double %223, i8* %224)
%226 = load i32**, i32*** %10
%227 = load i32, i32* %6
%228 = load i8*, i8** %7
%229 = call i32 @graph_to_text(i32** %226, i32 %227, i8* %228)
%230 = load i32**, i32*** %9
%231 = call i32 @free(i32** %230)
%232 = load i32**, i32*** %10
%233 = call i32 @free(i32** %232)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [14 x i8] c"generated.txt\00"
@.str.3 = [3 x i8] c"-f\00"
@.str.4 = [101 x i8] c"\0A--------------------------------------------------------------------\0AGenerated graph:\0A Output: %s\0A\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.6 = [50 x i8] c" vertex %i in:\09%.6f sec\09\09ETA: %.0f sec %s %.1f%%\0D\00"
@stdout = global i32 0
@.str.7 = [13 x i8] c"dijkstra.txt\00"
@.str.8 = [38 x i8] c" Execution time: %.6f sec\0A Output: %s\00"
@.str.10 = [10 x i8] c"floyd.txt\00"
@.str.11 = [39 x i8] c" Execution time: %.6f sec\0A Output: %s\0A\00"
@str = [10 x i8] c"Dijkstra:\00"
@str.12 = [18 x i8] c"\0A\0AFloyd-Warshall:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i8* (...) @usage()
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i64 @time(i32* null)
%11 = trunc i64 %10 to i32
%12 = tail call i32 @srand(i32 %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %32, label %17
17: ; preds = %9
%18 = load i8*, i8** %13
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = tail call i8* (...) @usage()
%24 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32 @get_nodes(i8* %28)
%30 = tail call i32** @text_to_graph(i8* %28)
%31 = tail call i32** @init_graph(i32 %29, i32 0)
br label %40
32: ; preds = %9
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = tail call i32 @atoi(i8* %34)
%36 = tail call i32** @init_graph(i32 %35, i32 1)
%37 = tail call i32** @init_graph(i32 %35, i32 0)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([101 x i8], [101 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%39 = tail call i32 @graph_to_text(i32** %36, i32 %35, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %26, %32
%41 = phi i32** [ %37, %32 ], [ %31, %26 ]
%42 = phi i32** [ %36, %32 ], [ %30, %26 ]
%43 = phi i32 [ %35, %32 ], [ %29, %26 ]
%44 = tail call i64 @malloc(i32 26)
%45 = inttoptr i64 %44 to i8*
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%47 = tail call i64 (...) @clock()
%48 = icmp sgt i32 %43, 0
br i1 %48, label %49, label %54
49: ; preds = %40
%50 = add nsw i32 %43, -1
%51 = sitofp i32 %43 to float
%52 = zext i32 %50 to i64
%53 = zext i32 %43 to i64
br label %74
54: ; preds = %115, %40
%55 = tail call i64 (...) @clock()
%56 = sub nsw i64 %55, %47
%57 = sitofp i64 %56 to double
%58 = load double, double* @CLOCKS_PER_SEC
%59 = fdiv double %57, %58
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), double %59, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%61 = tail call i32 @graph_to_text(i32** %41, i32 %43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0))
%63 = tail call i64 (...) @clock()
%64 = tail call i32** @floyd(i32** %42, i32 %43, i32 20)
%65 = tail call i64 (...) @clock()
%66 = sub nsw i64 %65, %63
%67 = sitofp i64 %66 to double
%68 = load double, double* @CLOCKS_PER_SEC
%69 = fdiv double %67, %68
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), double %69, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%71 = tail call i32 @graph_to_text(i32** %64, i32 %43, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%72 = tail call i32 @free(i32** %42)
%73 = tail call i32 @free(i32** %64)
ret i32 0
74: ; preds = %49, %115
%75 = phi i64 [ 0, %49 ], [ %104, %115 ]
%76 = phi double [ undef, %49 ], [ %103, %115 ]
%77 = phi double [ undef, %49 ], [ %101, %115 ]
%78 = phi double [ undef, %49 ], [ %99, %115 ]
%79 = tail call i64 (...) @clock()
%80 = trunc i64 %75 to i32
%81 = tail call i32* @dijkstra(i32 %80, i32** %42, i32 %43)
%82 = getelementptr inbounds i32*, i32** %41, i64 %75
store i32* %81, i32** %82
%83 = tail call i64 (...) @clock()
%84 = tail call i32 @get_progress(i8* %45, i32 %80, i32 %43, i32 20)
%85 = sub nsw i64 %83, %79
%86 = sitofp i64 %85 to double
%87 = load double, double* @CLOCKS_PER_SEC
%88 = fdiv double %86, %87
%89 = sub nsw i32 %43, %80
%90 = sitofp i32 %89 to double
%91 = fmul double %88, %90
%92 = fadd double %78, %77
%93 = fadd double %92, %76
%94 = fadd double %93, %91
%95 = tail call i32 @ceil(double %94)
%96 = sdiv i32 %95, 4
%97 = sitofp i32 %96 to double
%98 = tail call i32 @ceil(double %77)
%99 = sitofp i32 %98 to double
%100 = tail call i32 @ceil(double %76)
%101 = sitofp i32 %100 to double
%102 = tail call i32 @ceil(double %97)
%103 = sitofp i32 %102 to double
%104 = add nuw nsw i64 %75, 1
%105 = tail call i64 (...) @clock()
%106 = sitofp i64 %105 to double
%107 = load double, double* @CLOCKS_PER_SEC
%108 = fdiv double %106, %107
%109 = icmp eq i64 %75, %52
%110 = select i1 %109, double 0.000000e+00, double %97
br i1 %109, label %115, label %111
111: ; preds = %74
%112 = sitofp i32 %80 to float
%113 = fdiv float %112, %51
%114 = fmul float %113, 1.000000e+02
br label %115
115: ; preds = %74, %111
%116 = phi float [ %114, %111 ], [ 1.000000e+02, %74 ]
%117 = fpext float %116 to double
%118 = trunc i64 %104 to i32
%119 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %118, double %108, double %110, i8* %45, double %117)
%120 = load i32, i32* @stdout
%121 = tail call i32 @fflush(i32 %120)
%122 = icmp eq i64 %104, %53
br i1 %122, label %54, label %74
}