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

; 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
define dso_local i64 @_ZN4TPCE12CMEESecurity14CalculatePriceExd(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 noundef %1, double noundef %2) #0 align 2 {
  %4 = alloca %"class.TPCE::CMoney", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca %"class.TPCE::CMoney", align 8
  %12 = alloca %"class.TPCE::CMoney", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !11
  %13 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %14 = load double, ptr %7, align 8, !tbaa !11
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = call noundef double @_ZN4TPCE12CMEESecurity11InitialTimeEx(ptr noundef nonnull align 8 dereferenceable(64) %13, i64 noundef %15)
  %17 = fadd double %14, %16
  %18 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 4
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = sitofp i32 %19 to double
  %21 = fdiv double %17, %20
  store double %21, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %22 = load double, ptr %8, align 8, !tbaa !11
  %23 = load double, ptr %8, align 8, !tbaa !11
  %24 = fptosi double %23 to i32
  %25 = sitofp i32 %24 to double
  %26 = fsub double %22, %25
  %27 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 4
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = sitofp i32 %28 to double
  %30 = fmul double %26, %29
  store double %30, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @_ZN4TPCE6CMoneyC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %31 = load double, ptr %9, align 8, !tbaa !11
  %32 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 4
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %34 = sdiv i32 %33, 2
  %35 = sitofp i32 %34 to double
  %36 = fcmp olt double %31, %35
  br i1 %36, label %37, label %44

37:                                               ; preds = %3
  %38 = load double, ptr %9, align 8, !tbaa !11
  %39 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 4
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = sdiv i32 %40, 2
  %42 = sitofp i32 %41 to double
  %43 = fdiv double %38, %42
  store double %43, ptr %10, align 8, !tbaa !11
  br label %55

44:                                               ; preds = %3
  %45 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 4
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = sitofp i32 %46 to double
  %48 = load double, ptr %9, align 8, !tbaa !11
  %49 = fsub double %47, %48
  %50 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 4
  %51 = load i32, ptr %50, align 8, !tbaa !13
  %52 = sdiv i32 %51, 2
  %53 = sitofp i32 %52 to double
  %54 = fdiv double %49, %53
  store double %54, ptr %10, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %44, %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %56 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %57 = getelementptr inbounds %"class.TPCE::CMEESecurity", ptr %13, i32 0, i32 3
  %58 = load double, ptr %10, align 8, !tbaa !11
  %59 = call i64 @_ZN4TPCE6CMoneymlEd(ptr noundef nonnull align 8 dereferenceable(8) %57, double noundef %58)
  %60 = getelementptr inbounds %"class.TPCE::CMoney", ptr %12, i32 0, i32 0
  store i64 %59, ptr %60, align 8
  %61 = call i64 @_ZN4TPCE6CMoneyplERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %56, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %62 = getelementptr inbounds %"class.TPCE::CMoney", ptr %11, i32 0, i32 0
  store i64 %61, ptr %62, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %11, i64 8, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %63 = getelementptr inbounds %"class.TPCE::CMoney", ptr %4, i32 0, i32 0
  %64 = load i64, ptr %63, align 8
  ret i64 %64
}

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZN4TPCE6CMoneyC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

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

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

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

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 = { 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, !17, i64 32}
!14 = !{!"_ZTSN4TPCE12CMEESecurityE", !15, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !17, i64 32, !17, i64 36, !6, i64 40, !6, i64 48, !12, i64 56}
!15 = !{!"_ZTSN4TPCE7CRandomE", !10, i64 0}
!16 = !{!"_ZTSN4TPCE6CMoneyE", !10, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{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
define dso_local i64 @_ZN4TPCE12CMEESecurity14CalculatePriceExd(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"class.TPCE::CMoney", align 8
  %5 = alloca %"class.TPCE::CMoney", align 8
  %6 = tail call noundef double @_ZN4TPCE12CMEESecurity11InitialTimeEx(ptr noundef nonnull align 8 dereferenceable(64) %0, i64 noundef %1)
  %7 = fadd double %6, %2
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = sitofp i32 %9 to double
  %11 = fdiv double %7, %10
  %12 = fptosi double %11 to i32
  %13 = sitofp i32 %12 to double
  %14 = fsub double %11, %13
  %15 = fmul double %14, %10
  call void @_ZN4TPCE6CMoneyC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %16 = load i32, ptr %8, align 8, !tbaa !5
  %17 = sdiv i32 %16, 2
  %18 = sitofp i32 %17 to double
  %19 = fcmp olt double %15, %18
  %20 = sitofp i32 %16 to double
  %21 = fsub double %20, %15
  %.pn = select i1 %19, double %15, double %21
  %.0 = fdiv double %.pn, %18
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = call i64 @_ZN4TPCE6CMoneymlEd(ptr noundef nonnull align 8 dereferenceable(8) %23, double noundef %.0)
  store i64 %24, ptr %5, align 8
  %25 = call i64 @_ZN4TPCE6CMoneyplERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %22, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret i64 %25
}

; 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 nounwind uwtable
declare dso_local void @_ZN4TPCE6CMoneyC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

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

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

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

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 = { 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, !12, i64 32}
!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}


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