; LLVM IR from DevonCrawford/A-Pathfinding-in-C-command-line :: backups (pathfinding_copy)

; 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.GridSize = type { i32, i32 }
%struct.Node = type { ptr, i32, i32, i32, i32, i32, i32, i32 }

@size = external dso_local global %struct.GridSize, align 4

; 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
declare dso_local void @info(ptr noundef byval(%struct.Node) align 8) #1

; Function Attrs: nounwind uwtable
define dso_local void @info2D(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %8 = load i32, ptr @size, align 4, !tbaa !11
  %9 = zext i32 %8 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %55, %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %14, label %58

14:                                               ; preds = %10
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %51, %14
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = load i32, ptr getelementptr inbounds (%struct.GridSize, ptr @size, i32 0, i32 1), align 4, !tbaa !13
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %54

19:                                               ; preds = %15
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %47, %19
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = load i32, ptr @size, align 4, !tbaa !11
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %50

24:                                               ; preds = %20
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = mul nsw i64 %27, %9
  %29 = getelementptr inbounds %struct.Node, ptr %25, i64 %28
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.Node, ptr %29, i64 %31
  %33 = getelementptr inbounds %struct.Node, ptr %32, i32 0, i32 7
  %34 = load i32, ptr %33, align 8, !tbaa !14
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = icmp eq i32 %34, %35
  br i1 %36, label %37, label %46

37:                                               ; preds = %24
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = mul nsw i64 %40, %9
  %42 = getelementptr inbounds %struct.Node, ptr %38, i64 %41
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.Node, ptr %42, i64 %44
  call void @info(ptr noundef byval(%struct.Node) align 8 %45)
  br label %50

46:                                               ; preds = %24
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %7, align 4, !tbaa !9
  br label %20, !llvm.loop !16

50:                                               ; preds = %37, %20
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %6, align 4, !tbaa !9
  br label %15, !llvm.loop !18

54:                                               ; preds = %15
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %5, align 4, !tbaa !9
  br label %10, !llvm.loop !19

58:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"GridSize", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = !{!15, !10, i64 32}
!15 = !{!"Node", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


; 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.GridSize = type { i32, i32 }
%struct.Node = type { ptr, i32, i32, i32, i32, i32, i32, i32 }

@size = external dso_local local_unnamed_addr global %struct.GridSize, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @info(ptr noundef byval(%struct.Node) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @info2D(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr @size, align 4, !tbaa !5
  %4 = zext i32 %3 to i64
  %5 = icmp sgt i32 %1, 0
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @size, i64 4), align 4
  %7 = icmp sgt i32 %6, 0
  %or.cond40 = select i1 %5, i1 %7, i1 false
  br i1 %or.cond40, label %.preheader15, label %._crit_edge21

.preheader15:                                     ; preds = %2, %._crit_edge
  %.pre30 = phi i32 [ %.pre3032, %._crit_edge ], [ %3, %2 ]
  %8 = phi i32 [ %29, %._crit_edge ], [ %3, %2 ]
  %9 = phi i32 [ %30, %._crit_edge ], [ %6, %2 ]
  %10 = phi i32 [ %31, %._crit_edge ], [ %6, %2 ]
  %.01419 = phi i32 [ %32, %._crit_edge ], [ 0, %2 ]
  %11 = icmp sgt i32 %10, 0
  %12 = icmp sgt i32 %8, 0
  %or.cond = select i1 %11, i1 %12, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge

.preheader:                                       ; preds = %.preheader15, %.loopexit
  %.pre3034 = phi i32 [ %.pre3033, %.loopexit ], [ %.pre30, %.preheader15 ]
  %13 = phi i32 [ %25, %.loopexit ], [ %9, %.preheader15 ]
  %14 = phi i32 [ %26, %.loopexit ], [ %.pre30, %.preheader15 ]
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.loopexit ], [ 0, %.preheader15 ]
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %16 = mul nuw nsw i64 %indvars.iv26, %4
  %17 = getelementptr inbounds %struct.Node, ptr %0, i64 %16
  %wide.trip.count = zext nneg i32 %14 to i64
  br label %19

18:                                               ; preds = %19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %19, !llvm.loop !10

19:                                               ; preds = %.lr.ph, %18
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %18 ]
  %20 = getelementptr inbounds %struct.Node, ptr %17, i64 %indvars.iv
  %21 = getelementptr inbounds i8, ptr %20, i64 32
  %22 = load i32, ptr %21, align 8, !tbaa !12
  %23 = icmp eq i32 %22, %.01419
  br i1 %23, label %24, label %18

24:                                               ; preds = %19
  tail call void @info(ptr noundef nonnull byval(%struct.Node) align 8 %20)
  %.pre = load i32, ptr @size, align 4, !tbaa !5
  %.pre31 = load i32, ptr getelementptr inbounds (i8, ptr @size, i64 4), align 4, !tbaa !15
  br label %.loopexit

.loopexit:                                        ; preds = %18, %.preheader, %24
  %.pre3033 = phi i32 [ %.pre3034, %.preheader ], [ %.pre, %24 ], [ %.pre3034, %18 ]
  %25 = phi i32 [ %13, %.preheader ], [ %.pre31, %24 ], [ %13, %18 ]
  %26 = phi i32 [ %14, %.preheader ], [ %.pre, %24 ], [ %14, %18 ]
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %27 = sext i32 %25 to i64
  %28 = icmp slt i64 %indvars.iv.next27, %27
  br i1 %28, label %.preheader, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.loopexit, %.preheader15
  %.pre3032 = phi i32 [ %.pre30, %.preheader15 ], [ %.pre3033, %.loopexit ]
  %29 = phi i32 [ %8, %.preheader15 ], [ %26, %.loopexit ]
  %30 = phi i32 [ %9, %.preheader15 ], [ %25, %.loopexit ]
  %31 = phi i32 [ %10, %.preheader15 ], [ %25, %.loopexit ]
  %32 = add nuw nsw i32 %.01419, 1
  %exitcond29.not = icmp eq i32 %32, %1
  br i1 %exitcond29.not, label %._crit_edge21, label %.preheader15, !llvm.loop !18

._crit_edge21:                                    ; preds = %._crit_edge, %2
  ret void
}

attributes #0 = { 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" }

!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, !7, i64 0}
!6 = !{!"GridSize", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !7, i64 32}
!13 = !{!"Node", !14, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !7, i64 4}
!16 = distinct !{!16, !11, !17}
!17 = !{!"llvm.loop.unswitch.partial.disable"}
!18 = distinct !{!18, !11, !17}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass