; LLVM IR from alexzheng42/sDMD :: src (ToolFunctions)

; 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.ConstraintStr = type { i32, double, ptr, double, ptr }
%struct.StepPotenStr = type { double, double, double, ptr }

@potentialPairHB = external global [12 x [33 x [33 x %struct.ConstraintStr]]], align 16
@.str.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [7 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
declare double @sqrt(double noundef) #2

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

7:                                                ; preds = %108, %1
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp sle i32 %8, 32
  br i1 %9, label %11, label %10

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

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %104, %11
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = icmp sle i32 %13, 32
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %107

16:                                               ; preds = %12
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [12 x [33 x [33 x %struct.ConstraintStr]]], ptr @potentialPairHB, i64 0, i64 %18
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr %19, i64 0, i64 %21
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %22, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.ConstraintStr, ptr %25, i32 0, i32 1
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fcmp une double %27, 0.000000e+00
  br i1 %28, label %29, label %103

29:                                               ; preds = %16
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [12 x [33 x [33 x %struct.ConstraintStr]]], ptr @potentialPairHB, i64 0, i64 %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr %34, i64 0, i64 %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %37, i64 0, i64 %39
  %41 = getelementptr inbounds %struct.ConstraintStr, ptr %40, i32 0, i32 1
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = call double @sqrt(double noundef %42) #4
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.40, i32 noundef %30, i32 noundef %31, double noundef %43)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [12 x [33 x [33 x %struct.ConstraintStr]]], ptr @potentialPairHB, i64 0, i64 %46
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr %47, i64 0, i64 %49
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %50, i64 0, i64 %52
  %54 = getelementptr inbounds %struct.ConstraintStr, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  store ptr %55, ptr %6, align 8, !tbaa !14
  br label %56

56:                                               ; preds = %59, %29
  %57 = load ptr, ptr %6, align 8, !tbaa !14
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %74

59:                                               ; preds = %56
  %60 = load ptr, ptr %6, align 8, !tbaa !14
  %61 = getelementptr inbounds %struct.StepPotenStr, ptr %60, i32 0, i32 0
  %62 = load double, ptr %61, align 8, !tbaa !15
  %63 = call double @sqrt(double noundef %62) #4
  %64 = load ptr, ptr %6, align 8, !tbaa !14
  %65 = getelementptr inbounds %struct.StepPotenStr, ptr %64, i32 0, i32 1
  %66 = load double, ptr %65, align 8, !tbaa !17
  %67 = load ptr, ptr %6, align 8, !tbaa !14
  %68 = getelementptr inbounds %struct.StepPotenStr, ptr %67, i32 0, i32 2
  %69 = load double, ptr %68, align 8, !tbaa !18
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.41, double noundef %63, double noundef %66, double noundef %69)
  %71 = load ptr, ptr %6, align 8, !tbaa !14
  %72 = getelementptr inbounds %struct.StepPotenStr, ptr %71, i32 0, i32 3
  %73 = load ptr, ptr %72, align 8, !tbaa !19
  store ptr %73, ptr %6, align 8, !tbaa !14
  br label %56, !llvm.loop !20

74:                                               ; preds = %56
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [12 x [33 x [33 x %struct.ConstraintStr]]], ptr @potentialPairHB, i64 0, i64 %76
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr %77, i64 0, i64 %79
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %80, i64 0, i64 %82
  %84 = getelementptr inbounds %struct.ConstraintStr, ptr %83, i32 0, i32 3
  %85 = load double, ptr %84, align 8, !tbaa !22
  %86 = fcmp ogt double %85, 0.000000e+00
  br i1 %86, label %87, label %101

87:                                               ; preds = %74
  %88 = load i32, ptr %2, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [12 x [33 x [33 x %struct.ConstraintStr]]], ptr @potentialPairHB, i64 0, i64 %89
  %91 = load i32, ptr %3, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr %90, i64 0, i64 %92
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %93, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.ConstraintStr, ptr %96, i32 0, i32 3
  %98 = load double, ptr %97, align 8, !tbaa !22
  %99 = call double @sqrt(double noundef %98) #4
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.42, double noundef %99)
  br label %101

101:                                              ; preds = %87, %74
  %102 = call i32 (ptr, ...) @printf(ptr noundef @.str.39)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %103

103:                                              ; preds = %101, %16
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %5, align 4, !tbaa !5
  br label %12, !llvm.loop !23

107:                                              ; preds = %15
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %3, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !24

111:                                              ; preds = %10
  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 "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 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 #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, !11, i64 8}
!10 = !{!"ConstraintStr", !6, i64 0, !11, i64 8, !12, i64 16, !11, i64 24, !12, i64 32}
!11 = !{!"double", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !12, i64 16}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !11, i64 0}
!16 = !{!"StepPotenStr", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24}
!17 = !{!16, !11, i64 8}
!18 = !{!16, !11, i64 16}
!19 = !{!16, !12, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!10, !11, i64 24}
!23 = distinct !{!23, !21}
!24 = distinct !{!24, !21}


; 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.ConstraintStr = type { i32, double, ptr, double, ptr }

@potentialPairHB = external local_unnamed_addr global [12 x [33 x [33 x %struct.ConstraintStr]]], align 16
@.str.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind uwtable
define dso_local void @PrintHBPotentialTable(i32 noundef %0) local_unnamed_addr #2 {
  %2 = sext i32 %0 to i64
  br label %.preheader

.preheader:                                       ; preds = %1, %5
  %indvars.iv35 = phi i64 [ 0, %1 ], [ %indvars.iv.next36, %5 ]
  %3 = trunc nuw nsw i64 %indvars.iv35 to i32
  br label %6

4:                                                ; preds = %5
  ret void

5:                                                ; preds = %32
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %exitcond38.not = icmp eq i64 %indvars.iv.next36, 33
  br i1 %exitcond38.not, label %4, label %.preheader, !llvm.loop !5

6:                                                ; preds = %.preheader, %32
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %32 ]
  %7 = getelementptr inbounds [12 x [33 x [33 x %struct.ConstraintStr]]], ptr @potentialPairHB, i64 0, i64 %2, i64 %indvars.iv35, i64 %indvars.iv
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !7
  %10 = fcmp une double %9, 0.000000e+00
  br i1 %10, label %11, label %32

11:                                               ; preds = %6
  %12 = tail call double @sqrt(double noundef %9) #3
  %13 = trunc nuw nsw i64 %indvars.iv to i32
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.40, i32 noundef %3, i32 noundef %13, double noundef %12)
  %15 = getelementptr inbounds i8, ptr %7, i64 16
  %.029 = load ptr, ptr %15, align 8, !tbaa !14
  %.not30 = icmp eq ptr %.029, null
  br i1 %.not30, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %.lr.ph
  %.031 = phi ptr [ %.0, %.lr.ph ], [ %.029, %11 ]
  %16 = load double, ptr %.031, align 8, !tbaa !15
  %17 = tail call double @sqrt(double noundef %16) #3
  %18 = getelementptr inbounds i8, ptr %.031, i64 8
  %19 = load double, ptr %18, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %.031, i64 16
  %21 = load double, ptr %20, align 8, !tbaa !18
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.41, double noundef %17, double noundef %19, double noundef %21)
  %23 = getelementptr inbounds i8, ptr %.031, i64 24
  %.0 = load ptr, ptr %23, align 8, !tbaa !14
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %11
  %24 = getelementptr inbounds i8, ptr %7, i64 24
  %25 = load double, ptr %24, align 8, !tbaa !20
  %26 = fcmp ogt double %25, 0.000000e+00
  br i1 %26, label %27, label %30

27:                                               ; preds = %._crit_edge
  %28 = tail call double @sqrt(double noundef %25) #3
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.42, double noundef %28)
  br label %30

30:                                               ; preds = %27, %._crit_edge
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.39)
  br label %32

32:                                               ; preds = %6, %30
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 33
  br i1 %exitcond.not, label %5, label %6, !llvm.loop !21
}

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 = { mustprogress nofree nounwind willreturn memory(write) "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" }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !12, i64 8}
!8 = !{!"ConstraintStr", !9, i64 0, !12, i64 8, !13, i64 16, !12, i64 24, !13, i64 32}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"double", !10, i64 0}
!13 = !{!"any pointer", !10, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !12, i64 0}
!16 = !{!"StepPotenStr", !12, i64 0, !12, i64 8, !12, i64 16, !13, i64 24}
!17 = !{!16, !12, i64 8}
!18 = !{!16, !12, i64 16}
!19 = distinct !{!19, !6}
!20 = !{!8, !12, i64 24}
!21 = distinct !{!21, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass