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

; 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
@.str.17 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 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

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

; Function Attrs: nounwind uwtable
declare dso_local void @addListNode(ptr noundef, ptr noundef, ptr noundef byval(%struct.Node) align 8, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @calculateNodeValues(ptr noundef byval(%struct.Node) align 8 %0, ptr noundef byval(%struct.Node) align 8 %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.Node, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !9
  store ptr %5, ptr %11, align 8, !tbaa !9
  store ptr %6, ptr %12, align 8, !tbaa !9
  %19 = load i32, ptr @size, align 4, !tbaa !11
  %20 = zext i32 %19 to i64
  %21 = load i32, ptr @size, align 4, !tbaa !11
  %22 = zext i32 %21 to i64
  call void @llvm.lifetime.start.p0(i64 40, ptr %13) #4
  call void @clearNode(ptr noundef %13)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 2
  store i32 %23, ptr %24, align 4, !tbaa !13
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 3
  store i32 %25, ptr %26, align 8, !tbaa !15
  %27 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 0
  store ptr %0, ptr %27, align 8, !tbaa !16
  %28 = getelementptr inbounds %struct.Node, ptr %0, i32 0, i32 4
  %29 = load i32, ptr %28, align 4, !tbaa !17
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %14, align 4, !tbaa !5
  %31 = load i32, ptr %14, align 4, !tbaa !5
  %32 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 4
  store i32 %31, ptr %32, align 4, !tbaa !17
  %33 = getelementptr inbounds %struct.Node, ptr %1, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 2
  %36 = load i32, ptr %35, align 4, !tbaa !13
  %37 = sub nsw i32 %34, %36
  %38 = sitofp i32 %37 to double
  %39 = call double @llvm.fabs.f64(double %38)
  %40 = fptosi double %39 to i32
  store i32 %40, ptr %15, align 4, !tbaa !5
  %41 = getelementptr inbounds %struct.Node, ptr %1, i32 0, i32 3
  %42 = load i32, ptr %41, align 8, !tbaa !15
  %43 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 3
  %44 = load i32, ptr %43, align 8, !tbaa !15
  %45 = sub nsw i32 %42, %44
  %46 = sitofp i32 %45 to double
  %47 = call double @llvm.fabs.f64(double %46)
  %48 = fptosi double %47 to i32
  store i32 %48, ptr %16, align 4, !tbaa !5
  %49 = load i32, ptr %15, align 4, !tbaa !5
  %50 = load i32, ptr %16, align 4, !tbaa !5
  %51 = add nsw i32 %49, %50
  store i32 %51, ptr %17, align 4, !tbaa !5
  %52 = load i32, ptr %17, align 4, !tbaa !5
  %53 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 5
  store i32 %52, ptr %53, align 8, !tbaa !18
  %54 = load i32, ptr %14, align 4, !tbaa !5
  %55 = load i32, ptr %17, align 4, !tbaa !5
  %56 = add nsw i32 %54, %55
  store i32 %56, ptr %18, align 4, !tbaa !5
  %57 = load i32, ptr %18, align 4, !tbaa !5
  %58 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 6
  store i32 %57, ptr %58, align 4, !tbaa !19
  %59 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = getelementptr inbounds %struct.Node, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %61, align 4, !tbaa !13
  %63 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !16
  %65 = getelementptr inbounds %struct.Node, ptr %64, i32 0, i32 3
  %66 = load i32, ptr %65, align 8, !tbaa !15
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, i32 noundef %62, i32 noundef %66)
  %68 = load ptr, ptr %11, align 8, !tbaa !9
  %69 = load ptr, ptr %12, align 8, !tbaa !9
  call void @addListNode(ptr noundef %68, ptr noundef %69, ptr noundef byval(%struct.Node) align 8 %13, ptr noundef @.str.18)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %13) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"GridSize", !6, i64 0, !6, i64 4}
!13 = !{!14, !6, i64 12}
!14 = !{!"Node", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32}
!15 = !{!14, !6, i64 16}
!16 = !{!14, !10, i64 0}
!17 = !{!14, !6, i64 20}
!18 = !{!14, !6, i64 24}
!19 = !{!14, !6, i64 28}


; 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.17 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @calculateNodeValues(ptr noundef byval(%struct.Node) align 8 %0, ptr nocapture noundef readonly byval(%struct.Node) align 8 %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readnone %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #2 {
  %8 = alloca %struct.Node, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %8) #4
  call void @clearNode(ptr noundef nonnull %8)
  %9 = getelementptr inbounds i8, ptr %8, i64 12
  store i32 %2, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %8, i64 16
  store i32 %3, ptr %10, align 8, !tbaa !11
  store ptr %0, ptr %8, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %0, i64 20
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = add nsw i32 %12, 1
  %14 = getelementptr inbounds i8, ptr %8, i64 20
  store i32 %13, ptr %14, align 4, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %1, i64 12
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = sub nsw i32 %16, %2
  %18 = sitofp i32 %17 to double
  %19 = call double @llvm.fabs.f64(double %18)
  %20 = fptosi double %19 to i32
  %21 = getelementptr inbounds i8, ptr %1, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = sub nsw i32 %22, %3
  %24 = sitofp i32 %23 to double
  %25 = call double @llvm.fabs.f64(double %24)
  %26 = fptosi double %25 to i32
  %27 = add nsw i32 %26, %20
  %28 = getelementptr inbounds i8, ptr %8, i64 24
  store i32 %27, ptr %28, align 8, !tbaa !14
  %29 = add nsw i32 %27, %13
  %30 = getelementptr inbounds i8, ptr %8, i64 28
  store i32 %29, ptr %30, align 4, !tbaa !15
  %31 = getelementptr inbounds i8, ptr %0, i64 12
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, i32 noundef %32, i32 noundef %34)
  call void @addListNode(ptr noundef %5, ptr noundef %6, ptr noundef nonnull byval(%struct.Node) align 8 %8, ptr noundef nonnull @.str.18)
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %8) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 12}
!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 16}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 20}
!14 = !{!6, !10, i64 24}
!15 = !{!6, !10, i64 28}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass