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

@potentialPairCollision = external global [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

; 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 @PrintCollisionPotentialTable() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %70, %0
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp sle i32 %6, 32
  br i1 %7, label %9, label %8

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

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %66, %9
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp sle i32 %11, 32
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %10
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %16
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %17, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.ConstraintStr, ptr %20, i32 0, i32 1
  %22 = load double, ptr %21, align 8, !tbaa !9
  %23 = fcmp une double %22, 0.000000e+00
  br i1 %23, label %24, label %65

24:                                               ; preds = %14
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %29, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.ConstraintStr, ptr %32, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = call double @sqrt(double noundef %34) #4
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.40, i32 noundef %25, i32 noundef %26, double noundef %35)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %38
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %39, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.ConstraintStr, ptr %42, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  store ptr %44, ptr %4, align 8, !tbaa !14
  br label %45

45:                                               ; preds = %48, %24
  %46 = load ptr, ptr %4, align 8, !tbaa !14
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %63

48:                                               ; preds = %45
  %49 = load ptr, ptr %4, align 8, !tbaa !14
  %50 = getelementptr inbounds %struct.StepPotenStr, ptr %49, i32 0, i32 0
  %51 = load double, ptr %50, align 8, !tbaa !15
  %52 = call double @sqrt(double noundef %51) #4
  %53 = load ptr, ptr %4, align 8, !tbaa !14
  %54 = getelementptr inbounds %struct.StepPotenStr, ptr %53, i32 0, i32 1
  %55 = load double, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %4, align 8, !tbaa !14
  %57 = getelementptr inbounds %struct.StepPotenStr, ptr %56, i32 0, i32 2
  %58 = load double, ptr %57, align 8, !tbaa !18
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.41, double noundef %52, double noundef %55, double noundef %58)
  %60 = load ptr, ptr %4, align 8, !tbaa !14
  %61 = getelementptr inbounds %struct.StepPotenStr, ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  store ptr %62, ptr %4, align 8, !tbaa !14
  br label %45, !llvm.loop !20

63:                                               ; preds = %45
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.39)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %65

65:                                               ; preds = %63, %14
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !22

69:                                               ; preds = %13
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %1, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %1, align 4, !tbaa !5
  br label %5, !llvm.loop !23

73:                                               ; preds = %8
  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 = distinct !{!22, !21}
!23 = distinct !{!23, !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 }

@potentialPairCollision = external local_unnamed_addr global [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

; 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 @PrintCollisionPotentialTable() local_unnamed_addr #2 {
  br label %.preheader

.preheader:                                       ; preds = %0, %3
  %indvars.iv25 = phi i64 [ 1, %0 ], [ %indvars.iv.next26, %3 ]
  %1 = trunc nuw nsw i64 %indvars.iv25 to i32
  br label %4

2:                                                ; preds = %3
  ret void

3:                                                ; preds = %23
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %exitcond28.not = icmp eq i64 %indvars.iv.next26, 33
  br i1 %exitcond28.not, label %2, label %.preheader, !llvm.loop !5

4:                                                ; preds = %.preheader, %23
  %indvars.iv = phi i64 [ 1, %.preheader ], [ %indvars.iv.next, %23 ]
  %5 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %indvars.iv25, i64 %indvars.iv
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !7
  %8 = fcmp une double %7, 0.000000e+00
  br i1 %8, label %9, label %23

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

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.021 = phi ptr [ %.0, %.lr.ph ], [ %.019, %9 ]
  %14 = load double, ptr %.021, align 8, !tbaa !15
  %15 = tail call double @sqrt(double noundef %14) #3
  %16 = getelementptr inbounds i8, ptr %.021, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %.021, i64 16
  %19 = load double, ptr %18, align 8, !tbaa !18
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.41, double noundef %15, double noundef %17, double noundef %19)
  %21 = getelementptr inbounds i8, ptr %.021, i64 24
  %.0 = load ptr, ptr %21, 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, %9
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.39)
  br label %23

23:                                               ; preds = %4, %._crit_edge
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 33
  br i1 %exitcond.not, label %3, label %4, !llvm.loop !20
}

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 = distinct !{!20, !6}


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