; LLVM IR from sfu-dis/mosaicdb :: benchmarks/egen (CustomerSelection)

; 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.TPCE::CCustomerSelection" = type { ptr, i64, i64, i8, i32, i64, i64 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4TPCE18CCustomerSelection7PermuteExx(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef) #0 align 2

; 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE18CCustomerSelection22GenerateRandomCustomerERxRNS_13eCustomerTierE(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(4) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  br label %97

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %16 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = call noundef double @_ZN4TPCE7CRandom18RndDoubleIncrRangeEddd(ptr noundef nonnull align 8 dereferenceable(8) %17, double noundef 1.000000e-04, double noundef 2.000000e+03, double noundef 1.000000e-09)
  store double %18, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %19 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 3
  %20 = load i8, ptr %19, align 8, !tbaa !16, !range !17, !noundef !18
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %42

22:                                               ; preds = %15
  %23 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 4
  %26 = load i32, ptr %25, align 4, !tbaa !19
  %27 = call noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8) %24, i32 noundef %26)
  br i1 %27, label %28, label %42

28:                                               ; preds = %22
  %29 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 5
  %32 = load i64, ptr %31, align 8, !tbaa !20
  %33 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 5
  %34 = load i64, ptr %33, align 8, !tbaa !20
  %35 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 6
  %36 = load i64, ptr %35, align 8, !tbaa !21
  %37 = add nsw i64 %34, %36
  %38 = sub nsw i64 %37, 1
  %39 = call noundef i64 @_ZN4TPCE7CRandom13RndInt64RangeExx(ptr noundef nonnull align 8 dereferenceable(8) %30, i64 noundef %32, i64 noundef %38)
  %40 = sub nsw i64 %39, 1
  %41 = sdiv i64 %40, 1000
  store i64 %41, ptr %8, align 8, !tbaa !22
  br label %56

42:                                               ; preds = %22, %15
  %43 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 1
  %46 = load i64, ptr %45, align 8, !tbaa !23
  %47 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 1
  %48 = load i64, ptr %47, align 8, !tbaa !23
  %49 = getelementptr inbounds %"class.TPCE::CCustomerSelection", ptr %10, i32 0, i32 2
  %50 = load i64, ptr %49, align 8, !tbaa !24
  %51 = add nsw i64 %48, %50
  %52 = sub nsw i64 %51, 1
  %53 = call noundef i64 @_ZN4TPCE7CRandom13RndInt64RangeExx(ptr noundef nonnull align 8 dereferenceable(8) %44, i64 noundef %46, i64 noundef %52)
  %54 = sub nsw i64 %53, 1
  %55 = sdiv i64 %54, 1000
  store i64 %55, ptr %8, align 8, !tbaa !22
  br label %56

56:                                               ; preds = %42, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %57 = load double, ptr %7, align 8, !tbaa !14
  %58 = fcmp ole double %57, 2.000000e+02
  br i1 %58, label %59, label %67

59:                                               ; preds = %56
  %60 = load double, ptr %7, align 8, !tbaa !14
  %61 = call double @llvm.fmuladd.f64(double 5.000000e+02, double %60, double 2.250000e+04)
  %62 = call double @sqrt(double noundef %61) #7
  %63 = fsub double %62, 1.510000e+02
  %64 = call double @llvm.ceil.f64(double %63)
  %65 = fptosi double %64 to i32
  store i32 %65, ptr %9, align 4, !tbaa !25
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 1, ptr %66, align 4, !tbaa !26
  br label %87

67:                                               ; preds = %56
  %68 = load double, ptr %7, align 8, !tbaa !14
  %69 = fcmp ole double %68, 1.400000e+03
  br i1 %69, label %70, label %78

70:                                               ; preds = %67
  %71 = load double, ptr %7, align 8, !tbaa !14
  %72 = call double @llvm.fmuladd.f64(double 1.000000e+03, double %71, double 2.900000e+05)
  %73 = call double @sqrt(double noundef %72) #7
  %74 = fsub double %73, 5.010000e+02
  %75 = call double @llvm.ceil.f64(double %74)
  %76 = fptosi double %75 to i32
  store i32 %76, ptr %9, align 4, !tbaa !25
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 2, ptr %77, align 4, !tbaa !26
  br label %86

78:                                               ; preds = %67
  %79 = load double, ptr %7, align 8, !tbaa !14
  %80 = call double @llvm.fmuladd.f64(double 5.000000e+02, double %79, double -2.775000e+05)
  %81 = call double @sqrt(double noundef %80) #7
  %82 = fadd double 1.490000e+02, %81
  %83 = call double @llvm.ceil.f64(double %82)
  %84 = fptosi double %83 to i32
  store i32 %84, ptr %9, align 4, !tbaa !25
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 3, ptr %85, align 4, !tbaa !26
  br label %86

86:                                               ; preds = %78, %70
  br label %87

87:                                               ; preds = %86, %59
  %88 = load i64, ptr %8, align 8, !tbaa !22
  %89 = mul nsw i64 %88, 1000
  %90 = load i32, ptr %9, align 4, !tbaa !25
  %91 = sext i32 %90 to i64
  %92 = load i64, ptr %8, align 8, !tbaa !22
  %93 = call noundef i64 @_ZN4TPCE18CCustomerSelection7PermuteExx(ptr noundef nonnull align 8 dereferenceable(48) %10, i64 noundef %91, i64 noundef %92)
  %94 = add nsw i64 %89, %93
  %95 = add nsw i64 %94, 1
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %95, ptr %96, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %97

97:                                               ; preds = %87, %14
  ret void
}

declare noundef double @_ZN4TPCE7CRandom18RndDoubleIncrRangeEddd(ptr noundef nonnull align 8 dereferenceable(8), double noundef, double noundef, double noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4 align 2

declare noundef i64 @_ZN4TPCE7CRandom13RndInt64RangeExx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #6

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 = { mustprogress 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 = { "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 = { inlinehint mustprogress 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 "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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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, !6, i64 0}
!10 = !{!"_ZTSN4TPCE18CCustomerSelectionE", !6, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 28, !11, i64 32, !11, i64 40}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!10, !12, i64 24}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!10, !13, i64 28}
!20 = !{!10, !11, i64 32}
!21 = !{!10, !11, i64 40}
!22 = !{!11, !11, i64 0}
!23 = !{!10, !11, i64 8}
!24 = !{!10, !11, i64 16}
!25 = !{!13, !13, i64 0}
!26 = !{!27, !27, i64 0}
!27 = !{!"_ZTSN4TPCE13eCustomerTierE", !7, 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4TPCE18CCustomerSelection7PermuteExx(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE18CCustomerSelection22GenerateRandomCustomerERxRNS_13eCustomerTierE(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %1, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %2) local_unnamed_addr #1 align 2 {
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %44, label %6

6:                                                ; preds = %3
  %7 = tail call noundef double @_ZN4TPCE7CRandom18RndDoubleIncrRangeEddd(ptr noundef nonnull align 8 dereferenceable(8) %4, double noundef 1.000000e-04, double noundef 2.000000e+03, double noundef 1.000000e-09)
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i8, ptr %8, align 8, !tbaa !13, !range !14, !noundef !15
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %11, label %16

11:                                               ; preds = %6
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 28
  %14 = load i32, ptr %13, align 4, !tbaa !16
  %15 = tail call noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef %14)
  br i1 %15, label %17, label %16

16:                                               ; preds = %11, %6
  br label %17

17:                                               ; preds = %11, %16
  %.sink23 = phi i64 [ 8, %16 ], [ 32, %11 ]
  %.sink21 = phi i64 [ 16, %16 ], [ 40, %11 ]
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 %.sink23
  %20 = load i64, ptr %19, align 8, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %0, i64 %.sink21
  %22 = load i64, ptr %21, align 8, !tbaa !17
  %23 = add i64 %20, -1
  %24 = add i64 %23, %22
  %25 = tail call noundef i64 @_ZN4TPCE7CRandom13RndInt64RangeExx(ptr noundef nonnull align 8 dereferenceable(8) %18, i64 noundef %20, i64 noundef %24)
  %.012.in = add nsw i64 %25, -1
  %.012 = sdiv i64 %.012.in, 1000
  %26 = fcmp ugt double %7, 2.000000e+02
  br i1 %26, label %29, label %27

27:                                               ; preds = %17
  %28 = tail call double @llvm.fmuladd.f64(double %7, double 5.000000e+02, double 2.250000e+04)
  br label %35

29:                                               ; preds = %17
  %30 = fcmp ugt double %7, 1.400000e+03
  br i1 %30, label %33, label %31

31:                                               ; preds = %29
  %32 = tail call double @llvm.fmuladd.f64(double %7, double 1.000000e+03, double 2.900000e+05)
  br label %35

33:                                               ; preds = %29
  %34 = tail call double @llvm.fmuladd.f64(double %7, double 5.000000e+02, double -2.775000e+05)
  br label %35

35:                                               ; preds = %31, %33, %27
  %.sink27 = phi double [ %32, %31 ], [ %34, %33 ], [ %28, %27 ]
  %.sink26 = phi double [ -5.010000e+02, %31 ], [ 1.490000e+02, %33 ], [ -1.510000e+02, %27 ]
  %.sink = phi i32 [ 2, %31 ], [ 3, %33 ], [ 1, %27 ]
  %36 = tail call double @sqrt(double noundef %.sink27) #6
  %37 = fadd double %36, %.sink26
  %38 = tail call double @llvm.ceil.f64(double %37)
  store i32 %.sink, ptr %2, align 4, !tbaa !18
  %.0 = fptosi double %38 to i32
  %39 = mul nsw i64 %.012, 1000
  %40 = sext i32 %.0 to i64
  %41 = tail call noundef i64 @_ZN4TPCE18CCustomerSelection7PermuteExx(ptr noundef nonnull align 8 dereferenceable(48) %0, i64 noundef %40, i64 noundef %.012)
  %42 = or disjoint i64 %39, 1
  %43 = add i64 %42, %41
  store i64 %43, ptr %1, align 8, !tbaa !17
  br label %44

44:                                               ; preds = %3, %35
  ret void
}

declare noundef double @_ZN4TPCE7CRandom18RndDoubleIncrRangeEddd(ptr noundef nonnull align 8 dereferenceable(8), double noundef, double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4TPCE7CRandom10RndPercentEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3 align 2

declare noundef i64 @_ZN4TPCE7CRandom13RndInt64RangeExx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #5

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 = { mustprogress 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 = { "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 = { inlinehint mustprogress 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 = { 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 #5 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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, !7, i64 0}
!6 = !{!"_ZTSN4TPCE18CCustomerSelectionE", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 28, !10, i64 32, !10, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !11, i64 24}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!6, !12, i64 28}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"_ZTSN4TPCE13eCustomerTierE", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass