; LLVM IR from Vishnuparammal/maze_runner :: src (maze)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.Graph = type { i32, ptr }
%struct.AdjList = type { ptr, float, float, i32, [4 x float] }
%struct.AdjListNode = type { i32, float, i32, ptr }

@graph = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @printGraph() #1 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %68, %0
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = load ptr, ptr @graph, align 8, !tbaa !9
  %6 = getelementptr inbounds %struct.Graph, ptr %5, i32 0, i32 0
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = icmp slt i32 %4, %7
  br i1 %8, label %10, label %9

9:                                                ; preds = %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %71

10:                                               ; preds = %3
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %11)
  %13 = load ptr, ptr @graph, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.Graph, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds %struct.AdjList, ptr %15, i64 %17
  %19 = getelementptr inbounds %struct.AdjList, ptr %18, i32 0, i32 1
  %20 = load float, ptr %19, align 8, !tbaa !14
  %21 = fpext float %20 to double
  %22 = load ptr, ptr @graph, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.Graph, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %struct.AdjList, ptr %24, i64 %26
  %28 = getelementptr inbounds %struct.AdjList, ptr %27, i32 0, i32 2
  %29 = load float, ptr %28, align 4, !tbaa !17
  %30 = fpext float %29 to double
  %31 = load ptr, ptr @graph, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.Graph, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load i32, ptr %1, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds %struct.AdjList, ptr %33, i64 %35
  %37 = getelementptr inbounds %struct.AdjList, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %21, double noundef %30, i32 noundef %38)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %40 = load ptr, ptr @graph, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.Graph, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.AdjList, ptr %42, i64 %44
  %46 = getelementptr inbounds %struct.AdjList, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  store ptr %47, ptr %2, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %51, %10
  %49 = load ptr, ptr %2, align 8, !tbaa !9
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %66

51:                                               ; preds = %48
  %52 = load ptr, ptr %2, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.AdjListNode, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !20
  %55 = load ptr, ptr %2, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.AdjListNode, ptr %55, i32 0, i32 1
  %57 = load float, ptr %56, align 4, !tbaa !22
  %58 = fpext float %57 to double
  %59 = load ptr, ptr %2, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.AdjListNode, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !23
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %54, double noundef %58, i32 noundef %61)
  %63 = load ptr, ptr %2, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.AdjListNode, ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !24
  store ptr %65, ptr %2, align 8, !tbaa !9
  br label %48, !llvm.loop !25

66:                                               ; preds = %48
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  br label %68

68:                                               ; preds = %66
  %69 = load i32, ptr %1, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %1, align 4, !tbaa !5
  br label %3, !llvm.loop !27

71:                                               ; preds = %9
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"Graph", !6, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!15, !16, i64 8}
!15 = !{!"AdjList", !10, i64 0, !16, i64 8, !16, i64 12, !6, i64 16, !7, i64 20}
!16 = !{!"float", !7, i64 0}
!17 = !{!15, !16, i64 12}
!18 = !{!15, !6, i64 16}
!19 = !{!15, !10, i64 0}
!20 = !{!21, !6, i64 8}
!21 = !{!"AdjListNode", !6, i64 0, !16, i64 4, !6, i64 8, !10, i64 16}
!22 = !{!21, !16, i64 4}
!23 = !{!21, !6, i64 0}
!24 = !{!21, !10, i64 16}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.AdjList = type { ptr, float, float, i32, [4 x float] }

@graph = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @printGraph() local_unnamed_addr #0 {
  %1 = load ptr, ptr @graph, align 8, !tbaa !5
  %2 = load i32, ptr %1, align 8, !tbaa !9
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph17, label %._crit_edge18

._crit_edge18:                                    ; preds = %._crit_edge, %0
  ret void

.lr.ph17:                                         ; preds = %0, %._crit_edge
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge ], [ 0, %0 ]
  %4 = trunc nuw nsw i64 %indvars.iv to i32
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %4)
  %6 = load ptr, ptr @graph, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds %struct.AdjList, ptr %8, i64 %indvars.iv
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load float, ptr %10, align 8, !tbaa !13
  %12 = fpext float %11 to double
  %13 = getelementptr inbounds i8, ptr %9, i64 12
  %14 = load float, ptr %13, align 4, !tbaa !16
  %15 = fpext float %14 to double
  %16 = getelementptr inbounds i8, ptr %9, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %12, double noundef %15, i32 noundef %17)
  %19 = load ptr, ptr @graph, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = getelementptr inbounds %struct.AdjList, ptr %21, i64 %indvars.iv
  %.012 = load ptr, ptr %22, align 8, !tbaa !5
  %.not13 = icmp eq ptr %.012, null
  br i1 %.not13, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph17, %.lr.ph
  %.014 = phi ptr [ %.0, %.lr.ph ], [ %.012, %.lr.ph17 ]
  %23 = getelementptr inbounds i8, ptr %.014, i64 8
  %24 = load i32, ptr %23, align 8, !tbaa !18
  %25 = getelementptr inbounds i8, ptr %.014, i64 4
  %26 = load float, ptr %25, align 4, !tbaa !20
  %27 = fpext float %26 to double
  %28 = load i32, ptr %.014, align 8, !tbaa !21
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %24, double noundef %27, i32 noundef %28)
  %30 = getelementptr inbounds i8, ptr %.014, i64 16
  %.0 = load ptr, ptr %30, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph17
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = load ptr, ptr @graph, align 8, !tbaa !5
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next, %34
  br i1 %35, label %.lr.ph17, label %._crit_edge18, !llvm.loop !24
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Graph", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !15, i64 8}
!14 = !{!"AdjList", !6, i64 0, !15, i64 8, !15, i64 12, !11, i64 16, !7, i64 20}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !15, i64 12}
!17 = !{!14, !11, i64 16}
!18 = !{!19, !11, i64 8}
!19 = !{!"AdjListNode", !11, i64 0, !15, i64 4, !11, i64 8, !6, i64 16}
!20 = !{!19, !15, i64 4}
!21 = !{!19, !11, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass