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

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local double @RandomValue(i32 noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local double @Maxwell_Boltzmann_Distribution(double noundef %0, double noundef %1) #4 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca [3 x double], align 16
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store double %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #5
  call void @llvm.memset.p0.i64(ptr align 16 %5, i8 0, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  br label %8

8:                                                ; preds = %59, %2
  br label %9

9:                                                ; preds = %27, %8
  %10 = call double @RandomValue(i32 noundef 0, i32 noundef 1)
  %11 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %10, double -1.000000e+00)
  %12 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  store double %11, ptr %12, align 16, !tbaa !5
  %13 = call double @RandomValue(i32 noundef 0, i32 noundef 1)
  %14 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %13, double -1.000000e+00)
  %15 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 1
  store double %14, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %17 = load double, ptr %16, align 16, !tbaa !5
  %18 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %19 = load double, ptr %18, align 16, !tbaa !5
  %20 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 1
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 1
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fmul double %21, %23
  %25 = call double @llvm.fmuladd.f64(double %17, double %19, double %24)
  %26 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 2
  store double %25, ptr %26, align 16, !tbaa !5
  br label %27

27:                                               ; preds = %9
  %28 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 2
  %29 = load double, ptr %28, align 16, !tbaa !5
  %30 = fcmp oge double %29, 1.000000e+00
  br i1 %30, label %9, label %31, !llvm.loop !9

31:                                               ; preds = %27
  %32 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 2
  %33 = load double, ptr %32, align 16, !tbaa !5
  %34 = call double @log(double noundef %33) #5
  %35 = fmul double -2.000000e+00, %34
  %36 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 2
  %37 = load double, ptr %36, align 16, !tbaa !5
  %38 = fdiv double %35, %37
  %39 = call double @sqrt(double noundef %38) #5
  %40 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 2
  store double %39, ptr %40, align 16, !tbaa !5
  %41 = call double @RandomValue(i32 noundef 0, i32 noundef 1)
  store double %41, ptr %6, align 8, !tbaa !5
  %42 = load double, ptr %6, align 8, !tbaa !5
  %43 = fcmp oge double %42, 5.000000e-01
  br i1 %43, label %44, label %50

44:                                               ; preds = %31
  %45 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %46 = load double, ptr %45, align 16, !tbaa !5
  %47 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 2
  %48 = load double, ptr %47, align 16, !tbaa !5
  %49 = fmul double %46, %48
  store double %49, ptr %7, align 8, !tbaa !5
  br label %56

50:                                               ; preds = %31
  %51 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 1
  %52 = load double, ptr %51, align 8, !tbaa !5
  %53 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 2
  %54 = load double, ptr %53, align 16, !tbaa !5
  %55 = fmul double %52, %54
  store double %55, ptr %7, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %50, %44
  %57 = load double, ptr %7, align 8, !tbaa !5
  %58 = fcmp oeq double %57, 0.000000e+00
  br i1 %58, label %59, label %60

59:                                               ; preds = %56
  br label %8

60:                                               ; preds = %56
  %61 = load double, ptr %7, align 8, !tbaa !5
  %62 = load double, ptr %4, align 8, !tbaa !5
  %63 = call double @sqrt(double noundef %62) #5
  %64 = load double, ptr %3, align 8, !tbaa !5
  %65 = call double @llvm.fmuladd.f64(double %61, double %63, double %64)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #5
  ret double %65
}

; Function Attrs: nounwind
declare double @log(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

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

; Function Attrs: nounwind uwtable
declare dso_local double @RandomValue(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local double @Maxwell_Boltzmann_Distribution(double noundef %0, double noundef %1) local_unnamed_addr #2 {
  br label %3

3:                                                ; preds = %.backedge, %2
  %4 = tail call double @RandomValue(i32 noundef 0, i32 noundef 1)
  %5 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double -1.000000e+00)
  %6 = tail call double @RandomValue(i32 noundef 0, i32 noundef 1)
  %7 = tail call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double -1.000000e+00)
  %8 = fmul double %7, %7
  %9 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %8)
  %10 = fcmp ult double %9, 1.000000e+00
  br i1 %10, label %11, label %.backedge

.backedge:                                        ; preds = %3, %11
  br label %3, !llvm.loop !5

11:                                               ; preds = %3
  %12 = tail call double @log(double noundef %9) #3
  %13 = fmul double %12, -2.000000e+00
  %14 = fdiv double %13, %9
  %15 = tail call double @sqrt(double noundef %14) #3
  %16 = tail call double @RandomValue(i32 noundef 0, i32 noundef 1)
  %17 = fcmp ult double %16, 5.000000e-01
  %. = select i1 %17, double %7, double %5
  %.0 = fmul double %15, %.
  %18 = fcmp oeq double %.0, 0.000000e+00
  br i1 %18, label %.backedge, label %19

19:                                               ; preds = %11
  %20 = tail call double @sqrt(double noundef %1) #3
  %21 = tail call double @llvm.fmuladd.f64(double %.0, double %20, double %0)
  ret double %21
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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"}


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