#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 */
unsigned int dijkstra(unsigned int, unsigned int *);
int /*<<< orphan*/ free(unsigned int *);
scalar_t__ malloc(int);
unsigned int rand();
int /*<<< orphan*/ srand(unsigned int);
int main() {
  unsigned int size = 0x6000;
  unsigned int *graph =
      (unsigned int *)malloc(sizeof(unsigned int) * size * size);
  int i, j;
  srand(size);
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++) {
      if (i == j)
        graph[i * size + j] = 0;
      else if (j == size - 1)
        graph[i * size + j] = 0xFFFFFFFF;
      else
        graph[i * size + j] = (rand() % 0xFFFFFF00) + 1;
    }
  }
  graph[(rand() % size - 1) * size + size - 1] = 0xFFFFFF01;
  unsigned int answer = dijkstra(size, graph);
  free(graph);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6000,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%rax
mov    -0x8(%rbp),%ecx
imul   %rcx,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1253 <main+0x103>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1240 <main+0xf0>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11d5 <main+0x85>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x18(%rbp),%ecx
mov    %ecx,%ecx
movl   $0x0,(%rax,%rcx,4)
jmp    122d <main+0xdd>
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1202 <main+0xb2>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x18(%rbp),%ecx
mov    %ecx,%ecx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    1228 <main+0xd8>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xffffff00,%ecx
xor    %edx,%edx
div    %ecx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x18(%rbp),%ecx
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
jmp    122d <main+0xdd>
jmp    1232 <main+0xe2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a1 <main+0x51>
jmp    1245 <main+0xf5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
xor    %edx,%edx
divl   -0x8(%rbp)
mov    -0x28(%rbp),%rax
mov    %edx,%ecx
sub    $0x1,%ecx
imul   -0x8(%rbp),%ecx
add    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movl   $0xffffff01,(%rax,%rcx,4)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <dijkstra@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x90000000,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x6000,%edi
call   1040 <srand@plt>
mov    %r14,%r15
xor    %ebx,%ebx
jmp    11a0 <main+0x50>
nopl   0x0(%rax)
movl   $0xffffffff,0x17ffc(%r14,%r12,4)
add    $0x1,%rbx
add    $0x18000,%r15
cmp    $0x6000,%rbx
je     11fe <main+0xae>
mov    %rbx,%rax
shl    $0xd,%rax
lea    (%rax,%rax,2),%r12
imul   $0x6001,%rbx,%r13
xor    %ebp,%ebp
jmp    11d5 <main+0x85>
cs nopw 0x0(%rax,%rax,1)
movl   $0x0,(%r14,%r13,4)
add    $0x1,%rbp
cmp    $0x6000,%rbp
je     118c <main+0x3c>
cmp    %rbp,%rbx
je     11c0 <main+0x70>
cmp    $0x5fff,%rbp
je     1180 <main+0x30>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ecx
sub    $0xffffff00,%ecx
cmovb  %eax,%ecx
add    $0x1,%ecx
mov    %ecx,(%r15,%rbp,4)
jmp    11c8 <main+0x78>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ecx
mov    $0xaaaaaaab,%edx
imul   %rcx,%rdx
shr    $0x2e,%rdx
shl    $0xd,%edx
lea    (%rdx,%rdx,2),%ecx
sub    %ecx,%eax
lea    (%rax,%rax,2),%eax
shl    $0xd,%eax
add    $0xffffffff,%eax
movl   $0xffffff01,(%r14,%rax,4)
ff
mov    $0x6000,%edi
mov    %r14,%rsi
call   1060 <dijkstra@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 24576, i32* %2
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = mul i64 4, %8
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = mul i64 %9, %11
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %3
%16 = load i32, i32* %2
%17 = call i32 @srand(i32 %16)
store i32 0, i32* %4
br label %18
18: ; preds = %72, %0
%19 = load i32, i32* %4
%20 = load i32, i32* %2
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %75
22: ; preds = %18
store i32 0, i32* %5
br label %23
23: ; preds = %68, %22
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %71
27: ; preds = %23
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = load i32*, i32** %3
%33 = load i32, i32* %4
%34 = load i32, i32* %2
%35 = mul i32 %33, %34
%36 = load i32, i32* %5
%37 = add i32 %35, %36
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %32, i64 %38
store i32 0, i32* %39
br label %67
40: ; preds = %27
%41 = load i32, i32* %5
%42 = load i32, i32* %2
%43 = sub i32 %42, 1
%44 = icmp eq i32 %41, %43
br i1 %44, label %45, label %54
45: ; preds = %40
%46 = load i32*, i32** %3
%47 = load i32, i32* %4
%48 = load i32, i32* %2
%49 = mul i32 %47, %48
%50 = load i32, i32* %5
%51 = add i32 %49, %50
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %46, i64 %52
store i32 -1, i32* %53
br label %66
54: ; preds = %40
%55 = call i32 (...) @rand()
%56 = urem i32 %55, -256
%57 = add i32 %56, 1
%58 = load i32*, i32** %3
%59 = load i32, i32* %4
%60 = load i32, i32* %2
%61 = mul i32 %59, %60
%62 = load i32, i32* %5
%63 = add i32 %61, %62
%64 = zext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %58, i64 %64
store i32 %57, i32* %65
br label %66
66: ; preds = %54, %45
br label %67
67: ; preds = %66, %31
br label %68
68: ; preds = %67
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
store i32 %70, i32* %5
br label %23
71: ; preds = %23
br label %72
72: ; preds = %71
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 1
store i32 %74, i32* %4
br label %18
75: ; preds = %18
%76 = load i32*, i32** %3
%77 = call i32 (...) @rand()
%78 = load i32, i32* %2
%79 = urem i32 %77, %78
%80 = sub i32 %79, 1
%81 = load i32, i32* %2
%82 = mul i32 %80, %81
%83 = load i32, i32* %2
%84 = add i32 %82, %83
%85 = sub i32 %84, 1
%86 = zext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %76, i64 %86
store i32 -255, i32* %87
%88 = load i32, i32* %2
%89 = load i32*, i32** %3
%90 = call i32 @dijkstra(i32 %88, i32* %89)
store i32 %90, i32* %6
%91 = load i32*, i32** %3
%92 = call i32 @free(i32* %91)
%93 = load i32, i32* %1
ret i32 %93
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 -1879048192)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i32 @srand(i32 24576)
br label %4
4: ; preds = %0, %29
%5 = phi i64 [ 0, %0 ], [ %30, %29 ]
%6 = mul nuw nsw i64 %5, 24576
%7 = add nuw nsw i64 %6, 24575
%8 = getelementptr inbounds i32, i32* %2, i64 %7
%9 = mul nuw nsw i64 %5, 24577
%10 = getelementptr inbounds i32, i32* %2, i64 %9
br label %11
11: ; preds = %4, %26
%12 = phi i64 [ 0, %4 ], [ %27, %26 ]
%13 = icmp eq i64 %5, %12
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 0, i32* %10
br label %26
15: ; preds = %11
%16 = icmp eq i64 %12, 24575
br i1 %16, label %17, label %18
17: ; preds = %15
store i32 -1, i32* %8
br label %29
18: ; preds = %15
%19 = tail call i32 (...) @rand()
%20 = icmp ult i32 %19, -256
%21 = add i32 %19, 256
%22 = select i1 %20, i32 %19, i32 %21
%23 = add nuw i32 %22, 1
%24 = add nuw nsw i64 %12, %6
%25 = getelementptr inbounds i32, i32* %2, i64 %24
store i32 %23, i32* %25
br label %26
26: ; preds = %14, %18
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, 24576
br i1 %28, label %29, label %11
29: ; preds = %26, %17
%30 = add nuw nsw i64 %5, 1
%31 = icmp eq i64 %30, 24576
br i1 %31, label %32, label %4
32: ; preds = %29
%33 = tail call i32 (...) @rand()
%34 = urem i32 %33, 24576
%35 = mul nuw nsw i32 %34, 24576
%36 = add nsw i32 %35, -1
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %2, i64 %37
store i32 -255, i32* %38
%39 = tail call i32 @dijkstra(i32 24576, i32* %2)
%40 = tail call i32 @free(i32* %2)
ret i32 0
}