#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*/ addEdge(struct graph *, int, int);
struct graph *createGraph(int);
int /*<<< orphan*/ printGraph(struct graph *);
int /*<<< orphan*/ printf(char *, int, int, char *);
scalar_t__ searchRoute(struct graph *, int, int);
int main(void) {
  struct graph *g = createGraph(6);
  addEdge(g, 0, 3);
  addEdge(g, 1, 3);
  addEdge(g, 3, 5);
  addEdge(g, 2, 4);
  addEdge(g, 4, 5);
  printGraph(g);
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 6; j++) {
      printf("Route between node %i and node %i: %s\n", i, j,
             searchRoute(g, i, j) ? "exists" : "doesn't exist");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x6,%edi
call   1060 <createGraph@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <addEdge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1050 <addEdge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0x5,%edx
call   1050 <addEdge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
mov    $0x4,%edx
call   1050 <addEdge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0x5,%edx
call   1050 <addEdge@plt>
mov    -0x10(%rbp),%rdi
call   1070 <printGraph@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    125b <main+0x10b>
movl   $0x0,-0x18(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    1248 <main+0xf8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <searchRoute@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %rax,%rdi
lea    0xe0f(%rip),%rcx
lea    0xe01(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%rcx
lea    0xdcb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ea <main+0x9a>
jmp    124d <main+0xfd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d9 <main+0x89>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x6,%edi
call   1060 <createGraph@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <addEdge@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1050 <addEdge@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x5,%edx
call   1050 <addEdge@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x4,%edx
call   1050 <addEdge@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
call   1050 <addEdge@plt>
mov    %rbx,%rdi
call   1070 <printGraph@plt>
lea    0xe61(%rip),%r15
lea    0xe53(%rip),%r12
lea    0xe25(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1040 <searchRoute@plt>
test   %rax,%rax
mov    %r12,%rcx
cmove  %r15,%rcx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <searchRoute@plt>
test   %rax,%rax
mov    %r12,%rcx
cmove  %r15,%rcx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1040 <searchRoute@plt>
test   %rax,%rax
mov    %r12,%rcx
cmove  %r15,%rcx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1040 <searchRoute@plt>
test   %rax,%rax
mov    %r12,%rcx
cmove  %r15,%rcx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x4,%edx
call   1040 <searchRoute@plt>
test   %rax,%rax
mov    %r12,%rcx
cmove  %r15,%rcx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x5,%edx
call   1040 <searchRoute@plt>
test   %rax,%rax
mov    %r12,%rcx
cmove  %r15,%rcx
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x5,%edx
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    $0x6,%ebp
jne    11e0 <main+0x90>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.graph = type { i32 }
@.str = [39 x i8] c"Route between node %i and node %i: %s\0A\00"
@.str.1 = [7 x i8] c"exists\00"
@.str.2 = [14 x i8] c"doesn't exist\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.graph*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call %struct.graph* @createGraph(i32 6)
store %struct.graph* %5, %struct.graph** %2
%6 = load %struct.graph*, %struct.graph** %2
%7 = call i32 @addEdge(%struct.graph* %6, i32 0, i32 3)
%8 = load %struct.graph*, %struct.graph** %2
%9 = call i32 @addEdge(%struct.graph* %8, i32 1, i32 3)
%10 = load %struct.graph*, %struct.graph** %2
%11 = call i32 @addEdge(%struct.graph* %10, i32 3, i32 5)
%12 = load %struct.graph*, %struct.graph** %2
%13 = call i32 @addEdge(%struct.graph* %12, i32 2, i32 4)
%14 = load %struct.graph*, %struct.graph** %2
%15 = call i32 @addEdge(%struct.graph* %14, i32 4, i32 5)
%16 = load %struct.graph*, %struct.graph** %2
%17 = call i32 @printGraph(%struct.graph* %16)
store i32 0, i32* %3
br label %18
18: ; preds = %40, %0
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 6
br i1 %20, label %21, label %43
21: ; preds = %18
store i32 0, i32* %4
br label %22
22: ; preds = %36, %21
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 6
br i1 %24, label %25, label %39
25: ; preds = %22
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = load %struct.graph*, %struct.graph** %2
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i64 @searchRoute(%struct.graph* %28, i32 %29, i32 %30)
%32 = icmp ne i64 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0)
%35 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27, i8* %34)
br label %36
36: ; preds = %25
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %22
39: ; preds = %22
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %18
43: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
%struct.graph = type { i32 }
@.str = [39 x i8] c"Route between node %i and node %i: %s\0A\00"
@.str.1 = [7 x i8] c"exists\00"
@.str.2 = [14 x i8] c"doesn't exist\00"
define i32 @main() {
%1 = tail call %struct.graph* @createGraph(i32 6)
%2 = tail call i32 @addEdge(%struct.graph* %1, i32 0, i32 3)
%3 = tail call i32 @addEdge(%struct.graph* %1, i32 1, i32 3)
%4 = tail call i32 @addEdge(%struct.graph* %1, i32 3, i32 5)
%5 = tail call i32 @addEdge(%struct.graph* %1, i32 2, i32 4)
%6 = tail call i32 @addEdge(%struct.graph* %1, i32 4, i32 5)
%7 = tail call i32 @printGraph(%struct.graph* %1)
br label %8
8: ; preds = %0, %8
%9 = phi i32 [ 0, %0 ], [ %34, %8 ]
%10 = tail call i64 @searchRoute(%struct.graph* %1, i32 %9, i32 0)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 0, i8* %12)
%14 = tail call i64 @searchRoute(%struct.graph* %1, i32 %9, i32 1)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 1, i8* %16)
%18 = tail call i64 @searchRoute(%struct.graph* %1, i32 %9, i32 2)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 2, i8* %20)
%22 = tail call i64 @searchRoute(%struct.graph* %1, i32 %9, i32 3)
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 3, i8* %24)
%26 = tail call i64 @searchRoute(%struct.graph* %1, i32 %9, i32 4)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 4, i8* %28)
%30 = tail call i64 @searchRoute(%struct.graph* %1, i32 %9, i32 5)
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%33 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 5, i8* %32)
%34 = add nuw nsw i32 %9, 1
%35 = icmp eq i32 %34, 6
br i1 %35, label %36, label %8
36: ; preds = %8
ret i32 0
}