; LLVM IR from bldeng/AASolver :: AndersonOpt/external/OpenMesh/Core/Utils (RandomNumberGenerator)

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

%"class.OpenMesh::RandomNumberGenerator" = type { i64, i64, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8OpenMesh21RandomNumberGeneratorC2Em(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %"class.OpenMesh::RandomNumberGenerator", ptr %7, i32 0, i32 0
  %9 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %9, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds %"class.OpenMesh::RandomNumberGenerator", ptr %7, i32 0, i32 1
  store i64 1, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds %"class.OpenMesh::RandomNumberGenerator", ptr %7, i32 0, i32 2
  store double 0x41E0000000000000, ptr %11, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %12 = getelementptr inbounds %"class.OpenMesh::RandomNumberGenerator", ptr %7, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = uitofp i64 %13 to double
  store double %14, ptr %5, align 8, !tbaa !16
  br label %15

15:                                               ; preds = %18, %2
  %16 = load double, ptr %5, align 8, !tbaa !16
  %17 = fcmp ogt double %16, 0x41E0000000000000
  br i1 %17, label %18, label %24

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"class.OpenMesh::RandomNumberGenerator", ptr %7, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = add i64 %20, 1
  store i64 %21, ptr %19, align 8, !tbaa !14
  %22 = load double, ptr %5, align 8, !tbaa !16
  %23 = fdiv double %22, 0x41E0000000000000
  store double %23, ptr %5, align 8, !tbaa !16
  br label %15, !llvm.loop !17

24:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !19
  br label %25

25:                                               ; preds = %37, %24
  %26 = load i32, ptr %6, align 4, !tbaa !19
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds %"class.OpenMesh::RandomNumberGenerator", ptr %7, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !14
  %30 = sub i64 %29, 1
  %31 = icmp ult i64 %27, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %40

33:                                               ; preds = %25
  %34 = getelementptr inbounds %"class.OpenMesh::RandomNumberGenerator", ptr %7, i32 0, i32 2
  %35 = load double, ptr %34, align 8, !tbaa !15
  %36 = fmul double %35, 0x41E0000000000000
  store double %36, ptr %34, align 8, !tbaa !15
  br label %37

37:                                               ; preds = %33
  %38 = load i32, ptr %6, align 4, !tbaa !19
  %39 = add i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !19
  br label %25, !llvm.loop !21

40:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN8OpenMesh21RandomNumberGeneratorE", !10, i64 0, !10, i64 8, !13, i64 16}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !13, i64 16}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = distinct !{!21, !18}


; 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 nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @_ZN8OpenMesh21RandomNumberGeneratorC2Em(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(24) %0, i64 noundef %1) unnamed_addr #0 align 2 {
  store i64 %1, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 1, ptr %3, align 8, !tbaa !11
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  store double 0x41E0000000000000, ptr %4, align 8, !tbaa !12
  %5 = icmp ugt i64 %1, 2147483648
  br i1 %5, label %.lr.ph.preheader, label %.preheader.thread

.lr.ph.preheader:                                 ; preds = %2
  %6 = uitofp i64 %1 to double
  br label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  store i64 %8, ptr %3, align 8, !tbaa !11
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %.preheader.thread, label %.lr.ph9

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.056 = phi double [ %9, %.lr.ph ], [ %6, %.lr.ph.preheader ]
  %7 = phi i64 [ %8, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %8 = add i64 %7, 1
  %9 = fmul double %.056, 0x3E00000000000000
  %10 = fcmp ogt double %9, 0x41E0000000000000
  br i1 %10, label %.lr.ph, label %.preheader, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph9
  store double %12, ptr %4, align 8, !tbaa !12
  br label %.preheader.thread

.preheader.thread:                                ; preds = %2, %._crit_edge, %.preheader
  ret void

.lr.ph9:                                          ; preds = %.preheader, %.lr.ph9
  %.08 = phi i32 [ %13, %.lr.ph9 ], [ 0, %.preheader ]
  %11 = phi double [ %12, %.lr.ph9 ], [ 0x41E0000000000000, %.preheader ]
  %12 = fmul double %11, 0x41E0000000000000
  %13 = add i32 %.08, 1
  %14 = zext i32 %13 to i64
  %15 = icmp ugt i64 %7, %14
  br i1 %15, label %.lr.ph9, label %._crit_edge, !llvm.loop !15
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: write) 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 = !{!"_ZTSN8OpenMesh21RandomNumberGeneratorE", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !10, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass