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

@atom = external global ptr, align 8
@.str.35 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.37 = 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 uwtable
define dso_local void @PrintConstr(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr @atom, align 8, !tbaa !9
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds %struct.AtomStr, ptr %5, i64 %7
  %9 = getelementptr inbounds %struct.AtomStr, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %struct.PropertyStr, ptr %10, i32 0, i32 11
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  store ptr %12, ptr %3, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %42, %1
  %14 = load ptr, ptr %3, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %50

16:                                               ; preds = %13
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = load ptr, ptr %3, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.ConstraintStr, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !17
  %21 = load ptr, ptr %3, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.ConstraintStr, ptr %21, i32 0, i32 1
  %23 = load double, ptr %22, align 8, !tbaa !19
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.35, i32 noundef %17, i32 noundef %20, double noundef %23)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %25 = load ptr, ptr %3, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.ConstraintStr, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !20
  store ptr %27, ptr %4, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %31, %16
  %29 = load ptr, ptr %4, align 8, !tbaa !9
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %42

31:                                               ; preds = %28
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.StepPotenStr, ptr %32, i32 0, i32 0
  %34 = load double, ptr %33, align 8, !tbaa !21
  %35 = load ptr, ptr %4, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.StepPotenStr, ptr %35, i32 0, i32 1
  %37 = load double, ptr %36, align 8, !tbaa !23
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.36, double noundef %34, double noundef %37)
  %39 = load ptr, ptr %4, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.StepPotenStr, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !24
  store ptr %41, ptr %4, align 8, !tbaa !9
  br label %28, !llvm.loop !25

42:                                               ; preds = %28
  %43 = load ptr, ptr %3, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.ConstraintStr, ptr %43, i32 0, i32 3
  %45 = load double, ptr %44, align 8, !tbaa !27
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.37, double noundef %45)
  %47 = load ptr, ptr %3, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.ConstraintStr, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !28
  store ptr %49, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %13, !llvm.loop !29

50:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  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 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"AtomStr", !10, i64 0, !10, i64 8}
!13 = !{!14, !10, i64 128}
!14 = !{!"PropertyStr", !7, i64 0, !7, i64 8, !7, i64 40, !6, i64 48, !6, i64 52, !6, i64 56, !15, i64 64, !15, i64 72, !7, i64 80, !16, i64 104, !10, i64 120, !10, i64 128}
!15 = !{!"double", !7, i64 0}
!16 = !{!"AtomSeqStr", !6, i64 0, !6, i64 4, !6, i64 8}
!17 = !{!18, !6, i64 0}
!18 = !{!"ConstraintStr", !6, i64 0, !15, i64 8, !10, i64 16, !15, i64 24, !10, i64 32}
!19 = !{!18, !15, i64 8}
!20 = !{!18, !10, i64 16}
!21 = !{!22, !15, i64 0}
!22 = !{!"StepPotenStr", !15, i64 0, !15, i64 8, !15, i64 16, !10, i64 24}
!23 = !{!22, !15, i64 8}
!24 = !{!22, !10, i64 24}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!18, !15, i64 24}
!28 = !{!18, !10, i64 32}
!29 = distinct !{!29, !26}


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

@atom = external local_unnamed_addr global ptr, align 8
@.str.35 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.37 = 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: nofree nounwind uwtable
define dso_local void @PrintConstr(i32 noundef %0) local_unnamed_addr #1 {
  %2 = load ptr, ptr @atom, align 8, !tbaa !5
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds %struct.AtomStr, ptr %2, i64 %3
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %5, i64 128
  %.01116 = load ptr, ptr %6, align 8, !tbaa !5
  %.not17 = icmp eq ptr %.01116, null
  br i1 %.not17, label %._crit_edge21, label %.lr.ph20

.lr.ph20:                                         ; preds = %1, %._crit_edge
  %.01118 = phi ptr [ %.011, %._crit_edge ], [ %.01116, %1 ]
  %7 = load i32, ptr %.01118, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %.01118, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !15
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35, i32 noundef %0, i32 noundef %7, double noundef %9)
  %11 = getelementptr inbounds i8, ptr %.01118, i64 16
  %.013 = load ptr, ptr %11, align 8, !tbaa !5
  %.not1214 = icmp eq ptr %.013, null
  br i1 %.not1214, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph20, %.lr.ph
  %.015 = phi ptr [ %.0, %.lr.ph ], [ %.013, %.lr.ph20 ]
  %12 = load double, ptr %.015, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %.015, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !18
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.36, double noundef %12, double noundef %14)
  %16 = getelementptr inbounds i8, ptr %.015, i64 24
  %.0 = load ptr, ptr %16, align 8, !tbaa !5
  %.not12 = icmp eq ptr %.0, null
  br i1 %.not12, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph20
  %17 = getelementptr inbounds i8, ptr %.01118, i64 24
  %18 = load double, ptr %17, align 8, !tbaa !21
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37, double noundef %18)
  %20 = getelementptr inbounds i8, ptr %.01118, i64 32
  %.011 = load ptr, ptr %20, align 8, !tbaa !5
  %.not = icmp eq ptr %.011, null
  br i1 %.not, label %._crit_edge21, label %.lr.ph20, !llvm.loop !22

._crit_edge21:                                    ; preds = %._crit_edge, %1
  ret void
}

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

!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 0}
!12 = !{!"ConstraintStr", !13, i64 0, !14, i64 8, !6, i64 16, !14, i64 24, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!12, !14, i64 8}
!16 = !{!17, !14, i64 0}
!17 = !{!"StepPotenStr", !14, i64 0, !14, i64 8, !14, i64 16, !6, i64 24}
!18 = !{!17, !14, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!12, !14, i64 24}
!22 = distinct !{!22, !20}


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