#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, ...);
void check_graph(int vertex_count, int G[512][512], int graph_num) {
  int i, j;
  for (i = 0; i < vertex_count; i++) {
    for (j = 0; j < vertex_count; j++) {
      if (G[i][j] != G[j][i]) {
        printf("*** Error- adjacency matrix is not symmetric: A[%5d][%5d] != "
               "A[%5d][%5d]\n",
               i, j, j, i);
        printf("Graph   %5d: BAD GRAPH\n", graph_num);
        exit(EXIT_FAILURE);
      }
    }
    if (G[i][i] == 1) {
      printf("*** Error- graph is not simple, loop at node %5d\n", i);
      printf("Graph   %5d: BAD GRAPH\n", graph_num);
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<check_graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1237 <check_graph+0x117>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d7 <check_graph+0xb7>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0xb,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
shl    $0xb,%rdx
add    %rdx,%rcx
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
je     11c4 <check_graph+0xa4>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
jmp    11c9 <check_graph+0xa9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <check_graph+0x2c>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0xb,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1224 <check_graph+0x104>
mov    -0x18(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
jmp    1229 <check_graph+0x109>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <check_graph+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_graph>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
jle    118a <check_graph+0x6a>
mov    %edx,%r14d
mov    %rsi,%r8
mov    %edi,%edx
xor    %esi,%esi
mov    %r8,%rbx
mov    %r8,%rax
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rax,%rcx,4),%ebp
cmp    (%rdi),%ebp
jne    118f <check_graph+0x6f>
add    $0x1,%rcx
add    $0x800,%rdi
cmp    %rcx,%rdx
jne    1150 <check_graph+0x30>
mov    %rsi,%rcx
shl    $0xb,%rcx
add    %r8,%rcx
cmpl   $0x1,(%rcx,%rsi,4)
je     11c1 <check_graph+0xa1>
add    $0x1,%rsi
add    $0x800,%rax
add    $0x4,%rbx
cmp    %rdx,%rsi
jne    1140 <check_graph+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe6a(%rip),%rdi
mov    %ecx,%edx
mov    %esi,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a2 <check_graph+0x82>

LLVM IR (-O0):
@.str = [74 x i8] c"*** Error- adjacency matrix is not symmetric: A[%5d][%5d] != A[%5d][%5d]\0A\00"
@.str.1 = [24 x i8] c"Graph %5d: BAD GRAPH\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [50 x i8] c"*** Error- graph is not simple, loop at node %5d\0A\00"
define void @check_graph(i32 %0, [512 x i32]* %1, i32 %2) {
%4 = alloca i32
%5 = alloca [512 x i32]*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store [512 x i32]* %1, [512 x i32]** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %68, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %71
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %47, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %50
18: ; preds = %14
%19 = load [512 x i32]*, [512 x i32]** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [512 x i32], [512 x i32]* %19, i64 %21
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [512 x i32], [512 x i32]* %22, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load [512 x i32]*, [512 x i32]** %5
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [512 x i32], [512 x i32]* %27, i64 %29
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [512 x i32], [512 x i32]* %30, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp ne i32 %26, %34
br i1 %35, label %36, label %46
36: ; preds = %18
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* %6
%43 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %18
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %14
50: ; preds = %14
%51 = load [512 x i32]*, [512 x i32]** %5
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [512 x i32], [512 x i32]* %51, i64 %53
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [512 x i32], [512 x i32]* %54, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = icmp eq i32 %58, 1
br i1 %59, label %60, label %67
60: ; preds = %50
%61 = load i32, i32* %7
%62 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %6
%64 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %63)
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %50
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %9
71: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [74 x i8] c"*** Error- adjacency matrix is not symmetric: A[%5d][%5d] != A[%5d][%5d]\0A\00"
@.str.1 = [24 x i8] c"Graph %5d: BAD GRAPH\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [50 x i8] c"*** Error- graph is not simple, loop at node %5d\0A\00"
define void @check_graph(i32 %0, [512 x i32]* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %39
5: ; preds = %3
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %36, %5
%8 = phi i64 [ 0, %5 ], [ %37, %36 ]
br label %9
9: ; preds = %7, %23
%10 = phi i64 [ 0, %7 ], [ %24, %23 ]
%11 = getelementptr inbounds [512 x i32], [512 x i32]* %1, i64 %8, i64 %10
%12 = load i32, i32* %11
%13 = getelementptr inbounds [512 x i32], [512 x i32]* %1, i64 %10, i64 %8
%14 = load i32, i32* %13
%15 = icmp eq i32 %12, %14
br i1 %15, label %23, label %16
16: ; preds = %9
%17 = trunc i64 %8 to i32
%18 = trunc i64 %10 to i32
%19 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %18, i32 %17)
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %9
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %26, label %9
26: ; preds = %23
%27 = getelementptr inbounds [512 x i32], [512 x i32]* %1, i64 %8, i64 %8
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = trunc i64 %8 to i32
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %26
%37 = add nuw nsw i64 %8, 1
%38 = icmp eq i64 %37, %6
br i1 %38, label %39, label %7
39: ; preds = %36, %3
ret void
}