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

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

@_ZZN4TPCE14CCustomerTable13GenerateC_DOBEvE12age_brackets = external hidden global [10 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@__PRETTY_FUNCTION__._ZN4TPCE14CCustomerTable13GenerateC_DOBEv = external hidden unnamed_addr constant [43 x i8], align 1

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

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

14:                                               ; preds = %1
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp sle i32 %15, 21
  br i1 %16, label %17, label %18

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

18:                                               ; preds = %14
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = icmp sle i32 %19, 38
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store i32 2, ptr %3, align 4, !tbaa !9
  br label %48

22:                                               ; preds = %18
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = icmp sle i32 %23, 57
  br i1 %24, label %25, label %26

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

26:                                               ; preds = %22
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = icmp sle i32 %27, 73
  br i1 %28, label %29, label %30

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

30:                                               ; preds = %26
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp sle i32 %31, 84
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i32 5, ptr %3, align 4, !tbaa !9
  br label %45

34:                                               ; preds = %30
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = icmp sle i32 %35, 92
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  store i32 6, ptr %3, align 4, !tbaa !9
  br label %44

38:                                               ; preds = %34
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = icmp sle i32 %39, 99
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 7, ptr %3, align 4, !tbaa !9
  br label %43

42:                                               ; preds = %38
  store i32 8, ptr %3, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %42, %41
  br label %44

44:                                               ; preds = %43, %37
  br label %45

45:                                               ; preds = %44, %33
  br label %46

46:                                               ; preds = %45, %29
  br label %47

47:                                               ; preds = %46, %25
  br label %48

48:                                               ; preds = %47, %21
  br label %49

49:                                               ; preds = %48, %17
  br label %50

50:                                               ; preds = %49, %13
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 10
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  br label %56

54:                                               ; preds = %50
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 206, ptr noundef @__PRETTY_FUNCTION__._ZN4TPCE14CCustomerTable13GenerateC_DOBEv) #6
  unreachable

55:                                               ; No predecessors!
  br label %56

56:                                               ; preds = %55, %53
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [10 x i32], ptr @_ZZN4TPCE14CCustomerTable13GenerateC_DOBEvE12age_brackets, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = sub nsw i32 2005, %61
  %63 = call noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef %62, i32 noundef 1, i32 noundef 3)
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %4, align 4, !tbaa !9
  %65 = load i32, ptr %3, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [10 x i32], ptr @_ZZN4TPCE14CCustomerTable13GenerateC_DOBEvE12age_brackets, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = sub nsw i32 2005, %68
  %70 = call noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef %69, i32 noundef 1, i32 noundef 3)
  store i32 %70, ptr %5, align 4, !tbaa !9
  %71 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %8, i32 0, i32 4
  %72 = load i32, ptr %4, align 4, !tbaa !9
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = call noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8) %71, i32 noundef %72, i32 noundef %73)
  store i32 %74, ptr %6, align 4, !tbaa !9
  %75 = getelementptr inbounds %"class.TPCE::TableTemplate", ptr %8, i32 0, i32 1
  %76 = getelementptr inbounds %"struct.TPCE::CUSTOMER_ROW", ptr %75, i32 0, i32 9
  %77 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN4TPCE9CDateTime3SetEi(ptr noundef nonnull align 8 dereferenceable(16) %76, i32 noundef %77)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4TPCE7CRandom28RndGenerateIntegerPercentageEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

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

declare noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef, i32 noundef, i32 noundef) #4

declare noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef) #4

declare void @_ZN4TPCE9CDateTime3SetEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #4

; Function Attrs: 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 }
attributes #6 = { 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 = !{!"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"

@_ZZN4TPCE14CCustomerTable13GenerateC_DOBEvE12age_brackets = external hidden local_unnamed_addr global [10 x i32], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE14CCustomerTable13GenerateC_DOBEv(ptr noundef nonnull align 8 dereferenceable(496) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 320
  %3 = tail call noundef i32 @_ZN4TPCE7CRandom28RndGenerateIntegerPercentageEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %4 = icmp slt i32 %3, 6
  br i1 %4, label %19, label %5

5:                                                ; preds = %1
  %6 = icmp ult i32 %3, 22
  br i1 %6, label %19, label %7

7:                                                ; preds = %5
  %8 = icmp ult i32 %3, 39
  br i1 %8, label %19, label %9

9:                                                ; preds = %7
  %10 = icmp ult i32 %3, 58
  br i1 %10, label %19, label %11

11:                                               ; preds = %9
  %12 = icmp ult i32 %3, 74
  br i1 %12, label %19, label %13

13:                                               ; preds = %11
  %14 = icmp ult i32 %3, 85
  br i1 %14, label %19, label %15

15:                                               ; preds = %13
  %16 = icmp ult i32 %3, 93
  br i1 %16, label %19, label %17

17:                                               ; preds = %15
  %18 = icmp ult i32 %3, 100
  %. = select i1 %18, i32 7, i32 8
  br label %19

19:                                               ; preds = %1, %5, %7, %9, %11, %13, %15, %17
  %.0 = phi i32 [ 0, %1 ], [ 1, %5 ], [ 2, %7 ], [ 3, %9 ], [ 4, %11 ], [ 5, %13 ], [ 6, %15 ], [ %., %17 ]
  %20 = add nuw nsw i32 %.0, 1
  %21 = zext nneg i32 %20 to i64
  %22 = getelementptr inbounds [10 x i32], ptr @_ZZN4TPCE14CCustomerTable13GenerateC_DOBEvE12age_brackets, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sub nsw i32 2005, %23
  %25 = tail call noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef %24, i32 noundef 1, i32 noundef 3)
  %26 = add nsw i32 %25, 1
  %27 = zext nneg i32 %.0 to i64
  %28 = getelementptr inbounds [10 x i32], ptr @_ZZN4TPCE14CCustomerTable13GenerateC_DOBEvE12age_brackets, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sub nsw i32 2005, %29
  %31 = tail call noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef %30, i32 noundef 1, i32 noundef 3)
  %32 = tail call noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %26, i32 noundef %31)
  %33 = getelementptr inbounds i8, ptr %0, i64 96
  tail call void @_ZN4TPCE9CDateTime3SetEi(ptr noundef nonnull align 8 dereferenceable(16) %33, i32 noundef %32)
  ret void
}

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

declare noundef i32 @_ZN4TPCE9CDateTime10YMDtoDaynoEiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare noundef i32 @_ZN4TPCE7CRandom11RndIntRangeEii(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @_ZN4TPCE9CDateTime3SetEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #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 = { 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 #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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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