#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 adjacency(char file[], int matrix[][9]) {
  FILE *fp;
  int i, j;
  for (i = 0; i < 9; i++) {
    for (j = 0; j < 9; j++)
      matrix[i][j] = 0;
  }
  fp = fopen(file, "r");
  if (fp == NULL)
    return -1;
  while (fscanf(fp, "%d %d", &i, &j) != EOF) {
    matrix[i][j] = 1;
    matrix[j][i] = 1;
  }
  fclose(fp);
}


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   $0x0,(%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    1237 <adjacency+0x107>
jmp    11cd <adjacency+0x9d>
mov    -0x20(%rbp),%rdi
lea    0xe2a(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1040 <fscanf@plt>
mov    0x2dfc(%rip),%rcx
cmp    (%rcx),%rax
je     122e <adjacency+0xfe>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
imul   $0x24,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    11cd <adjacency+0x9d>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
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
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x144,%edx
mov    %rsi,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x9,0x4(%rsp)
movl   $0x9,(%rsp)
lea    0xe8a(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     1206 <adjacency+0xc6>
mov    %rax,%r14
lea    0xe71(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    0x2e40(%rip),%rbp
cmp    0x0(%rbp),%rax
je     11fe <adjacency+0xbe>
lea    0xe4d(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%r13
nopl   (%rax)
movslq 0x4(%rsp),%rax
movslq (%rsp),%rcx
lea    (%rax,%rax,8),%rdx
lea    (%rbx,%rdx,4),%rdx
movl   $0x1,(%rdx,%rcx,4)
lea    (%rcx,%rcx,8),%rcx
lea    (%rbx,%rcx,4),%rcx
movl   $0x1,(%rcx,%rax,4)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1050 <fscanf@plt>
cmp    0x0(%rbp),%rax
jne    11c0 <adjacency+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    $0xffffffff,%eax
add    $0x8,%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 = [6 x i8] c"%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
store i8* %0, i8** %4
store [9 x i32]* %1, [9 x i32]** %5
store i32 0, i32* %7
br label %9
9: ; preds = %28, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 9
br i1 %11, label %12, label %31
12: ; preds = %9
store i32 0, i32* %8
br label %13
13: ; preds = %24, %12
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 9
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load [9 x i32]*, [9 x i32]** %5
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %17, i64 %19
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [9 x i32], [9 x i32]* %20, i64 0, i64 %22
store i32 0, i32* %23
br label %24
24: ; preds = %16
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %13
27: ; preds = %13
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %9
31: ; preds = %9
%32 = load i8*, i8** %4
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %33, i32** %6
%34 = load i32*, i32** %6
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %37
36: ; preds = %31
store i32 -1, i32* %3
br label %61
37: ; preds = %31
br label %38
38: ; preds = %43, %37
%39 = load i32*, i32** %6
%40 = call i64 @fscanf(i32* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8)
%41 = load i64, i64* @EOF
%42 = icmp ne i64 %40, %41
br i1 %42, label %43, label %58
43: ; preds = %38
%44 = load [9 x i32]*, [9 x i32]** %5
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [9 x i32], [9 x i32]* %44, i64 %46
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [9 x i32], [9 x i32]* %47, i64 0, i64 %49
store i32 1, i32* %50
%51 = load [9 x i32]*, [9 x i32]** %5
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [9 x i32], [9 x i32]* %51, i64 %53
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [9 x i32], [9 x i32]* %54, i64 0, i64 %56
store i32 1, i32* %57
br label %38
58: ; preds = %38
%59 = load i32*, i32** %6
%60 = call i32 @fclose(i32* %59)
br label %61
61: ; preds = %58, %36
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"%d %d\00"
@EOF = global i64 0
define i32 @adjacency(i8* nocapture %0, [9 x i32]* nocapture writeonly %1) {
%3 = bitcast [9 x i32]* %1 to i8*
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
store i32 9, i32* %4
store i32 9, i32* %5
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %26, label %10
10: ; preds = %2
%11 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %24, label %14
14: ; preds = %10, %14
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 %16, i64 %18
store i32 1, i32* %19
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 %18, i64 %16
store i32 1, i32* %20
%21 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %14
24: ; preds = %14, %10
%25 = call i32 @fclose(i32* %8)
br label %26
26: ; preds = %2, %24
ret i32 -1
}