; LLVM IR from sgtlaugh/algovault :: code_library/dancing_links.ll (ZN3dlx10algorithmXEi)

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

@_ZN3dlx3rowE = external dso_local global [2000010 x i32], align 16
@_ZN3dlx3colE = external dso_local global [2000010 x i32], align 16
@_ZN3dlx1LE = external dso_local global [2000010 x i32], align 16
@_ZN3dlx1RE = external dso_local global [2000010 x i32], align 16
@_ZN3dlx1DE = external dso_local global [2000010 x i32], align 16
@_ZN3dlx3lenE = external dso_local global i32, align 4
@_ZN3dlx13selected_rowsE = external dso_local global [2000010 x i32], align 16
@_ZN3dlx12column_countE = external dso_local global [2000010 x i32], align 16

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3dlx10algorithmXEi(i32 noundef %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  store i32 %0, ptr %3, align 4, !tbaa !5
  %8 = load i32, ptr @_ZN3dlx1RE, align 16, !tbaa !5
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %1
  %11 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %11, ptr @_ZN3dlx3lenE, align 4, !tbaa !5
  store i1 true, ptr %2, align 1
  br label %117

12:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %13 = load i32, ptr @_ZN3dlx1RE, align 16, !tbaa !5
  store i32 %13, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr @_ZN3dlx1RE, align 16, !tbaa !5
  store i32 %14, ptr %4, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %31, %12
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %36

18:                                               ; preds = %15
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx12column_countE, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx12column_countE, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp slt i32 %22, %26
  br i1 %27, label %28, label %30

28:                                               ; preds = %18
  %29 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %29, ptr %6, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %28, %18
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1RE, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  store i32 %35, ptr %4, align 4, !tbaa !5
  br label %15, !llvm.loop !9

36:                                               ; preds = %15
  %37 = load i32, ptr %6, align 4, !tbaa !5
  call void @_ZN3dlx6removeEi(i32 noundef %37)
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !11
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1DE, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  store i32 %41, ptr %4, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %108, %36
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = icmp ne i32 %43, %44
  br i1 %45, label %46, label %50

46:                                               ; preds = %42
  %47 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %48 = trunc i8 %47 to i1
  %49 = xor i1 %48, true
  br label %50

50:                                               ; preds = %46, %42
  %51 = phi i1 [ false, %42 ], [ %49, %46 ]
  br i1 %51, label %52, label %113

52:                                               ; preds = %50
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx3rowE, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx13selected_rowsE, i64 0, i64 %58
  store i32 %56, ptr %59, align 4, !tbaa !5
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1RE, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  store i32 %63, ptr %5, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %73, %52
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = icmp ne i32 %65, %66
  br i1 %67, label %68, label %78

68:                                               ; preds = %64
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx3colE, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  call void @_ZN3dlx6removeEi(i32 noundef %72)
  br label %73

73:                                               ; preds = %68
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1RE, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  store i32 %77, ptr %5, align 4, !tbaa !5
  br label %64, !llvm.loop !15

78:                                               ; preds = %64
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  %81 = call noundef zeroext i1 @_ZN3dlx10algorithmXEi(i32 noundef %80)
  %82 = zext i1 %81 to i32
  %83 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %84 = trunc i8 %83 to i1
  %85 = zext i1 %84 to i32
  %86 = or i32 %85, %82
  %87 = icmp ne i32 %86, 0
  %88 = zext i1 %87 to i8
  store i8 %88, ptr %7, align 1, !tbaa !11
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1LE, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  store i32 %92, ptr %5, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %102, %78
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = icmp ne i32 %94, %95
  br i1 %96, label %97, label %107

97:                                               ; preds = %93
  %98 = load i32, ptr %5, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx3colE, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  call void @_ZN3dlx7restoreEi(i32 noundef %101)
  br label %102

102:                                              ; preds = %97
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1LE, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  store i32 %106, ptr %5, align 4, !tbaa !5
  br label %93, !llvm.loop !16

107:                                              ; preds = %93
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %4, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1DE, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  store i32 %112, ptr %4, align 4, !tbaa !5
  br label %42, !llvm.loop !17

113:                                              ; preds = %50
  %114 = load i32, ptr %6, align 4, !tbaa !5
  call void @_ZN3dlx7restoreEi(i32 noundef %114)
  %115 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %116 = trunc i8 %115 to i1
  store i1 %116, ptr %2, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %117

117:                                              ; preds = %113, %10
  %118 = load i1, ptr %2, align 1
  ret i1 %118
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3dlx6removeEi(i32 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3dlx7restoreEi(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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

@_ZN3dlx3rowE = external dso_local local_unnamed_addr global [2000010 x i32], align 16
@_ZN3dlx3colE = external dso_local local_unnamed_addr global [2000010 x i32], align 16
@_ZN3dlx1LE = external dso_local local_unnamed_addr global [2000010 x i32], align 16
@_ZN3dlx1RE = external dso_local local_unnamed_addr global [2000010 x i32], align 16
@_ZN3dlx1DE = external dso_local local_unnamed_addr global [2000010 x i32], align 16
@_ZN3dlx3lenE = external dso_local local_unnamed_addr global i32, align 4
@_ZN3dlx13selected_rowsE = external dso_local local_unnamed_addr global [2000010 x i32], align 16
@_ZN3dlx12column_countE = external dso_local local_unnamed_addr global [2000010 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN3dlx10algorithmXEi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @_ZN3dlx1RE, align 16, !tbaa !5
  %3 = icmp eq i32 %2, 0
  br i1 %3, label %4, label %.preheader

4:                                                ; preds = %1
  store i32 %0, ptr @_ZN3dlx3lenE, align 4, !tbaa !5
  br label %32

.preheader:                                       ; preds = %1, %.preheader
  %.02842 = phi i32 [ %spec.select, %.preheader ], [ %2, %1 ]
  %.03141 = phi i32 [ %13, %.preheader ], [ %2, %1 ]
  %5 = sext i32 %.03141 to i64
  %6 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx12column_countE, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = sext i32 %.02842 to i64
  %9 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx12column_countE, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = icmp slt i32 %7, %10
  %spec.select = select i1 %11, i32 %.03141, i32 %.02842
  %12 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1RE, i64 0, i64 %5
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %14, label %.preheader, !llvm.loop !9

14:                                               ; preds = %.preheader
  tail call void @_ZN3dlx6removeEi(i32 noundef %spec.select)
  %15 = sext i32 %spec.select to i64
  %.132.in53 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1DE, i64 0, i64 %15
  %.13254 = load i32, ptr %.132.in53, align 4, !tbaa !5
  %16 = icmp eq i32 %.13254, %spec.select
  br i1 %16, label %._crit_edge59, label %.lr.ph58

.lr.ph58:                                         ; preds = %14
  %17 = sext i32 %0 to i64
  %18 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx13selected_rowsE, i64 0, i64 %17
  %19 = add nsw i32 %0, 1
  br label %21

.loopexit:                                        ; preds = %.lr.ph52, %._crit_edge
  %.132.in = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1DE, i64 0, i64 %22
  %.132 = load i32, ptr %.132.in, align 4, !tbaa !5
  %20 = icmp eq i32 %.132, %spec.select
  %.not36 = or i1 %20, %28
  br i1 %.not36, label %._crit_edge59, label %21, !llvm.loop !11

21:                                               ; preds = %.lr.ph58, %.loopexit
  %.13256 = phi i32 [ %.13254, %.lr.ph58 ], [ %.132, %.loopexit ]
  %22 = sext i32 %.13256 to i64
  %23 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx3rowE, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %18, align 4, !tbaa !5
  %.029.in43 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1RE, i64 0, i64 %22
  %.02944 = load i32, ptr %.029.in43, align 4, !tbaa !5
  %.not3845 = icmp eq i32 %.02944, %.13256
  br i1 %.not3845, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %21, %.lr.ph
  %.02946 = phi i32 [ %.029, %.lr.ph ], [ %.02944, %21 ]
  %25 = sext i32 %.02946 to i64
  %26 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx3colE, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  tail call void @_ZN3dlx6removeEi(i32 noundef %27)
  %.029.in = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1RE, i64 0, i64 %25
  %.029 = load i32, ptr %.029.in, align 4, !tbaa !5
  %.not38 = icmp eq i32 %.029, %.13256
  br i1 %.not38, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %21
  %28 = tail call noundef zeroext i1 @_ZN3dlx10algorithmXEi(i32 noundef %19)
  %.130.in47 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1LE, i64 0, i64 %22
  %.13048 = load i32, ptr %.130.in47, align 4, !tbaa !5
  %.not4049 = icmp eq i32 %.13048, %.13256
  br i1 %.not4049, label %.loopexit, label %.lr.ph52

.lr.ph52:                                         ; preds = %._crit_edge, %.lr.ph52
  %.13050 = phi i32 [ %.130, %.lr.ph52 ], [ %.13048, %._crit_edge ]
  %29 = sext i32 %.13050 to i64
  %30 = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx3colE, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  tail call void @_ZN3dlx7restoreEi(i32 noundef %31)
  %.130.in = getelementptr inbounds [2000010 x i32], ptr @_ZN3dlx1LE, i64 0, i64 %29
  %.130 = load i32, ptr %.130.in, align 4, !tbaa !5
  %.not40 = icmp eq i32 %.130, %.13256
  br i1 %.not40, label %.loopexit, label %.lr.ph52, !llvm.loop !13

._crit_edge59:                                    ; preds = %.loopexit, %14
  %.0.lcssa = phi i1 [ false, %14 ], [ %28, %.loopexit ]
  tail call void @_ZN3dlx7restoreEi(i32 noundef %spec.select)
  br label %32

32:                                               ; preds = %._crit_edge59, %4
  %.033 = phi i1 [ true, %4 ], [ %.0.lcssa, %._crit_edge59 ]
  ret i1 %.033
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3dlx6removeEi(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3dlx7restoreEi(i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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