; 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.9 = external hidden unnamed_addr constant [49 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
define dso_local void @printNodeInfo(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load i32, ptr @size, align 4, !tbaa !9
  %6 = zext i32 %5 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %7

7:                                                ; preds = %101, %1
  %8 = load i32, ptr %3, align 4, !tbaa !12
  %9 = load i32, ptr getelementptr inbounds (%struct.GridSize, ptr @size, i32 0, i32 1), align 4, !tbaa !13
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %11, label %104

11:                                               ; preds = %7
  store i32 0, ptr %4, align 4, !tbaa !12
  br label %12

12:                                               ; preds = %97, %11
  %13 = load i32, ptr %4, align 4, !tbaa !12
  %14 = load i32, ptr @size, align 4, !tbaa !9
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %100

16:                                               ; preds = %12
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !12
  %19 = sext i32 %18 to i64
  %20 = mul nsw i64 %19, %6
  %21 = getelementptr inbounds %struct.Node, ptr %17, i64 %20
  %22 = load i32, ptr %4, align 4, !tbaa !12
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.Node, ptr %21, i64 %23
  %25 = getelementptr inbounds %struct.Node, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 8, !tbaa !14
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %96

28:                                               ; preds = %16
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !12
  %31 = sext i32 %30 to i64
  %32 = mul nsw i64 %31, %6
  %33 = getelementptr inbounds %struct.Node, ptr %29, i64 %32
  %34 = load i32, ptr %4, align 4, !tbaa !12
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds %struct.Node, ptr %33, i64 %35
  %37 = getelementptr inbounds %struct.Node, ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !16
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = load i32, ptr %3, align 4, !tbaa !12
  %41 = sext i32 %40 to i64
  %42 = mul nsw i64 %41, %6
  %43 = getelementptr inbounds %struct.Node, ptr %39, i64 %42
  %44 = load i32, ptr %4, align 4, !tbaa !12
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.Node, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.Node, ptr %46, i32 0, i32 3
  %48 = load i32, ptr %47, align 8, !tbaa !17
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = load i32, ptr %3, align 4, !tbaa !12
  %51 = sext i32 %50 to i64
  %52 = mul nsw i64 %51, %6
  %53 = getelementptr inbounds %struct.Node, ptr %49, i64 %52
  %54 = load i32, ptr %4, align 4, !tbaa !12
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds %struct.Node, ptr %53, i64 %55
  %57 = getelementptr inbounds %struct.Node, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !14
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !12
  %61 = sext i32 %60 to i64
  %62 = mul nsw i64 %61, %6
  %63 = getelementptr inbounds %struct.Node, ptr %59, i64 %62
  %64 = load i32, ptr %4, align 4, !tbaa !12
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %struct.Node, ptr %63, i64 %65
  %67 = getelementptr inbounds %struct.Node, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = getelementptr inbounds %struct.Node, ptr %68, i32 0, i32 2
  %70 = load i32, ptr %69, align 4, !tbaa !16
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = load i32, ptr %3, align 4, !tbaa !12
  %73 = sext i32 %72 to i64
  %74 = mul nsw i64 %73, %6
  %75 = getelementptr inbounds %struct.Node, ptr %71, i64 %74
  %76 = load i32, ptr %4, align 4, !tbaa !12
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.Node, ptr %75, i64 %77
  %79 = getelementptr inbounds %struct.Node, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !18
  %81 = getelementptr inbounds %struct.Node, ptr %80, i32 0, i32 3
  %82 = load i32, ptr %81, align 8, !tbaa !17
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = load i32, ptr %3, align 4, !tbaa !12
  %85 = sext i32 %84 to i64
  %86 = mul nsw i64 %85, %6
  %87 = getelementptr inbounds %struct.Node, ptr %83, i64 %86
  %88 = load i32, ptr %4, align 4, !tbaa !12
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds %struct.Node, ptr %87, i64 %89
  %91 = getelementptr inbounds %struct.Node, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !18
  %93 = getelementptr inbounds %struct.Node, ptr %92, i32 0, i32 1
  %94 = load i32, ptr %93, align 8, !tbaa !14
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %38, i32 noundef %48, i32 noundef %58, i32 noundef %70, i32 noundef %82, i32 noundef %94)
  br label %96

96:                                               ; preds = %28, %16
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %4, align 4, !tbaa !12
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %4, align 4, !tbaa !12
  br label %12, !llvm.loop !19

100:                                              ; preds = %12
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %3, align 4, !tbaa !12
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %3, align 4, !tbaa !12
  br label %7, !llvm.loop !21

104:                                              ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

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 = { 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 0}
!10 = !{!"GridSize", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!15, !11, i64 8}
!15 = !{!"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}
!16 = !{!15, !11, i64 12}
!17 = !{!15, !11, i64 16}
!18 = !{!15, !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @printNodeInfo(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = load i32, ptr @size, align 4, !tbaa !5
  %3 = zext i32 %2 to i64
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @size, i64 4), align 4, !tbaa !10
  %5 = icmp sgt i32 %4, 0
  %6 = icmp sgt i32 %2, 0
  %or.cond = select i1 %5, i1 %6, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge28

.preheader:                                       ; preds = %1, %._crit_edge
  %7 = phi i32 [ %36, %._crit_edge ], [ %4, %1 ]
  %8 = phi i32 [ %37, %._crit_edge ], [ %2, %1 ]
  %9 = phi i32 [ %38, %._crit_edge ], [ %2, %1 ]
  %indvars.iv31 = phi i64 [ %indvars.iv.next32, %._crit_edge ], [ 0, %1 ]
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %11 = mul nuw nsw i64 %indvars.iv31, %3
  %12 = getelementptr inbounds %struct.Node, ptr %0, i64 %11
  br label %13

13:                                               ; preds = %.lr.ph, %32
  %14 = phi i32 [ %8, %.lr.ph ], [ %33, %32 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %32 ]
  %15 = getelementptr inbounds %struct.Node, ptr %12, i64 %indvars.iv
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %32

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %15, i64 12
  %21 = load i32, ptr %20, align 4, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %15, i64 16
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = load ptr, ptr %15, align 8, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %24, i64 12
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %24, i64 16
  %28 = load i32, ptr %27, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %24, i64 8
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %21, i32 noundef %23, i32 noundef 1, i32 noundef %26, i32 noundef %28, i32 noundef %30)
  %.pre = load i32, ptr @size, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %13, %19
  %33 = phi i32 [ %14, %13 ], [ %.pre, %19 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next, %34
  br i1 %35, label %13, label %._crit_edge.loopexit, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %32
  %.pre34 = load i32, ptr getelementptr inbounds (i8, ptr @size, i64 4), align 4, !tbaa !10
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %36 = phi i32 [ %.pre34, %._crit_edge.loopexit ], [ %7, %.preheader ]
  %37 = phi i32 [ %33, %._crit_edge.loopexit ], [ %8, %.preheader ]
  %38 = phi i32 [ %33, %._crit_edge.loopexit ], [ %9, %.preheader ]
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %39 = sext i32 %36 to i64
  %40 = icmp slt i64 %indvars.iv.next32, %39
  br i1 %40, label %.preheader, label %._crit_edge28, !llvm.loop !19

._crit_edge28:                                    ; preds = %._crit_edge, %1
  ret void
}

attributes #0 = { 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 #1 = { 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 = !{!6, !7, i64 4}
!11 = !{!12, !7, i64 8}
!12 = !{!"Node", !13, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!12, !7, i64 12}
!15 = !{!12, !7, i64 16}
!16 = !{!12, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18, !20}
!20 = !{!"llvm.loop.unswitch.partial.disable"}


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