#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *);
int adjacency(char file[], int matrix[][9]) {
  FILE *fp;
  int start, end, weight;
  for (start = 0; start < 9; start++) {
    for (end = 0; end < 9; end++)
      matrix[start][end] = 999;
  }
  fp = fopen(file, "r");
  if (fp == NULL)
    return -1;
  while (fscanf(fp, "%d %d %d", &start, &end, &weight) != EOF) {
    matrix[start][end] = weight;
    matrix[end][start] = weight;
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<adjacency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x9,-0x24(%rbp)
jge    119d <adjacency+0x6d>
movl   $0x0,-0x28(%rbp)
cmpl   $0x9,-0x28(%rbp)
jge    118a <adjacency+0x5a>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x3e7,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1158 <adjacency+0x28>
jmp    118f <adjacency+0x5f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <adjacency+0x17>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c8 <adjacency+0x98>
movl   $0xffffffff,-0x4(%rbp)
jmp    1240 <adjacency+0x110>
jmp    11cd <adjacency+0x9d>
mov    -0x20(%rbp),%rdi
lea    0xe2a(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1040 <fscanf@plt>
mov    0x2df8(%rip),%rcx
cmp    (%rcx),%rax
je     1230 <adjacency+0x100>
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11cd <adjacency+0x9d>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjacency>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movaps 0xeb8(%rip),%xmm0
movups %xmm0,(%rsi)
movups %xmm0,0x10(%rsi)
movl   $0x3e7,0x20(%rsi)
movups %xmm0,0x24(%rsi)
movups %xmm0,0x34(%rsi)
movl   $0x3e7,0x44(%rsi)
movups %xmm0,0x48(%rsi)
movups %xmm0,0x58(%rsi)
movl   $0x3e7,0x68(%rsi)
movups %xmm0,0x6c(%rsi)
movups %xmm0,0x7c(%rsi)
movl   $0x3e7,0x8c(%rsi)
movups %xmm0,0x90(%rsi)
movups %xmm0,0xa0(%rsi)
movl   $0x3e7,0xb0(%rsi)
movups %xmm0,0xb4(%rsi)
movups %xmm0,0xc4(%rsi)
movl   $0x3e7,0xd4(%rsi)
movups %xmm0,0xd8(%rsi)
movups %xmm0,0xe8(%rsi)
movl   $0x3e7,0xf8(%rsi)
movups %xmm0,0xfc(%rsi)
movups %xmm0,0x10c(%rsi)
movl   $0x3e7,0x11c(%rsi)
movups %xmm0,0x120(%rsi)
movups %xmm0,0x130(%rsi)
movl   $0x3e7,0x140(%rsi)
movl   $0x9,0x10(%rsp)
movl   $0x9,0xc(%rsp)
lea    0xdfb(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     12ad <adjacency+0x17d>
mov    %rax,%r14
lea    0xde5(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    0x2d9d(%rip),%r15
cmp    (%r15),%rax
je     12a1 <adjacency+0x171>
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x14(%rsp),%rbp
nop
mov    0x14(%rsp),%eax
movslq 0x10(%rsp),%rcx
movslq 0xc(%rsp),%rdx
lea    (%rcx,%rcx,8),%rsi
lea    (%rbx,%rsi,4),%rsi
mov    %eax,(%rsi,%rdx,4)
lea    (%rdx,%rdx,8),%rdx
lea    (%rbx,%rdx,4),%rdx
mov    %eax,(%rdx,%rcx,4)
mov    %r14,%rdi
lea    0xd84(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1040 <fscanf@plt>
cmp    (%r15),%rax
jne    1260 <adjacency+0x130>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12b2 <adjacency+0x182>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@EOF = global i64 0
define i32 @adjacency(i8* %0, [9 x i32]* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [9 x i32]*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store [9 x i32]* %1, [9 x i32]** %5
store i32 0, i32* %7
br label %10
10: ; preds = %29, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 9
br i1 %12, label %13, label %32
13: ; preds = %10
store i32 0, i32* %8
br label %14
14: ; preds = %25, %13
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 9
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load [9 x i32]*, [9 x i32]** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [9 x i32], [9 x i32]* %18, i64 %20
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [9 x i32], [9 x i32]* %21, i64 0, i64 %23
store i32 999, i32* %24
br label %25
25: ; preds = %17
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %14
28: ; preds = %14
br label %29
29: ; preds = %28
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %10
32: ; preds = %10
%33 = load i8*, i8** %4
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %34, i32** %6
%35 = load i32*, i32** %6
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %38
37: ; preds = %32
store i32 -1, i32* %3
br label %64
38: ; preds = %32
br label %39
39: ; preds = %44, %38
%40 = load i32*, i32** %6
%41 = call i64 @fscanf(i32* %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%42 = load i64, i64* @EOF
%43 = icmp ne i64 %41, %42
br i1 %43, label %44, label %61
44: ; preds = %39
%45 = load i32, i32* %9
%46 = load [9 x i32]*, [9 x i32]** %5
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [9 x i32], [9 x i32]* %46, i64 %48
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [9 x i32], [9 x i32]* %49, i64 0, i64 %51
store i32 %45, i32* %52
%53 = load i32, i32* %9
%54 = load [9 x i32]*, [9 x i32]** %5
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [9 x i32], [9 x i32]* %54, i64 %56
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [9 x i32], [9 x i32]* %57, i64 0, i64 %59
store i32 %53, i32* %60
br label %39
61: ; preds = %39
%62 = load i32*, i32** %6
%63 = call i32 @fclose(i32* %62)
store i32 0, i32* %3
br label %64
64: ; preds = %61, %37
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@EOF = global i64 0
define i32 @adjacency(i8* nocapture %0, [9 x i32]* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast [9 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %9
%10 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 4
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %11
%12 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 8
store i32 999, i32* %12
%13 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 1, i64 0
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %14
%15 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 1, i64 4
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %16
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 1, i64 8
store i32 999, i32* %17
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 2, i64 0
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %19
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 2, i64 4
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %21
%22 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 2, i64 8
store i32 999, i32* %22
%23 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 3, i64 0
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %24
%25 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 3, i64 4
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %26
%27 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 3, i64 8
store i32 999, i32* %27
%28 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 4, i64 0
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %29
%30 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 4, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %31
%32 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 4, i64 8
store i32 999, i32* %32
%33 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 5, i64 0
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %34
%35 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 5, i64 4
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %36
%37 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 5, i64 8
store i32 999, i32* %37
%38 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 6, i64 0
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %39
%40 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 6, i64 4
%41 = bitcast i32* %40 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %41
%42 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 6, i64 8
store i32 999, i32* %42
%43 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 7, i64 0
%44 = bitcast i32* %43 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %44
%45 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 7, i64 4
%46 = bitcast i32* %45 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %46
%47 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 7, i64 8
store i32 999, i32* %47
%48 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 8, i64 0
%49 = bitcast i32* %48 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %49
%50 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 8, i64 4
%51 = bitcast i32* %50 to <4 x i32>*
store <4 x i32> <i32 999, i32 999, i32 999, i32 999>, <4 x i32>* %51
%52 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 8, i64 8
store i32 999, i32* %52
store i32 9, i32* %3
store i32 9, i32* %4
%53 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%54 = icmp eq i32* %53, null
br i1 %54, label %72, label %55
55: ; preds = %2
%56 = call i64 @fscanf(i32* %53, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%57 = load i64, i64* @EOF
%58 = icmp eq i64 %56, %57
br i1 %58, label %70, label %59
59: ; preds = %55, %59
%60 = load i32, i32* %5
%61 = load i32, i32* %3
%62 = sext i32 %61 to i64
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 %62, i64 %64
store i32 %60, i32* %65
%66 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 %64, i64 %62
store i32 %60, i32* %66
%67 = call i64 @fscanf(i32* %53, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%68 = load i64, i64* @EOF
%69 = icmp eq i64 %67, %68
br i1 %69, label %70, label %59
70: ; preds = %59, %55
%71 = call i32 @fclose(i32* %53)
br label %72
72: ; preds = %2, %70
%73 = phi i32 [ 0, %70 ], [ -1, %2 ]
ret i32 %73
}