#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 */
struct graph {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_edge(struct graph *, int, int);
int /*<<< orphan*/ bfs(struct graph *, int /*<<< orphan*/);
struct graph *create_graph(int);
int /*<<< orphan*/ dfs(struct graph *, int);
int is_cycylic(struct graph *);
int /*<<< orphan*/ print_graph(struct graph *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ topoloical_sort(struct graph *);
int main() {
  int V = 7;
  struct graph *g = NULL;
  g = create_graph(V);
  if (g == NULL) {
    return -1;
  }
  add_edge(g, 0, 1);
  add_edge(g, 0, 2);
  add_edge(g, 6, 1);
  add_edge(g, 6, 2);
  add_edge(g, 6, 5);
  int i = is_cycylic(g);
  if (i)
    printf(" graph has is_cycylic\n");
  else
    printf(" graph doesnot has is_cycylic\n");
  dfs(g, 0);
  dfs(g, 1);
  dfs(g, 2);
  dfs(g, 3);
  dfs(g, 4);
  dfs(g, 5);
  print_graph(g, V);
  bfs(g, 0);
  topoloical_sort(g);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1090 <create_graph@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c1 <main+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c5 <main+0x145>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <add_edge@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
call   1050 <add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
call   1050 <add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x6,%esi
mov    $0x5,%edx
call   1050 <add_edge@plt>
mov    -0x10(%rbp),%rdi
call   1060 <is_cycylic@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1241 <main+0xc1>
lea    0xdc9(%rip),%rdi
call   1070 <printf@plt>
jmp    124d <main+0xcd>
lea    0xdcf(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   10a0 <dfs@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <dfs@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   10a0 <dfs@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   10a0 <dfs@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   10a0 <dfs@plt>
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   10a0 <dfs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <print_graph@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1080 <bfs@plt>
mov    -0x10(%rbp),%rdi
call   1030 <topoloical_sort@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x7,%edi
call   1090 <create_graph@plt>
test   %rax,%rax
je     127c <main+0xfc>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <add_edge@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1060 <add_edge@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x1,%edx
call   1060 <add_edge@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x2,%edx
call   1060 <add_edge@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x5,%edx
call   1060 <add_edge@plt>
mov    %rbx,%rdi
call   1070 <is_cycylic@plt>
test   %eax,%eax
lea    0xe00(%rip),%rax
lea    0xe17(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <dfs@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   10a0 <dfs@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   10a0 <dfs@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   10a0 <dfs@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   10a0 <dfs@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   10a0 <dfs@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1050 <print_graph@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <bfs@plt>
mov    %rbx,%rdi
call   1030 <topoloical_sort@plt>
jmp    1281 <main+0x101>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.graph = type { i32 }
@.str = [23 x i8] c" graph has is_cycylic\0A\00"
@.str.1 = [31 x i8] c" graph doesnot has is_cycylic\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.graph*
%4 = alloca i32
store i32 0, i32* %1
store i32 7, i32* %2
store %struct.graph* null, %struct.graph** %3
%5 = load i32, i32* %2
%6 = call %struct.graph* @create_graph(i32 %5)
store %struct.graph* %6, %struct.graph** %3
%7 = load %struct.graph*, %struct.graph** %3
%8 = icmp eq %struct.graph* %7, null
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %49
10: ; preds = %0
%11 = load %struct.graph*, %struct.graph** %3
%12 = call i32 @add_edge(%struct.graph* %11, i32 0, i32 1)
%13 = load %struct.graph*, %struct.graph** %3
%14 = call i32 @add_edge(%struct.graph* %13, i32 0, i32 2)
%15 = load %struct.graph*, %struct.graph** %3
%16 = call i32 @add_edge(%struct.graph* %15, i32 6, i32 1)
%17 = load %struct.graph*, %struct.graph** %3
%18 = call i32 @add_edge(%struct.graph* %17, i32 6, i32 2)
%19 = load %struct.graph*, %struct.graph** %3
%20 = call i32 @add_edge(%struct.graph* %19, i32 6, i32 5)
%21 = load %struct.graph*, %struct.graph** %3
%22 = call i32 @is_cycylic(%struct.graph* %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %10
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %29
27: ; preds = %10
%28 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = load %struct.graph*, %struct.graph** %3
%31 = call i32 @dfs(%struct.graph* %30, i32 0)
%32 = load %struct.graph*, %struct.graph** %3
%33 = call i32 @dfs(%struct.graph* %32, i32 1)
%34 = load %struct.graph*, %struct.graph** %3
%35 = call i32 @dfs(%struct.graph* %34, i32 2)
%36 = load %struct.graph*, %struct.graph** %3
%37 = call i32 @dfs(%struct.graph* %36, i32 3)
%38 = load %struct.graph*, %struct.graph** %3
%39 = call i32 @dfs(%struct.graph* %38, i32 4)
%40 = load %struct.graph*, %struct.graph** %3
%41 = call i32 @dfs(%struct.graph* %40, i32 5)
%42 = load %struct.graph*, %struct.graph** %3
%43 = load i32, i32* %2
%44 = call i32 @print_graph(%struct.graph* %42, i32 %43)
%45 = load %struct.graph*, %struct.graph** %3
%46 = call i32 @bfs(%struct.graph* %45, i32 0)
%47 = load %struct.graph*, %struct.graph** %3
%48 = call i32 @topoloical_sort(%struct.graph* %47)
store i32 0, i32* %1
br label %49
49: ; preds = %29, %9
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
%struct.graph = type { i32 }
@str = [30 x i8] c" graph doesnot has is_cycylic\00"
@str.2 = [22 x i8] c" graph has is_cycylic\00"
define i32 @main() {
%1 = tail call %struct.graph* @create_graph(i32 7)
%2 = icmp eq %struct.graph* %1, null
br i1 %2, label %22, label %3
3: ; preds = %0
%4 = tail call i32 @add_edge(%struct.graph* %1, i32 0, i32 1)
%5 = tail call i32 @add_edge(%struct.graph* %1, i32 0, i32 2)
%6 = tail call i32 @add_edge(%struct.graph* %1, i32 6, i32 1)
%7 = tail call i32 @add_edge(%struct.graph* %1, i32 6, i32 2)
%8 = tail call i32 @add_edge(%struct.graph* %1, i32 6, i32 5)
%9 = tail call i32 @is_cycylic(%struct.graph* %1)
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.2, i64 0, i64 0)
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
%13 = tail call i32 @dfs(%struct.graph* %1, i32 0)
%14 = tail call i32 @dfs(%struct.graph* %1, i32 1)
%15 = tail call i32 @dfs(%struct.graph* %1, i32 2)
%16 = tail call i32 @dfs(%struct.graph* %1, i32 3)
%17 = tail call i32 @dfs(%struct.graph* %1, i32 4)
%18 = tail call i32 @dfs(%struct.graph* %1, i32 5)
%19 = tail call i32 @print_graph(%struct.graph* %1, i32 7)
%20 = tail call i32 @bfs(%struct.graph* %1, i32 0)
%21 = tail call i32 @topoloical_sort(%struct.graph* %1)
br label %22
22: ; preds = %0, %3
%23 = phi i32 [ 0, %3 ], [ -1, %0 ]
ret i32 %23
}