; LLVM IR from totte174/minesolve :: src (equations)

; 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.EquationSet = type { [1024 x %struct.Equation], i32, [192 x i32], [192 x i32], i32, %struct.Mask, %struct.Mask }
%struct.Equation = type { %struct.Mask, i32 }
%struct.Mask = type { [3 x i64] }

; 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: nounwind uwtable
declare dso_local zeroext i1 @is_subequation(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @remove_subequation(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @remove_subequations(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  store i8 0, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %10

10:                                               ; preds = %127, %1
  %11 = load i32, ptr %4, align 4, !tbaa !11
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.EquationSet, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = icmp slt i32 %11, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %130

17:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %18 = load i32, ptr %4, align 4, !tbaa !11
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %6, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %123, %17
  %21 = load i32, ptr %6, align 4, !tbaa !11
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.EquationSet, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !13
  %25 = icmp slt i32 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %126

27:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %58, %27
  %29 = load i32, ptr %8, align 4, !tbaa !11
  %30 = icmp slt i32 %29, 3
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %61

32:                                               ; preds = %28
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.EquationSet, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %8, align 4, !tbaa !11
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1024 x %struct.Equation], ptr %34, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.Equation, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.Mask, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [3 x i64], ptr %39, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !16
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.EquationSet, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %6, align 4, !tbaa !11
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1024 x %struct.Equation], ptr %45, i64 0, i64 %47
  %49 = getelementptr inbounds %struct.Equation, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.Mask, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %8, align 4, !tbaa !11
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [3 x i64], ptr %50, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !16
  %55 = and i64 %43, %54
  %56 = load i64, ptr %7, align 8, !tbaa !16
  %57 = or i64 %56, %55
  store i64 %57, ptr %7, align 8, !tbaa !16
  br label %58

58:                                               ; preds = %32
  %59 = load i32, ptr %8, align 4, !tbaa !11
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %8, align 4, !tbaa !11
  br label %28, !llvm.loop !18

61:                                               ; preds = %31
  %62 = load i64, ptr %7, align 8, !tbaa !16
  %63 = icmp ne i64 %62, 0
  %64 = zext i1 %63 to i8
  store i8 %64, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  %65 = load i8, ptr %9, align 1, !tbaa !9, !range !20, !noundef !21
  %66 = trunc i8 %65 to i1
  br i1 %66, label %67, label %122

67:                                               ; preds = %61
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.EquationSet, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds [1024 x %struct.Equation], ptr %69, i64 0, i64 0
  %71 = load i32, ptr %4, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.Equation, ptr %70, i64 %72
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.EquationSet, ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds [1024 x %struct.Equation], ptr %75, i64 0, i64 0
  %77 = load i32, ptr %6, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds %struct.Equation, ptr %76, i64 %78
  %80 = call zeroext i1 @is_subequation(ptr noundef %73, ptr noundef %79)
  br i1 %80, label %81, label %94

81:                                               ; preds = %67
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.EquationSet, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds [1024 x %struct.Equation], ptr %83, i64 0, i64 0
  %85 = load i32, ptr %4, align 4, !tbaa !11
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds %struct.Equation, ptr %84, i64 %86
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.EquationSet, ptr %88, i32 0, i32 0
  %90 = getelementptr inbounds [1024 x %struct.Equation], ptr %89, i64 0, i64 0
  %91 = load i32, ptr %6, align 4, !tbaa !11
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds %struct.Equation, ptr %90, i64 %92
  call void @remove_subequation(ptr noundef %87, ptr noundef %93)
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %94

94:                                               ; preds = %81, %67
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.EquationSet, ptr %95, i32 0, i32 0
  %97 = getelementptr inbounds [1024 x %struct.Equation], ptr %96, i64 0, i64 0
  %98 = load i32, ptr %6, align 4, !tbaa !11
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds %struct.Equation, ptr %97, i64 %99
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.EquationSet, ptr %101, i32 0, i32 0
  %103 = getelementptr inbounds [1024 x %struct.Equation], ptr %102, i64 0, i64 0
  %104 = load i32, ptr %4, align 4, !tbaa !11
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.Equation, ptr %103, i64 %105
  %107 = call zeroext i1 @is_subequation(ptr noundef %100, ptr noundef %106)
  br i1 %107, label %108, label %121

108:                                              ; preds = %94
  %109 = load ptr, ptr %2, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.EquationSet, ptr %109, i32 0, i32 0
  %111 = getelementptr inbounds [1024 x %struct.Equation], ptr %110, i64 0, i64 0
  %112 = load i32, ptr %6, align 4, !tbaa !11
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds %struct.Equation, ptr %111, i64 %113
  %115 = load ptr, ptr %2, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.EquationSet, ptr %115, i32 0, i32 0
  %117 = getelementptr inbounds [1024 x %struct.Equation], ptr %116, i64 0, i64 0
  %118 = load i32, ptr %4, align 4, !tbaa !11
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds %struct.Equation, ptr %117, i64 %119
  call void @remove_subequation(ptr noundef %114, ptr noundef %120)
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %121

121:                                              ; preds = %108, %94
  br label %122

122:                                              ; preds = %121, %61
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %6, align 4, !tbaa !11
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %6, align 4, !tbaa !11
  br label %20, !llvm.loop !22

126:                                              ; preds = %26
  br label %127

127:                                              ; preds = %126
  %128 = load i32, ptr %4, align 4, !tbaa !11
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %4, align 4, !tbaa !11
  br label %10, !llvm.loop !23

130:                                              ; preds = %16
  %131 = load i8, ptr %3, align 1, !tbaa !9, !range !20, !noundef !21
  %132 = trunc i8 %131 to i1
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  ret i1 %132
}

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 }

!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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 32768}
!14 = !{!"EquationSet", !7, i64 0, !12, i64 32768, !7, i64 32772, !7, i64 33540, !12, i64 34308, !15, i64 34312, !15, i64 34336}
!15 = !{!"Mask", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !19}
!23 = distinct !{!23, !19}


; 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.Equation = type { %struct.Mask, i32 }
%struct.Mask = type { [3 x i64] }

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @is_subequation(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @remove_subequations(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32768
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  br label %.lr.ph

.loopexit.loopexit:                               ; preds = %33
  %.pre = sext i32 %34 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph
  %.pre-phi = phi i64 [ %.pre, %.loopexit.loopexit ], [ %10, %.lr.ph ]
  %7 = phi i32 [ %34, %.loopexit.loopexit ], [ %9, %.lr.ph ]
  %.1.lcssa = phi i1 [ %.3, %.loopexit.loopexit ], [ %.043, %.lr.ph ]
  %8 = icmp slt i64 %indvars.iv.next49, %.pre-phi
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %8, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.loopexit, %1
  %.0.lcssa = phi i1 [ false, %1 ], [ %.1.lcssa, %.loopexit ]
  ret i1 %.0.lcssa

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.loopexit
  %9 = phi i32 [ %3, %.lr.ph.preheader ], [ %7, %.loopexit ]
  %indvars.iv48 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next49, %.loopexit ]
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.loopexit ]
  %.043 = phi i1 [ false, %.lr.ph.preheader ], [ %.1.lcssa, %.loopexit ]
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %10 = sext i32 %9 to i64
  %11 = icmp slt i64 %indvars.iv.next49, %10
  br i1 %11, label %.preheader.lr.ph, label %.loopexit

.preheader.lr.ph:                                 ; preds = %.lr.ph
  %12 = getelementptr inbounds %struct.Equation, ptr %0, i64 %indvars.iv48
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %33
  %indvars.iv46 = phi i64 [ %indvars.iv, %.preheader.lr.ph ], [ %indvars.iv.next47, %33 ]
  %.141 = phi i1 [ %.043, %.preheader.lr.ph ], [ %.3, %33 ]
  %13 = getelementptr inbounds [1024 x %struct.Equation], ptr %0, i64 0, i64 %indvars.iv46
  %14 = load i64, ptr %0, align 8, !tbaa !13
  %15 = load i64, ptr %13, align 8, !tbaa !13
  %16 = and i64 %15, %14
  %17 = load i64, ptr %5, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %13, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %20 = and i64 %19, %17
  %21 = or i64 %20, %16
  %22 = load i64, ptr %6, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %13, i64 16
  %24 = load i64, ptr %23, align 8, !tbaa !13
  %25 = and i64 %24, %22
  %26 = or i64 %25, %21
  %.not = icmp eq i64 %26, 0
  br i1 %.not, label %33, label %27

27:                                               ; preds = %.preheader
  %28 = tail call zeroext i1 @is_subequation(ptr noundef nonnull %12, ptr noundef nonnull %13)
  br i1 %28, label %29, label %30

29:                                               ; preds = %27
  tail call void @remove_subequation(ptr noundef nonnull %12, ptr noundef nonnull %13)
  br label %30

30:                                               ; preds = %29, %27
  %.2 = phi i1 [ true, %29 ], [ %.141, %27 ]
  %31 = tail call zeroext i1 @is_subequation(ptr noundef nonnull %13, ptr noundef nonnull %12)
  br i1 %31, label %32, label %33

32:                                               ; preds = %30
  tail call void @remove_subequation(ptr noundef nonnull %13, ptr noundef nonnull %12)
  br label %33

33:                                               ; preds = %.preheader, %32, %30
  %.3 = phi i1 [ true, %32 ], [ %.2, %30 ], [ %.141, %.preheader ]
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %34 = load i32, ptr %2, align 8, !tbaa !5
  %35 = trunc nuw i64 %indvars.iv.next47 to i32
  %36 = icmp sgt i32 %34, %35
  br i1 %36, label %.preheader, label %.loopexit.loopexit, !llvm.loop !15
}

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

!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, !9, i64 32768}
!6 = !{!"EquationSet", !7, i64 0, !9, i64 32768, !7, i64 32772, !7, i64 33540, !9, i64 34308, !10, i64 34312, !10, i64 34336}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"Mask", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !12}


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