#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);
struct Graph *create_graph(int);
int get_max_dist(struct Graph *, int /*<<< orphan*/);
int /*<<< orphan*/ print_graph(struct Graph *);
int /*<<< orphan*/ printf(char *, int);
void main() {
  int V = 5;
  struct Graph *graph = create_graph(V);
  add_edge(graph, 0, 1);
  add_edge(graph, 0, 2);
  add_edge(graph, 1, 3);
  add_edge(graph, 2, 3);
  add_edge(graph, 4, 2);
  add_edge(graph, 3, 4);
  print_graph(graph);
  int res = get_max_dist(graph, 0);
  printf("The maximum distance from root is %d\n", res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <create_graph@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <add_edge@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1040 <add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1040 <add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   1040 <add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1040 <add_edge@plt>
mov    -0x10(%rbp),%rdi
call   1030 <print_graph@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1070 <get_max_dist@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe08(%rip),%rdi
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x5,%edi
call   1060 <create_graph@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <add_edge@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <add_edge@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1040 <add_edge@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1040 <add_edge@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   1040 <add_edge@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1040 <add_edge@plt>
mov    %rbx,%rdi
call   1030 <print_graph@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <get_max_dist@plt>
lea    0xe23(%rip),%rdi
mov    %eax,%esi
pop    %rbx
jmp    1050 <printf@plt>

LLVM IR (-O0):
%struct.Graph = type { i32 }
@.str = [38 x i8] c"The maximum distance from root is %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca %struct.Graph*
%3 = alloca i32
store i32 5, i32* %1
%4 = load i32, i32* %1
%5 = call %struct.Graph* @create_graph(i32 %4)
store %struct.Graph* %5, %struct.Graph** %2
%6 = load %struct.Graph*, %struct.Graph** %2
%7 = call i32 @add_edge(%struct.Graph* %6, i32 0, i32 1)
%8 = load %struct.Graph*, %struct.Graph** %2
%9 = call i32 @add_edge(%struct.Graph* %8, i32 0, i32 2)
%10 = load %struct.Graph*, %struct.Graph** %2
%11 = call i32 @add_edge(%struct.Graph* %10, i32 1, i32 3)
%12 = load %struct.Graph*, %struct.Graph** %2
%13 = call i32 @add_edge(%struct.Graph* %12, i32 2, i32 3)
%14 = load %struct.Graph*, %struct.Graph** %2
%15 = call i32 @add_edge(%struct.Graph* %14, i32 4, i32 2)
%16 = load %struct.Graph*, %struct.Graph** %2
%17 = call i32 @add_edge(%struct.Graph* %16, i32 3, i32 4)
%18 = load %struct.Graph*, %struct.Graph** %2
%19 = call i32 @print_graph(%struct.Graph* %18)
%20 = load %struct.Graph*, %struct.Graph** %2
%21 = call i32 @get_max_dist(%struct.Graph* %20, i32 0)
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %22)
ret void
}

LLVM IR (-O2):
%struct.Graph = type { i32 }
@.str = [38 x i8] c"The maximum distance from root is %d\0A\00"
define void @main() {
%1 = tail call %struct.Graph* @create_graph(i32 5)
%2 = tail call i32 @add_edge(%struct.Graph* %1, i32 0, i32 1)
%3 = tail call i32 @add_edge(%struct.Graph* %1, i32 0, i32 2)
%4 = tail call i32 @add_edge(%struct.Graph* %1, i32 1, i32 3)
%5 = tail call i32 @add_edge(%struct.Graph* %1, i32 2, i32 3)
%6 = tail call i32 @add_edge(%struct.Graph* %1, i32 4, i32 2)
%7 = tail call i32 @add_edge(%struct.Graph* %1, i32 3, i32 4)
%8 = tail call i32 @print_graph(%struct.Graph* %1)
%9 = tail call i32 @get_max_dist(%struct.Graph* %1, i32 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %9)
ret void
}