#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*/ check_vertex_count(int, int);
int /*<<< orphan*/ memset(int **, int /*<<< orphan*/, int);
int /*<<< orphan*/ read_vertex(int, int, int **, int);
int scanf(char *, int *);
int read_graph(int *vertex_count, int G[512][512], int graph_num) {
  if (scanf("%d", vertex_count) != 1) {
    return 0;
  }
  check_vertex_count(*vertex_count, graph_num);
  memset(G, 0, (*vertex_count) * 512 * sizeof(int));
  int i;
  for (i = 0; i < *vertex_count; i++) {
    read_vertex(i, *vertex_count, G, graph_num);
  }
  return 1;
}


x86 assembly (clang, -O0):
<read_graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     1178 <read_graph+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <read_graph+0xa2>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%esi
call   1040 <check_vertex_count@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x9,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11db <read_graph+0x9b>
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1050 <read_vertex@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <read_graph+0x69>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_graph>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%rbp
lea    0xea8(%rip),%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
xor    %r15d,%r15d
cmp    $0x1,%eax
jne    11b7 <read_graph+0x77>
mov    0x0(%rbp),%edi
mov    %r14d,%esi
call   1040 <check_vertex_count@plt>
mov    0x0(%rbp),%edx
shl    $0xb,%edx
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x0(%rbp),%esi
mov    $0x1,%r15d
test   %esi,%esi
jle    11b7 <read_graph+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r12,%rdx
mov    %r14d,%ecx
call   1050 <read_vertex@plt>
add    $0x1,%ebx
mov    0x0(%rbp),%esi
cmp    %esi,%ebx
jl     11a0 <read_graph+0x60>
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @read_graph(i32* %0, [512 x i32]* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [512 x i32]*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store [512 x i32]* %1, [512 x i32]** %6
store i32 %2, i32* %7
%9 = load i32*, i32** %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 0, i32* %4
br label %44
13: ; preds = %3
%14 = load i32*, i32** %5
%15 = load i32, i32* %14
%16 = load i32, i32* %7
%17 = call i32 @check_vertex_count(i32 %15, i32 %16)
%18 = load [512 x i32]*, [512 x i32]** %6
%19 = bitcast [512 x i32]* %18 to i32**
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = mul nsw i32 %21, 512
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 4
%25 = trunc i64 %24 to i32
%26 = call i32 @memset(i32** %19, i32 0, i32 %25)
store i32 0, i32* %8
br label %27
27: ; preds = %40, %13
%28 = load i32, i32* %8
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %43
32: ; preds = %27
%33 = load i32, i32* %8
%34 = load i32*, i32** %5
%35 = load i32, i32* %34
%36 = load [512 x i32]*, [512 x i32]** %6
%37 = bitcast [512 x i32]* %36 to i32**
%38 = load i32, i32* %7
%39 = call i32 @read_vertex(i32 %33, i32 %35, i32** %37, i32 %38)
br label %40
40: ; preds = %32
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %27
43: ; preds = %27
store i32 1, i32* %4
br label %44
44: ; preds = %43, %12
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @read_graph(i32* %0, [512 x i32]* %1, i32 %2) {
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = load i32, i32* %0
%8 = tail call i32 @check_vertex_count(i32 %7, i32 %2)
%9 = bitcast [512 x i32]* %1 to i32**
%10 = load i32, i32* %0
%11 = shl i32 %10, 11
%12 = tail call i32 @memset(i32** %9, i32 0, i32 %11)
%13 = load i32, i32* %0
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %6, %15
%16 = phi i32 [ %20, %15 ], [ %13, %6 ]
%17 = phi i32 [ %19, %15 ], [ 0, %6 ]
%18 = tail call i32 @read_vertex(i32 %17, i32 %16, i32** %9, i32 %2)
%19 = add nuw nsw i32 %17, 1
%20 = load i32, i32* %0
%21 = icmp slt i32 %19, %20
br i1 %21, label %15, label %22
22: ; preds = %15, %6, %3
%23 = phi i32 [ 0, %3 ], [ 1, %6 ], [ 1, %15 ]
ret i32 %23
}