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

; 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::CMoney" = type { i64 }
%"class.TPCE::CMEESecurity" = type { %"class.TPCE::CRandom", %"class.TPCE::CMoney", %"class.TPCE::CMoney", %"class.TPCE::CMoney", i32, i32, ptr, ptr, double }
%"class.TPCE::CRandom" = type { i64 }

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN4TPCE12CMEESecurity14CalculatePriceExd(ptr noundef nonnull align 8 dereferenceable(64), i64 noundef, double noundef) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4TPCE12CMEESecurity11InitialTimeEx(ptr noundef nonnull align 8 dereferenceable(64), i64 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN4TPCE12CMEESecurity13CalculateTimeENS_6CMoneyES1_i(ptr noundef nonnull align 8 dereferenceable(64), i64, i64, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN4TPCE12CMEESecurity17GetSubmissionTimeExdNS_6CMoneyENS_12eTradeTypeIDE(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 noundef %1, double noundef %2, i64 %3, i32 noundef %4) #0 align 2 {
  %6 = alloca %"class.TPCE::CMoney", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"class.TPCE::CMoney", align 8
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca %"class.TPCE::CMoney", align 8
  %15 = alloca %"class.TPCE::CMoney", align 8
  %16 = getelementptr inbounds %"class.TPCE::CMoney", ptr %6, i32 0, i32 0
  store i64 %3, ptr %16, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store double %2, ptr %9, align 8, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !13
  %17 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = load double, ptr %9, align 8, !tbaa !11
  %20 = call i64 @_ZN4TPCE12CMEESecurity14CalculatePriceExd(ptr noundef nonnull align 8 dereferenceable(64) %17, i64 noundef %18, double noundef %19)
  %21 = getelementptr inbounds %"class.TPCE::CMoney", ptr %11, i32 0, i32 0
  store i64 %20, ptr %21, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %22 = load i32, ptr %10, align 4, !tbaa !13
  %23 = icmp eq i32 %22, 4
  br i1 %23, label %27, label %24

24:                                               ; preds = %5
  %25 = load i32, ptr %10, align 4, !tbaa !13
  %26 = icmp eq i32 %25, 2
  br i1 %26, label %27, label %29

27:                                               ; preds = %24, %5
  %28 = call noundef zeroext i1 @_ZN4TPCE6CMoneyleERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %28, label %34, label %29

29:                                               ; preds = %27, %24
  %30 = load i32, ptr %10, align 4, !tbaa !13
  %31 = icmp eq i32 %30, 3
  br i1 %31, label %32, label %43

32:                                               ; preds = %29
  %33 = call noundef zeroext i1 @_ZN4TPCE6CMoneygeERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %33, label %34, label %43

34:                                               ; preds = %32, %27
  %35 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %17, i32 0, i32 0
  %36 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %17, i32 0, i32 8
  %37 = load double, ptr %36, align 8, !tbaa !15
  %38 = fmul double 5.000000e-01, %37
  %39 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %17, i32 0, i32 8
  %40 = load double, ptr %39, align 8, !tbaa !15
  %41 = fmul double 1.500000e+00, %40
  %42 = call noundef double @_ZN4TPCE7CRandom18RndDoubleIncrRangeEddd(ptr noundef nonnull align 8 dereferenceable(8) %35, double noundef %38, double noundef %41, double noundef 1.000000e-03)
  store double %42, ptr %13, align 8, !tbaa !11
  br label %65

43:                                               ; preds = %32, %29
  %44 = load double, ptr %9, align 8, !tbaa !11
  %45 = load i64, ptr %8, align 8, !tbaa !9
  %46 = call noundef double @_ZN4TPCE12CMEESecurity11InitialTimeEx(ptr noundef nonnull align 8 dereferenceable(64) %17, i64 noundef %45)
  %47 = fadd double %44, %46
  %48 = fptosi double %47 to i32
  %49 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %17, i32 0, i32 4
  %50 = load i32, ptr %49, align 8, !tbaa !20
  %51 = srem i32 %48, %50
  %52 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %17, i32 0, i32 4
  %53 = load i32, ptr %52, align 8, !tbaa !20
  %54 = sdiv i32 %53, 2
  %55 = icmp slt i32 %51, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %43
  store i32 1, ptr %12, align 4, !tbaa !21
  br label %58

57:                                               ; preds = %43
  store i32 -1, ptr %12, align 4, !tbaa !21
  br label %58

58:                                               ; preds = %57, %56
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %11, i64 8, i1 false), !tbaa.struct !22
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %6, i64 8, i1 false), !tbaa.struct !22
  %59 = load i32, ptr %12, align 4, !tbaa !21
  %60 = getelementptr inbounds %"class.TPCE::CMoney", ptr %14, i32 0, i32 0
  %61 = load i64, ptr %60, align 8
  %62 = getelementptr inbounds %"class.TPCE::CMoney", ptr %15, i32 0, i32 0
  %63 = load i64, ptr %62, align 8
  %64 = call noundef double @_ZN4TPCE12CMEESecurity13CalculateTimeENS_6CMoneyES1_i(ptr noundef nonnull align 8 dereferenceable(64) %17, i64 %61, i64 %63, i32 noundef %59)
  store double %64, ptr %13, align 8, !tbaa !11
  br label %65

65:                                               ; preds = %58, %34
  %66 = load double, ptr %9, align 8, !tbaa !11
  %67 = load double, ptr %13, align 8, !tbaa !11
  %68 = fadd double %66, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  ret double %68
}

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

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

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

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { 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 #5 = { "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 = { 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 long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTSN4TPCE12eTradeTypeIDE", !7, i64 0}
!15 = !{!16, !12, i64 56}
!16 = !{!"_ZTSN4TPCE12CMEESecurityE", !17, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !19, i64 32, !19, i64 36, !6, i64 40, !6, i64 48, !12, i64 56}
!17 = !{!"_ZTSN4TPCE7CRandomE", !10, i64 0}
!18 = !{!"_ZTSN4TPCE6CMoneyE", !10, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!16, !19, i64 32}
!21 = !{!19, !19, i64 0}
!22 = !{i64 0, i64 8, !9}


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

%"class.TPCE::CMoney" = type { i64 }

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN4TPCE12CMEESecurity14CalculatePriceExd(ptr noundef nonnull align 8 dereferenceable(64), i64 noundef, double noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4TPCE12CMEESecurity11InitialTimeEx(ptr noundef nonnull align 8 dereferenceable(64), i64 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN4TPCE12CMEESecurity13CalculateTimeENS_6CMoneyES1_i(ptr noundef nonnull align 8 dereferenceable(64), i64, i64, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN4TPCE12CMEESecurity17GetSubmissionTimeExdNS_6CMoneyENS_12eTradeTypeIDE(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 noundef %1, double noundef %2, i64 %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = alloca %"class.TPCE::CMoney", align 8
  %7 = alloca %"class.TPCE::CMoney", align 8
  store i64 %3, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %8 = tail call i64 @_ZN4TPCE12CMEESecurity14CalculatePriceExd(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 noundef %1, double noundef %2)
  store i64 %8, ptr %7, align 8
  switch i32 %4, label %21 [
    i32 4, label %9
    i32 2, label %9
    i32 3, label %13
  ]

9:                                                ; preds = %5, %5
  %10 = call noundef zeroext i1 @_ZN4TPCE6CMoneyleERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %10, label %15, label %11

11:                                               ; preds = %9
  %12 = icmp eq i32 %4, 3
  br i1 %12, label %13, label %21

13:                                               ; preds = %5, %11
  %14 = call noundef zeroext i1 @_ZN4TPCE6CMoneygeERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %14, label %15, label %21

15:                                               ; preds = %13, %9
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = fmul double %17, 5.000000e-01
  %19 = fmul double %17, 1.500000e+00
  %20 = call noundef double @_ZN4TPCE7CRandom18RndDoubleIncrRangeEddd(ptr noundef nonnull align 8 dereferenceable(8) %0, double noundef %18, double noundef %19, double noundef 1.000000e-03)
  br label %31

21:                                               ; preds = %5, %13, %11
  %22 = call noundef double @_ZN4TPCE12CMEESecurity11InitialTimeEx(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 noundef %1)
  %23 = fadd double %22, %2
  %24 = fptosi double %23 to i32
  %25 = getelementptr inbounds i8, ptr %0, i64 32
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = srem i32 %24, %26
  %28 = sdiv i32 %26, 2
  %29 = icmp slt i32 %27, %28
  %. = select i1 %29, i32 1, i32 -1
  %.sroa.02.0.copyload = load i64, ptr %7, align 8, !tbaa !16
  %.sroa.0.0.copyload = load i64, ptr %6, align 8, !tbaa !16
  %30 = call noundef double @_ZN4TPCE12CMEESecurity13CalculateTimeENS_6CMoneyES1_i(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 %.sroa.02.0.copyload, i64 %.sroa.0.0.copyload, i32 noundef %.)
  br label %31

31:                                               ; preds = %21, %15
  %.012 = phi double [ %20, %15 ], [ %30, %21 ]
  %32 = fadd double %.012, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  ret double %32
}

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

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 #4 = { "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, !14, i64 56}
!6 = !{!"_ZTSN4TPCE12CMEESecurityE", !7, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !12, i64 36, !13, i64 40, !13, i64 48, !14, i64 56}
!7 = !{!"_ZTSN4TPCE7CRandomE", !8, i64 0}
!8 = !{!"long long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN4TPCE6CMoneyE", !8, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!"double", !9, i64 0}
!15 = !{!6, !12, i64 32}
!16 = !{!8, !8, i64 0}


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