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

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

@.str.4 = external hidden unnamed_addr constant [6 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: nounwind uwtable
declare dso_local void @nodesInfo(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @lowestF(ptr dead_on_unwind noalias writable sret(%struct.Node) align 8 %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.Node, align 8
  %10 = alloca %struct.Node, align 8
  %11 = alloca i32, align 4
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i32 %2, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = zext i32 %12 to i64
  %14 = call ptr @llvm.stacksave.p0()
  store ptr %14, ptr %6, align 8
  %15 = alloca %struct.Node, i64 %13, align 16
  store i64 %13, ptr %7, align 8
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !9
  call void @arrangeID(ptr noundef %15, ptr noundef %16, i32 noundef %17)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 -1, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  br label %18

18:                                               ; preds = %52, %3
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %53

21:                                               ; preds = %18
  store i32 0, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %49, %21
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sub nsw i32 %24, 1
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %27, label %52

27:                                               ; preds = %22
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %struct.Node, ptr %15, i64 %29
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %30, i64 40, i1 false), !tbaa.struct !11
  %31 = load i32, ptr %11, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.Node, ptr %15, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %34, i64 40, i1 false), !tbaa.struct !11
  %35 = getelementptr inbounds %struct.Node, ptr %9, i32 0, i32 6
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 6
  %38 = load i32, ptr %37, align 4, !tbaa !12
  %39 = icmp sgt i32 %36, %38
  br i1 %39, label %40, label %48

40:                                               ; preds = %27
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %struct.Node, ptr %15, i64 %42
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %43, ptr align 8 %10, i64 40, i1 false), !tbaa.struct !11
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %struct.Node, ptr %15, i64 %46
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %47, ptr align 8 %9, i64 40, i1 false), !tbaa.struct !11
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %40, %27
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %11, align 4, !tbaa !9
  br label %22, !llvm.loop !14

52:                                               ; preds = %22
  br label %18, !llvm.loop !16

53:                                               ; preds = %18
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void @nodesInfo(ptr noundef %15)
  %55 = getelementptr inbounds %struct.Node, ptr %15, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 16 %55, i64 40, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %56 = load ptr, ptr %6, align 8
  call void @llvm.stackrestore.p0(ptr %56)
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local void @arrangeID(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 = !{i64 0, i64 8, !5, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 4, !9}
!12 = !{!13, !10, i64 28}
!13 = !{!"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}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @nodesInfo(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @lowestF(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.Node) align 8 %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %.sroa.010 = alloca [28 x i8], align 8
  %4 = zext i32 %2 to i64
  %5 = alloca %struct.Node, i64 %4, align 16
  call void @arrangeID(ptr noundef nonnull %5, ptr noundef %1, i32 noundef %2)
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %.sroa.010)
  %6 = icmp sgt i32 %2, 1
  br i1 %6, label %.preheader.us.preheader, label %.split26.us

.preheader.us.preheader:                          ; preds = %3
  %7 = add nsw i32 %2, -1
  %wide.trip.count = zext i32 %7 to i64
  %.sroa.411.0..sroa_idx.us.phi.trans.insert = getelementptr inbounds i8, ptr %5, i64 28
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %..loopexit_crit_edge.us
  %.sroa.411.0.copyload.us.pre = load i32, ptr %.sroa.411.0..sroa_idx.us.phi.trans.insert, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %.preheader.us, %13
  %.sroa.411.0.copyload.us = phi i32 [ %.sroa.411.0.copyload.us.pre, %.preheader.us ], [ %.sroa.411.0.copyload.us28, %13 ]
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %13 ]
  %.123.us = phi i32 [ 0, %.preheader.us ], [ %.2.us, %13 ]
  %9 = getelementptr inbounds %struct.Node, ptr %5, i64 %indvars.iv
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %.sroa.010, ptr noundef nonnull align 8 dereferenceable(28) %9, i64 28, i1 false), !tbaa.struct !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = getelementptr inbounds %struct.Node, ptr %5, i64 %indvars.iv.next
  %.sroa.4.0..sroa_idx.us = getelementptr inbounds i8, ptr %10, i64 28
  %.sroa.4.0.copyload.us = load i32, ptr %.sroa.4.0..sroa_idx.us, align 4, !tbaa !5
  %11 = icmp sgt i32 %.sroa.411.0.copyload.us, %.sroa.4.0.copyload.us
  br i1 %11, label %12, label %13

12:                                               ; preds = %8
  %.sroa.514.0..sroa_idx.us = getelementptr inbounds i8, ptr %9, i64 32
  %.sroa.514.0.copyload.us = load i64, ptr %.sroa.514.0..sroa_idx.us, align 8
  %.sroa.411.0..sroa_idx.us = getelementptr inbounds i8, ptr %9, i64 28
  %.sroa.5.0..sroa_idx.us = getelementptr inbounds i8, ptr %10, i64 32
  %.sroa.5.0.copyload.us = load i64, ptr %.sroa.5.0..sroa_idx.us, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %9, ptr noundef nonnull align 8 dereferenceable(28) %10, i64 28, i1 false)
  store i32 %.sroa.4.0.copyload.us, ptr %.sroa.411.0..sroa_idx.us, align 4, !tbaa !5
  store i64 %.sroa.5.0.copyload.us, ptr %.sroa.514.0..sroa_idx.us, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %10, ptr noundef nonnull align 8 dereferenceable(28) %.sroa.010, i64 28, i1 false), !tbaa.struct !9
  store i32 %.sroa.411.0.copyload.us, ptr %.sroa.4.0..sroa_idx.us, align 4, !tbaa !5
  store i64 %.sroa.514.0.copyload.us, ptr %.sroa.5.0..sroa_idx.us, align 8
  br label %13

13:                                               ; preds = %12, %8
  %.sroa.411.0.copyload.us28 = phi i32 [ %.sroa.411.0.copyload.us, %12 ], [ %.sroa.4.0.copyload.us, %8 ]
  %.2.us = phi i32 [ 1, %12 ], [ %.123.us, %8 ]
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %..loopexit_crit_edge.us, label %8, !llvm.loop !12

..loopexit_crit_edge.us:                          ; preds = %13
  %.not.us = icmp eq i32 %.2.us, 0
  br i1 %.not.us, label %.split26.us, label %.preheader.us, !llvm.loop !14

.split26.us:                                      ; preds = %..loopexit_crit_edge.us, %3
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  call void @nodesInfo(ptr noundef nonnull %5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 16 dereferenceable(40) %5, i64 40, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %.sroa.010)
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local void @arrangeID(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = !{i64 0, i64 8, !10, i64 8, i64 4, !5, i64 12, i64 4, !5, i64 16, i64 4, !5, i64 20, i64 4, !5, i64 24, i64 4, !5, i64 28, i64 4, !5, i64 32, i64 4, !5}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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