; 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 }

; 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
define dso_local void @removeListNode(ptr noundef %0, ptr noundef %1, ptr noundef byval(%struct.Node) align 8 %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %7 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 1
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %10, label %60

10:                                               ; preds = %3
  %11 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 7
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = sub nsw i32 %14, 1
  %16 = icmp ne i32 %12, %15
  br i1 %16, label %17, label %44

17:                                               ; preds = %10
  store i32 0, ptr %6, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %40, %17
  %19 = load i32, ptr %6, align 4, !tbaa !13
  %20 = icmp slt i32 %19, 6
  br i1 %20, label %21, label %43

21:                                               ; preds = %18
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !13
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds %struct.Node, ptr %22, i64 %24
  %26 = getelementptr inbounds %struct.Node, ptr %25, i32 0, i32 7
  %27 = load i32, ptr %26, align 8, !tbaa !12
  %28 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 7
  %29 = load i32, ptr %28, align 8, !tbaa !12
  %30 = icmp sgt i32 %27, %29
  br i1 %30, label %31, label %39

31:                                               ; preds = %21
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !13
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct.Node, ptr %32, i64 %34
  %36 = getelementptr inbounds %struct.Node, ptr %35, i32 0, i32 7
  %37 = load i32, ptr %36, align 8, !tbaa !12
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr %36, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %31, %21
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %6, align 4, !tbaa !13
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %6, align 4, !tbaa !13
  br label %18, !llvm.loop !14

43:                                               ; preds = %18
  br label %44

44:                                               ; preds = %43, %10
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !16
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %struct.Node, ptr %45, i64 %48
  call void @clearNode(ptr noundef %49)
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !16
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds %struct.Node, ptr %50, i64 %53
  %55 = getelementptr inbounds %struct.Node, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  call void @free(ptr noundef %56) #3
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load i32, ptr %57, align 4, !tbaa !13
  %59 = add nsw i32 %58, -1
  store i32 %59, ptr %57, align 4, !tbaa !13
  br label %60

60:                                               ; preds = %44, %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  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: nounwind uwtable
declare dso_local void @clearNode(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(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 = { 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 = { 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, !11, i64 8}
!10 = !{!"Node", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 32}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !11, i64 12}
!17 = !{!10, !6, i64 0}


; 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 }

; Function Attrs: nounwind uwtable
define dso_local void @removeListNode(ptr noundef %0, ptr nocapture noundef %1, ptr nocapture noundef readonly byval(%struct.Node) align 8 %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %49

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %2, i64 32
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = load i32, ptr %1, align 4, !tbaa !12
  %11 = add nsw i32 %10, -1
  %.not = icmp eq i32 %9, %11
  br i1 %.not, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = icmp sgt i32 %13, %9
  br i1 %14, label %15, label %.preheader.1

15:                                               ; preds = %.preheader.preheader
  %16 = add nsw i32 %13, -1
  store i32 %16, ptr %12, align 8, !tbaa !11
  br label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader, %15
  %17 = getelementptr inbounds i8, ptr %0, i64 72
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp sgt i32 %18, %9
  br i1 %19, label %20, label %.preheader.2

20:                                               ; preds = %.preheader.1
  %21 = add nsw i32 %18, -1
  store i32 %21, ptr %17, align 8, !tbaa !11
  br label %.preheader.2

.preheader.2:                                     ; preds = %20, %.preheader.1
  %22 = getelementptr inbounds i8, ptr %0, i64 112
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = icmp sgt i32 %23, %9
  br i1 %24, label %25, label %.preheader.3

25:                                               ; preds = %.preheader.2
  %26 = add nsw i32 %23, -1
  store i32 %26, ptr %22, align 8, !tbaa !11
  br label %.preheader.3

.preheader.3:                                     ; preds = %25, %.preheader.2
  %27 = getelementptr inbounds i8, ptr %0, i64 152
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = icmp sgt i32 %28, %9
  br i1 %29, label %30, label %.preheader.4

30:                                               ; preds = %.preheader.3
  %31 = add nsw i32 %28, -1
  store i32 %31, ptr %27, align 8, !tbaa !11
  br label %.preheader.4

.preheader.4:                                     ; preds = %30, %.preheader.3
  %32 = getelementptr inbounds i8, ptr %0, i64 192
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = icmp sgt i32 %33, %9
  br i1 %34, label %35, label %.preheader.5

35:                                               ; preds = %.preheader.4
  %36 = add nsw i32 %33, -1
  store i32 %36, ptr %32, align 8, !tbaa !11
  br label %.preheader.5

.preheader.5:                                     ; preds = %35, %.preheader.4
  %37 = getelementptr inbounds i8, ptr %0, i64 232
  %38 = load i32, ptr %37, align 8, !tbaa !11
  %39 = icmp sgt i32 %38, %9
  br i1 %39, label %40, label %.loopexit

40:                                               ; preds = %.preheader.5
  %41 = add nsw i32 %38, -1
  store i32 %41, ptr %37, align 8, !tbaa !11
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.5, %40, %7
  %42 = getelementptr inbounds i8, ptr %2, i64 12
  %43 = load i32, ptr %42, align 4, !tbaa !13
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.Node, ptr %0, i64 %44
  tail call void @clearNode(ptr noundef %45)
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  tail call void @free(ptr noundef %46) #2
  %47 = load i32, ptr %1, align 4, !tbaa !12
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %1, align 4, !tbaa !12
  br label %49

49:                                               ; preds = %.loopexit, %3
  ret void
}

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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, !10, i64 8}
!6 = !{!"Node", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 32}
!12 = !{!10, !10, i64 0}
!13 = !{!6, !10, i64 12}
!14 = !{!6, !7, i64 0}


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