#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 firstadj(int **, int);
int nextadj(int **, int, int);
int /*<<< orphan*/ printf(char *, int);
void DFS(int matrix[5][5], int s[], int v) {
  int u;
  printf("V%d ", v);
  s[v] = 1;
  u = firstadj(matrix, v);
  while (u >= 0) {
    if (s[u] != 1) {
      DFS(matrix, s, u);
    }
    u = nextadj(matrix, v, u);
  }
}


x86 assembly (clang, -O0):
<DFS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <firstadj@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11c3 <DFS+0x83>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
je     11ac <DFS+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1050 <DFS@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <nextadj@plt>
mov    %eax,-0x18(%rbp)
jmp    1180 <DFS+0x40>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DFS>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xea9(%rip),%rdi
mov    %edx,%esi
call   1040 <printf@plt>
movslq %r14d,%rsi
movl   $0x1,(%r15,%rsi,4)
mov    %rbp,%rdi
call   1060 <firstadj@plt>
test   %eax,%eax
js     11ab <DFS+0x6b>
mov    %eax,%ebx
jmp    1193 <DFS+0x53>
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %ebx,%edx
call   1030 <nextadj@plt>
mov    %eax,%ebx
test   %eax,%eax
js     11ab <DFS+0x6b>
mov    %ebx,%eax
cmpl   $0x1,(%r15,%rax,4)
je     1180 <DFS+0x40>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <DFS@plt>
jmp    1180 <DFS+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"V%d \00"
define void @DFS([5 x i32]* %0, i32* %1, i32 %2) {
%4 = alloca [5 x i32]*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store [5 x i32]* %0, [5 x i32]** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32*, i32** %5
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
store i32 1, i32* %13
%14 = load [5 x i32]*, [5 x i32]** %4
%15 = bitcast [5 x i32]* %14 to i32**
%16 = load i32, i32* %6
%17 = call i32 @firstadj(i32** %15, i32 %16)
store i32 %17, i32* %7
br label %18
18: ; preds = %32, %3
%19 = load i32, i32* %7
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %38
21: ; preds = %18
%22 = load i32*, i32** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = load [5 x i32]*, [5 x i32]** %4
%30 = load i32*, i32** %5
%31 = load i32, i32* %7
br label %32
32: ; preds = %28, %21
%33 = load [5 x i32]*, [5 x i32]** %4
%34 = bitcast [5 x i32]* %33 to i32**
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = call i32 @nextadj(i32** %34, i32 %35, i32 %36)
store i32 %37, i32* %7
br label %18
38: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"V%d \00"
define void @DFS([5 x i32]* %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %2)
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i32, i32* %1, i64 %5
store i32 1, i32* %6
%7 = bitcast [5 x i32]* %0 to i32**
%8 = tail call i32 @firstadj(i32** %7, i32 %2)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %20
10: ; preds = %3, %17
%11 = phi i32 [ %18, %17 ], [ %8, %3 ]
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %1, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 1
br i1 %15, label %17, label %16
16: ; preds = %10
tail call void @DFS([5 x i32]* %0, i32* %1, i32 %11)
br label %17
17: ; preds = %16, %10
%18 = tail call i32 @nextadj(i32** %7, i32 %2, i32 %11)
%19 = icmp sgt i32 %18, -1
br i1 %19, label %10, label %20
20: ; preds = %17, %3
ret void
}