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

; 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) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @addListNode(ptr noundef %0, ptr noundef %1, ptr noundef byval(%struct.Node) align 8 %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %3, ptr %7, align 8, !tbaa !5
  %8 = load i32, ptr @size, align 4, !tbaa !9
  %9 = zext i32 %8 to i64
  %10 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %24

13:                                               ; preds = %4
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = getelementptr inbounds %struct.Node, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds %struct.Node, ptr %20, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %14, i32 noundef %18, i32 noundef %22)
  br label %24

24:                                               ; preds = %13, %4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 3
  %27 = load i32, ptr %26, align 8, !tbaa !15
  %28 = sext i32 %27 to i64
  %29 = mul nsw i64 %28, %9
  %30 = getelementptr inbounds %struct.Node, ptr %25, i64 %29
  %31 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.Node, ptr %30, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 8 %2, i64 40, i1 false), !tbaa.struct !16
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 3
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = sext i32 %37 to i64
  %39 = mul nsw i64 %38, %9
  %40 = getelementptr inbounds %struct.Node, ptr %35, i64 %39
  %41 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !14
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %struct.Node, ptr %40, i64 %43
  %45 = getelementptr inbounds %struct.Node, ptr %44, i32 0, i32 1
  store i32 1, ptr %45, align 8, !tbaa !18
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !17
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 3
  %50 = load i32, ptr %49, align 8, !tbaa !15
  %51 = sext i32 %50 to i64
  %52 = mul nsw i64 %51, %9
  %53 = getelementptr inbounds %struct.Node, ptr %48, i64 %52
  %54 = getelementptr inbounds %struct.Node, ptr %2, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !14
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds %struct.Node, ptr %53, i64 %56
  %58 = getelementptr inbounds %struct.Node, ptr %57, i32 0, i32 7
  store i32 %47, ptr %58, align 8, !tbaa !19
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = load i32, ptr %59, align 4, !tbaa !17
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %59, align 4, !tbaa !17
  ret void
}

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

!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 = !{!"GridSize", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"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}
!14 = !{!13, !11, i64 12}
!15 = !{!13, !11, i64 16}
!16 = !{i64 0, i64 8, !5, i64 8, i64 4, !17, i64 12, i64 4, !17, i64 16, i64 4, !17, i64 20, i64 4, !17, i64 24, i64 4, !17, i64 28, i64 4, !17, i64 32, i64 4, !17}
!17 = !{!11, !11, i64 0}
!18 = !{!13, !11, i64 8}
!19 = !{!13, !11, i64 32}


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

; 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) #0

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @addListNode(ptr nocapture noundef writeonly %0, ptr nocapture noundef %1, ptr nocapture noundef readonly byval(%struct.Node) align 8 %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = load i32, ptr @size, align 4, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !10
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %13, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %6, i64 12
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %6, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %3, i32 noundef %9, i32 noundef %11)
  br label %13

13:                                               ; preds = %7, %4
  %14 = zext i32 %5 to i64
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  %16 = load i32, ptr %15, align 8, !tbaa !14
  %17 = sext i32 %16 to i64
  %18 = mul nsw i64 %17, %14
  %19 = getelementptr inbounds %struct.Node, ptr %0, i64 %18
  %20 = getelementptr inbounds i8, ptr %2, i64 12
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %struct.Node, ptr %19, i64 %22
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %23, ptr noundef nonnull align 8 dereferenceable(40) %2, i64 40, i1 false), !tbaa.struct !15
  %24 = getelementptr inbounds %struct.Node, ptr %19, i64 %22, i32 1
  store i32 1, ptr %24, align 8, !tbaa !18
  %25 = load i32, ptr %1, align 4, !tbaa !17
  %26 = getelementptr inbounds %struct.Node, ptr %19, i64 %22, i32 7
  store i32 %25, ptr %26, align 8, !tbaa !19
  %27 = add nsw i32 %25, 1
  store i32 %27, ptr %1, align 4, !tbaa !17
  ret void
}

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

!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 = !{!11, !12, i64 0}
!11 = !{!"Node", !12, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!11, !7, i64 12}
!14 = !{!11, !7, i64 16}
!15 = !{i64 0, i64 8, !16, i64 8, i64 4, !17, i64 12, i64 4, !17, i64 16, i64 4, !17, i64 20, i64 4, !17, i64 24, i64 4, !17, i64 28, i64 4, !17, i64 32, i64 4, !17}
!16 = !{!12, !12, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!11, !7, i64 8}
!19 = !{!11, !7, i64 32}


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