; 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.AtomStr = type { ptr, ptr }
%struct.PropertyStr = type { [8 x i8], [2 x [16 x i8]], [8 x i8], i32, i32, i32, double, double, [3 x double], %struct.AtomSeqStr, ptr, ptr }
%struct.AtomSeqStr = type { i32, i32, i32 }
%struct.ConstraintStr = type { i32, double, ptr, double, ptr }
%struct.StepPotenStr = type { double, double, double, ptr }

; 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 ptr @RightPair(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @FindPotWellWidth(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.AtomStr, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.PropertyStr, ptr %14, i32 0, i32 4
  %16 = load i32, ptr %15, align 4, !tbaa !11
  store i32 %16, ptr %6, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.AtomStr, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.PropertyStr, ptr %19, i32 0, i32 4
  %21 = load i32, ptr %20, align 4, !tbaa !11
  store i32 %21, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store double 0.000000e+00, ptr %8, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %22 = load i32, ptr %6, align 4, !tbaa !16
  %23 = load i32, ptr %7, align 4, !tbaa !16
  %24 = call ptr @RightPair(i32 noundef %22, i32 noundef %23, i32 noundef 0)
  store ptr %24, ptr %9, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ConstraintStr, ptr %25, i32 0, i32 3
  %27 = load double, ptr %26, align 8, !tbaa !18
  store double %27, ptr %8, align 8, !tbaa !17
  %28 = fcmp ogt double %27, 0.000000e+00
  br i1 %28, label %29, label %31

29:                                               ; preds = %2
  %30 = load double, ptr %8, align 8, !tbaa !17
  store double %30, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %48

31:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ConstraintStr, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !20
  store ptr %34, ptr %11, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %40, %31
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.StepPotenStr, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !21
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %44

40:                                               ; preds = %35
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.StepPotenStr, ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  store ptr %43, ptr %11, align 8, !tbaa !5
  br label %35, !llvm.loop !23

44:                                               ; preds = %35
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.StepPotenStr, ptr %45, i32 0, i32 0
  %47 = load double, ptr %46, align 8, !tbaa !25
  store double %47, ptr %3, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  br label %48

48:                                               ; preds = %44, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %49 = load double, ptr %3, align 8
  ret double %49
}

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, !6, i64 0}
!10 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!11 = !{!12, !13, i64 52}
!12 = !{!"PropertyStr", !7, i64 0, !7, i64 8, !7, i64 40, !13, i64 48, !13, i64 52, !13, i64 56, !14, i64 64, !14, i64 72, !7, i64 80, !15, i64 104, !6, i64 120, !6, i64 128}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"AtomSeqStr", !13, i64 0, !13, i64 4, !13, i64 8}
!16 = !{!13, !13, i64 0}
!17 = !{!14, !14, i64 0}
!18 = !{!19, !14, i64 24}
!19 = !{!"ConstraintStr", !13, i64 0, !14, i64 8, !6, i64 16, !14, i64 24, !6, i64 32}
!20 = !{!19, !6, i64 16}
!21 = !{!22, !6, i64 24}
!22 = !{!"StepPotenStr", !14, i64 0, !14, i64 8, !14, i64 16, !6, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!22, !14, i64 0}


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

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

; Function Attrs: nounwind uwtable
define dso_local double @FindPotWellWidth(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 52
  %5 = load i32, ptr %4, align 4, !tbaa !10
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 52
  %8 = load i32, ptr %7, align 4, !tbaa !10
  %9 = tail call ptr @RightPair(i32 noundef %5, i32 noundef %8, i32 noundef 0)
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !15
  %12 = fcmp ogt double %11, 0.000000e+00
  br i1 %12, label %21, label %13

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %9, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  br label %16

16:                                               ; preds = %16, %13
  %.0 = phi ptr [ %15, %13 ], [ %18, %16 ]
  %17 = getelementptr inbounds i8, ptr %.0, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !18
  %.not = icmp eq ptr %18, null
  br i1 %.not, label %19, label %16, !llvm.loop !20

19:                                               ; preds = %16
  %20 = load double, ptr %.0, align 8, !tbaa !22
  br label %21

21:                                               ; preds = %2, %19
  %.010 = phi double [ %20, %19 ], [ %11, %2 ]
  ret double %.010
}

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, !7, i64 0}
!6 = !{!"AtomStr", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 52}
!11 = !{!"PropertyStr", !8, i64 0, !8, i64 8, !8, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !13, i64 64, !13, i64 72, !8, i64 80, !14, i64 104, !7, i64 120, !7, i64 128}
!12 = !{!"int", !8, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!"AtomSeqStr", !12, i64 0, !12, i64 4, !12, i64 8}
!15 = !{!16, !13, i64 24}
!16 = !{!"ConstraintStr", !12, i64 0, !13, i64 8, !7, i64 16, !13, i64 24, !7, i64 32}
!17 = !{!16, !7, i64 16}
!18 = !{!19, !7, i64 24}
!19 = !{!"StepPotenStr", !13, i64 0, !13, i64 8, !13, i64 16, !7, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!19, !13, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass