#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*/ bfs(int **, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ populate(int **, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int v;
  int i;
  scanf("%d", &v);
  int **adjacency_matrix = (int **)malloc(sizeof(int *) * v);
  for (i = 0; i < v; ++i) {
    adjacency_matrix[i] = (int *)malloc(sizeof(int) * v);
  }
  populate(adjacency_matrix, v);
  bfs(adjacency_matrix, v);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <main+0x71>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1179 <main+0x39>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <populate@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <bfs@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    118c <main+0x4c>
xor    %ebx,%ebx
xchg   %ax,%ax
shl    $0x2,%esi
mov    %esi,%edi
call   1050 <malloc@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
movslq 0x4(%rsp),%rsi
cmp    %rsi,%rbx
jl     1170 <main+0x30>
mov    %r14,%rdi
call   1040 <populate@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1030 <bfs@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32**
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32**
store i32** %11, i32*** %4
store i32 0, i32* %3
br label %12
12: ; preds = %27, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = mul i64 4, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
%23 = load i32**, i32*** %4
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32*, i32** %23, i64 %25
store i32* %22, i32** %26
br label %27
27: ; preds = %16
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %12
30: ; preds = %12
%31 = load i32**, i32*** %4
%32 = load i32, i32* %2
%33 = call i32 @populate(i32** %31, i32 %32)
%34 = load i32**, i32*** %4
%35 = load i32, i32* %2
%36 = call i32 @bfs(i32** %34, i32 %35)
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = shl i32 %4, 3
%6 = call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i32**
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %0, %10
%11 = phi i64 [ %17, %10 ], [ 0, %0 ]
%12 = phi i32 [ %18, %10 ], [ %8, %0 ]
%13 = shl i32 %12, 2
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = getelementptr inbounds i32*, i32** %7, i64 %11
store i32* %15, i32** %16
%17 = add nuw nsw i64 %11, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %10, label %21
21: ; preds = %10, %0
%22 = phi i32 [ %8, %0 ], [ %18, %10 ]
%23 = call i32 @populate(i32** %7, i32 %22)
%24 = load i32, i32* %1
%25 = call i32 @bfs(i32** %7, i32 %24)
ret i32 0
}