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

; 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::CTradeGen" = type <{ %"class.TPCE::CRandom", %"class.TPCE::CAddressTable", %"class.TPCE::CCustomerSelection", %"class.TPCE::CCustomerTable", %"class.TPCE::CCustomerTaxratesTable", %"class.TPCE::CCustomerAccountsAndPermissionsTable", %"class.TPCE::CHoldingsAndTradesTable", %"class.TPCE::CBrokersTable", %"class.TPCE::CSecurityTable", %"class.TPCE::CPerson", ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i32, i32, i32, i32, double, double, %"class.TPCE::CDateTime", double, %"class.std::priority_queue", i64, i64, i64, i32, [4 x i8], ptr, %"struct.TPCE::TTradeInfo", %"struct.TPCE::TAdditionalTradeInfo", %"struct.TPCE::TTradeRow", %"struct.TPCE::HOLDING_ROW", %"struct.TPCE::HOLDING_SUMMARY_ROW", i32, i32, i32, i32, %"class.TPCE::CMEESecurity", i32, i32, %"struct.std::_List_iterator", i32, i32, i64, i32, [4 x i8] }>
%"class.TPCE::CRandom" = type { i64 }
%"class.TPCE::CAddressTable" = type { %"class.TPCE::TableTemplate", %"class.TPCE::CDateTime", ptr, ptr, ptr, ptr, i64, i64, i8, i8, i64, i32, i64, i8, i32, i64, ptr }
%"class.TPCE::TableTemplate" = type { ptr, %"struct.TPCE::ADDRESS_ROW", i64, i8, %"class.TPCE::CRandom" }
%"struct.TPCE::ADDRESS_ROW" = type { i64, [81 x i8], [81 x i8], [13 x i8], [81 x i8] }
%"class.TPCE::CCustomerSelection" = type { ptr, i64, i64, i8, i32, i64, i64 }
%"class.TPCE::CCustomerTable" = type { %"class.TPCE::TableTemplate.0", i64, %"class.TPCE::CPerson", ptr, i64, i64, i64, i32, ptr, %"class.TPCE::CCustomerSelection" }
%"class.TPCE::TableTemplate.0" = type { ptr, %"struct.TPCE::CUSTOMER_ROW", i64, i8, %"class.TPCE::CRandom" }
%"struct.TPCE::CUSTOMER_ROW" = type <{ i64, [21 x i8], [5 x i8], [26 x i8], [21 x i8], [2 x i8], i8, i8, [3 x i8], %"class.TPCE::CDateTime", i64, [4 x i8], [4 x i8], [11 x i8], [6 x i8], [4 x i8], [4 x i8], [11 x i8], [6 x i8], [4 x i8], [4 x i8], [11 x i8], [6 x i8], [51 x i8], [51 x i8], [7 x i8] }>
%"class.TPCE::CCustomerTaxratesTable" = type { %"class.TPCE::TableTemplate.1", %"class.TPCE::CCustomerTable", %"class.TPCE::CAddressTable", ptr, ptr }
%"class.TPCE::TableTemplate.1" = type { ptr, %"struct.TPCE::CUSTOMER_TAXRATE_ROWS", i64, i8, %"class.TPCE::CRandom" }
%"struct.TPCE::CUSTOMER_TAXRATE_ROWS" = type { [2 x %"struct.TPCE::CUSTOMER_TAXRATE_ROW"] }
%"struct.TPCE::CUSTOMER_TAXRATE_ROW" = type { [5 x i8], i64 }
%"class.TPCE::CCustomerAccountsAndPermissionsTable" = type { %"class.TPCE::TableTemplate.2", ptr, ptr, i64, i64, i64, i32, i32, %"class.TPCE::CCustomerTable", %"class.TPCE::CPerson", i32, i64, %"class.TPCE::CAddressTable", i32, %"class.TPCE::CCustomerSelection", i8, i32, i64, ptr, i32, i64, ptr }
%"class.TPCE::TableTemplate.2" = type { ptr, %"struct.TPCE::CUSTOMER_ACCOUNT_AND_PERMISSION_ROW", i64, i8, %"class.TPCE::CRandom" }
%"struct.TPCE::CUSTOMER_ACCOUNT_AND_PERMISSION_ROW" = type { %"struct.TPCE::CUSTOMER_ACCOUNT_ROW", [4 x %"struct.TPCE::ACCOUNT_PERMISSION_ROW"] }
%"struct.TPCE::CUSTOMER_ACCOUNT_ROW" = type { i64, i64, i64, [51 x i8], i8, double }
%"struct.TPCE::ACCOUNT_PERMISSION_ROW" = type { i64, [5 x i8], [21 x i8], [26 x i8], [21 x i8] }
%"class.TPCE::CHoldingsAndTradesTable" = type { %"class.TPCE::CRandom", %"class.TPCE::CCustomerAccountsAndPermissionsTable", i64, i32, [18 x i64], i8, i64, i32, ptr, i64, i32, ptr }
%"class.TPCE::CBrokersTable" = type { %"class.TPCE::TableTemplate.3", i64, i64, i64, %"class.TPCE::CPerson", ptr, ptr, ptr }
%"class.TPCE::TableTemplate.3" = type { ptr, %"struct.TPCE::BROKER_ROW", i64, i8, %"class.TPCE::CRandom" }
%"struct.TPCE::BROKER_ROW" = type { i64, [5 x i8], [50 x i8], i32, double }
%"class.TPCE::CSecurityTable" = type { %"class.TPCE::TableTemplate.4", i64, i64, ptr, ptr, %"class.TPCE::CDateTime", i32, i32, i32, i64 }
%"class.TPCE::TableTemplate.4" = type { ptr, %"struct.TPCE::SECURITY_ROW", i64, i8, %"class.TPCE::CRandom" }
%"struct.TPCE::SECURITY_ROW" = type { [16 x i8], [7 x i8], [5 x i8], [71 x i8], [7 x i8], i64, i64, %"class.TPCE::CDateTime", %"class.TPCE::CDateTime", double, float, %"class.TPCE::CDateTime", float, %"class.TPCE::CDateTime", double, double }
%"class.TPCE::CPerson" = type { ptr, ptr, ptr, %"class.TPCE::CRandom", i8, i32, i64, ptr, ptr }
%"class.TPCE::CDateTime" = type { i32, i32, ptr }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<TPCE::TTradeInfo, std::allocator<TPCE::TTradeInfo>>::_Vector_impl" }
%"struct.std::_Vector_base<TPCE::TTradeInfo, std::allocator<TPCE::TTradeInfo>>::_Vector_impl" = type { %"struct.std::_Vector_base<TPCE::TTradeInfo, std::allocator<TPCE::TTradeInfo>>::_Vector_impl_data" }
%"struct.std::_Vector_base<TPCE::TTradeInfo, std::allocator<TPCE::TTradeInfo>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.TPCE::TTradeInfo" = type <{ i64, i32, i32, double, double, double, i64, i32, i32, %"class.TPCE::CMoney", %"class.TPCE::CMoney", i64, i32, [4 x i8], i64, i8, [7 x i8] }>
%"class.TPCE::CMoney" = type { i64 }
%"struct.TPCE::TAdditionalTradeInfo" = type { %"class.TPCE::CMoney", %"class.TPCE::CMoney", i64, i32, %"class.TPCE::CMoney", %"class.TPCE::CMoney", %"class.TPCE::CMoney", %"class.TPCE::CMoney" }
%"struct.TPCE::TTradeRow" = type { %"struct.TPCE::TRADE_ROW", %"struct.TPCE::TRADE_REQUEST_ROW", [3 x %"struct.TPCE::TRADE_HISTORY_ROW"], %"struct.TPCE::SETTLEMENT_ROW", %"struct.TPCE::CASH_TRANSACTION_ROW", [8 x %"struct.TPCE::HOLDING_HISTORY_ROW"] }
%"struct.TPCE::TRADE_ROW" = type <{ i64, %"class.TPCE::CDateTime", [5 x i8], [4 x i8], i8, [16 x i8], [2 x i8], i32, double, i64, [50 x i8], [6 x i8], double, double, double, double, i8, [7 x i8] }>
%"struct.TPCE::TRADE_REQUEST_ROW" = type { i64, [4 x i8], [16 x i8], i32, double, i64 }
%"struct.TPCE::TRADE_HISTORY_ROW" = type <{ i64, %"class.TPCE::CDateTime", [5 x i8], [3 x i8] }>
%"struct.TPCE::SETTLEMENT_ROW" = type { i64, [41 x i8], %"class.TPCE::CDateTime", double }
%"struct.TPCE::CASH_TRANSACTION_ROW" = type <{ i64, %"class.TPCE::CDateTime", double, [101 x i8], [3 x i8] }>
%"struct.TPCE::HOLDING_HISTORY_ROW" = type { i64, i64, i32, i32 }
%"struct.TPCE::HOLDING_ROW" = type <{ i64, i64, [16 x i8], %"class.TPCE::CDateTime", double, i32, [4 x i8] }>
%"struct.TPCE::HOLDING_SUMMARY_ROW" = type { i64, [16 x i8], i32 }
%"class.TPCE::CMEESecurity" = type { %"class.TPCE::CRandom", %"class.TPCE::CMoney", %"class.TPCE::CMoney", %"class.TPCE::CMoney", i32, i32, ptr, ptr, double }
%"struct.std::_List_iterator" = type { ptr }

@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__._ZN4TPCE9CTradeGen17GenerateTradeTypeEv = external hidden unnamed_addr constant [50 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4TPCE9CTradeGen17GenerateTradeTypeEv(ptr noundef nonnull align 8 dereferenceable(7356) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %6 = getelementptr inbounds %"class.TPCE::CTradeGen", ptr %5, i32 0, i32 0
  %7 = call noundef i32 @_ZN4TPCE7CRandom28RndGenerateIntegerPercentageEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  store i32 %7, ptr %4, align 4, !tbaa !11
  %8 = load i32, ptr %4, align 4, !tbaa !11
  %9 = icmp sle i32 %8, 30
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %32

11:                                               ; preds = %1
  %12 = load i32, ptr %4, align 4, !tbaa !11
  %13 = icmp sle i32 %12, 60
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %31

15:                                               ; preds = %11
  %16 = load i32, ptr %4, align 4, !tbaa !11
  %17 = icmp sle i32 %16, 80
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store i32 4, ptr %3, align 4, !tbaa !9
  br label %30

19:                                               ; preds = %15
  %20 = load i32, ptr %4, align 4, !tbaa !11
  %21 = icmp sle i32 %20, 90
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store i32 3, ptr %3, align 4, !tbaa !9
  br label %29

23:                                               ; preds = %19
  %24 = load i32, ptr %4, align 4, !tbaa !11
  %25 = icmp sle i32 %24, 100
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store i32 2, ptr %3, align 4, !tbaa !9
  br label %28

27:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 868, ptr noundef @__PRETTY_FUNCTION__._ZN4TPCE9CTradeGen17GenerateTradeTypeEv) #5
  unreachable

28:                                               ; preds = %26
  br label %29

29:                                               ; preds = %28, %22
  br label %30

30:                                               ; preds = %29, %18
  br label %31

31:                                               ; preds = %30, %14
  br label %32

32:                                               ; preds = %31, %10
  %33 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %33
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4TPCE7CRandom28RndGenerateIntegerPercentageEv(ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { 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 = { nounwind }
attributes #5 = { noreturn 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 = !{!"_ZTSN4TPCE12eTradeTypeIDE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__._ZN4TPCE9CTradeGen17GenerateTradeTypeEv = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZN4TPCE9CTradeGen17GenerateTradeTypeEv(ptr noundef nonnull align 8 dereferenceable(7356) %0) local_unnamed_addr #1 align 2 {
  %2 = tail call noundef i32 @_ZN4TPCE7CRandom28RndGenerateIntegerPercentageEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %3 = icmp slt i32 %2, 31
  br i1 %3, label %13, label %4

4:                                                ; preds = %1
  %5 = icmp ult i32 %2, 61
  br i1 %5, label %13, label %6

6:                                                ; preds = %4
  %7 = icmp ult i32 %2, 81
  br i1 %7, label %13, label %8

8:                                                ; preds = %6
  %9 = icmp ult i32 %2, 91
  br i1 %9, label %13, label %10

10:                                               ; preds = %8
  %11 = icmp ult i32 %2, 101
  br i1 %11, label %13, label %12

12:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 868, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4TPCE9CTradeGen17GenerateTradeTypeEv) #3
  unreachable

13:                                               ; preds = %10, %8, %6, %4, %1
  %.0 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 4, %6 ], [ 3, %8 ], [ 2, %10 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4TPCE7CRandom28RndGenerateIntegerPercentageEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

attributes #0 = { noreturn 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 #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 = { 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 #3 = { noreturn 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)"}


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