#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*/ check_degree(int, int, int);
int /*<<< orphan*/ check_int_scanf(int *, int);
int /*<<< orphan*/ check_vertex(int, int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, ...);
void read_vertex(int vertex, int vertex_count, int G[512][512], int graph_num) {
  int degree;
  check_int_scanf(&degree, graph_num);
  check_degree(degree, vertex_count, graph_num);
  int i, neighbour;
  for (i = 0; i < degree; i++) {
    check_int_scanf(&neighbour, graph_num);
    check_vertex(neighbour, vertex_count, graph_num);
    if (G[vertex][neighbour] == 1) {
      printf("*** Error- graph is not simple, multiple edges between node %5d "
             "and node %5d\n",
             vertex, neighbour);
      printf("Graph   %5d: BAD GRAPH\n", graph_num);
      exit(EXIT_FAILURE);
    } else {
      G[vertex][neighbour] = 1;
    }
  }
}


x86 assembly (clang, -O0):
<read_vertex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1030 <check_int_scanf@plt>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <check_degree@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1229 <read_vertex+0xd9>
mov    -0x14(%rbp),%esi
lea    -0x20(%rbp),%rdi
call   1030 <check_int_scanf@plt>
mov    -0x20(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <check_vertex@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0xb,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    11fc <read_vertex+0xac>
mov    -0x4(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0xb,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    121b <read_vertex+0xcb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <read_vertex+0x36>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_vertex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %rdx,%rbp
mov    %esi,%r15d
mov    %edi,%r14d
mov    %rsp,%rdi
mov    %ecx,%esi
call   1030 <check_int_scanf@plt>
mov    (%rsp),%edi
mov    %r15d,%esi
mov    %r13d,%edx
call   1040 <check_degree@plt>
cmpl   $0x0,(%rsp)
jle    11df <read_vertex+0x8f>
movslq %r14d,%rax
xor    %ebx,%ebx
lea    0x4(%rsp),%r12
shl    $0xb,%rax
add    %rax,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13d,%esi
call   1030 <check_int_scanf@plt>
mov    0x4(%rsp),%edi
mov    %r15d,%esi
mov    %r13d,%edx
call   1070 <check_vertex@plt>
movslq 0x4(%rsp),%rdx
cmpl   $0x1,0x0(%rbp,%rdx,4)
je     11ee <read_vertex+0x9e>
lea    0x0(,%rdx,4),%rax
add    %rbp,%rax
movl   $0x1,(%rax)
add    $0x1,%ebx
cmp    (%rsp),%ebx
jl     11a0 <read_vertex+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0b(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe48(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [78 x i8] c"*** Error- graph is not simple, multiple edges between node %5d and node %5d\0A\00"
@.str.1 = [24 x i8] c"Graph %5d: BAD GRAPH\0A\00"
@EXIT_FAILURE = global i32 0
define void @read_vertex(i32 %0, i32 %1, [512 x i32]* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca [512 x i32]*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store [512 x i32]* %2, [512 x i32]** %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = call i32 @check_int_scanf(i32* %9, i32 %12)
%14 = load i32, i32* %9
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = call i32 @check_degree(i32 %14, i32 %15, i32 %16)
store i32 0, i32* %10
br label %18
18: ; preds = %55, %4
%19 = load i32, i32* %10
%20 = load i32, i32* %9
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %58
22: ; preds = %18
%23 = load i32, i32* %8
%24 = call i32 @check_int_scanf(i32* %11, i32 %23)
%25 = load i32, i32* %11
%26 = load i32, i32* %6
%27 = load i32, i32* %8
%28 = call i32 @check_vertex(i32 %25, i32 %26, i32 %27)
%29 = load [512 x i32]*, [512 x i32]** %7
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [512 x i32], [512 x i32]* %29, i64 %31
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [512 x i32], [512 x i32]* %32, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %46
38: ; preds = %22
%39 = load i32, i32* %5
%40 = load i32, i32* %11
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i32 %39, i32 %40)
%42 = load i32, i32* %8
%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 = %22
%47 = load [512 x i32]*, [512 x i32]** %7
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [512 x i32], [512 x i32]* %47, i64 %49
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [512 x i32], [512 x i32]* %50, i64 0, i64 %52
store i32 1, i32* %53
br label %54
54: ; preds = %46
br label %55
55: ; preds = %54
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %18
58: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [78 x i8] c"*** Error- graph is not simple, multiple edges between node %5d and node %5d\0A\00"
@.str.1 = [24 x i8] c"Graph %5d: BAD GRAPH\0A\00"
@EXIT_FAILURE = global i32 0
define void @read_vertex(i32 %0, i32 %1, [512 x i32]* nocapture %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
%8 = call i32 @check_int_scanf(i32* %5, i32 %3)
%9 = load i32, i32* %5
%10 = call i32 @check_degree(i32 %9, i32 %1, i32 %3)
%11 = bitcast i32* %6 to i8*
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %35
14: ; preds = %4
%15 = sext i32 %0 to i64
br label %16
16: ; preds = %14, %31
%17 = phi i32 [ 0, %14 ], [ %32, %31 ]
%18 = call i32 @check_int_scanf(i32* %6, i32 %3)
%19 = load i32, i32* %6
%20 = call i32 @check_vertex(i32 %19, i32 %1, i32 %3)
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [512 x i32], [512 x i32]* %2, i64 %15, i64 %22
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %16
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %21)
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %16
store i32 1, i32* %23
%32 = add nuw nsw i32 %17, 1
%33 = load i32, i32* %5
%34 = icmp slt i32 %32, %33
br i1 %34, label %16, label %35
35: ; preds = %31, %4
ret void
}