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

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

@.str = external hidden unnamed_addr constant [71 x i8], align 1
@_ZTISt11range_error = external constant ptr
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE15BucketSimulatorC2EiixxyRNS_14BucketProgressE(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef nonnull align 8 dereferenceable(128) %6) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i64 %3, ptr %11, align 8, !tbaa !11
  store i64 %4, ptr %12, align 8, !tbaa !11
  store i64 %5, ptr %13, align 8, !tbaa !11
  store ptr %6, ptr %14, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8
  %18 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 0
  call void @_ZN4TPCE7CRandomC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %18)
  %19 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 1
  store ptr null, ptr %19, align 8, !tbaa !13
  %20 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 2
  %21 = load i64, ptr %11, align 8, !tbaa !11
  store i64 %21, ptr %20, align 8, !tbaa !16
  %22 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 3
  %23 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %23, ptr %22, align 8, !tbaa !17
  %24 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 4
  %25 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %25, ptr %24, align 4, !tbaa !18
  %26 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 5
  %27 = load i64, ptr %13, align 8, !tbaa !11
  store i64 %27, ptr %26, align 8, !tbaa !19
  %28 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 6
  %29 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %29, ptr %28, align 8, !tbaa !20
  %30 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 7
  %31 = load i64, ptr %11, align 8, !tbaa !11
  %32 = sdiv i64 %31, 1000
  %33 = trunc i64 %32 to i32
  store i32 %33, ptr %30, align 8, !tbaa !21
  %34 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 8
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %35, ptr %34, align 8, !tbaa !5
  %36 = load i64, ptr %11, align 8, !tbaa !11
  %37 = srem i64 %36, 1000
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %50

39:                                               ; preds = %7
  %40 = call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt11range_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %40, ptr noundef @.str)
          to label %41 unwind label %42

41:                                               ; preds = %39
  invoke void @__cxa_throw(ptr %40, ptr @_ZTISt11range_error, ptr @_ZNSt11range_errorD1Ev) #7
          to label %78 unwind label %46

42:                                               ; preds = %39
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %15, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %16, align 4
  call void @__cxa_free_exception(ptr %40) #6
  br label %72

46:                                               ; preds = %61, %56, %41
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %15, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %16, align 4
  br label %72

50:                                               ; preds = %7
  %51 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 7
  %52 = load i32, ptr %51, align 8, !tbaa !21
  %53 = icmp slt i32 %52, 2
  br i1 %53, label %54, label %61

54:                                               ; preds = %50
  %55 = call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt11range_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %55, ptr noundef @.str.1)
          to label %56 unwind label %57

56:                                               ; preds = %54
  invoke void @__cxa_throw(ptr %55, ptr @_ZTISt11range_error, ptr @_ZNSt11range_errorD1Ev) #7
          to label %78 unwind label %46

57:                                               ; preds = %54
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %15, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %16, align 4
  call void @__cxa_free_exception(ptr %55) #6
  br label %72

61:                                               ; preds = %50
  %62 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 7
  %63 = load i32, ptr %62, align 8, !tbaa !21
  %64 = sext i32 %63 to i64
  %65 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %64, i64 8)
  %66 = extractvalue { i64, i1 } %65, 1
  %67 = extractvalue { i64, i1 } %65, 0
  %68 = select i1 %66, i64 -1, i64 %67
  %69 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %68) #8
          to label %70 unwind label %46

70:                                               ; preds = %61
  %71 = getelementptr inbounds %"class.TPCE::BucketSimulator", ptr %17, i32 0, i32 1
  store ptr %69, ptr %71, align 8, !tbaa !13
  ret void

72:                                               ; preds = %57, %46, %42
  call void @_ZN4TPCE7CRandomD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %18) #6
  br label %73

73:                                               ; preds = %72
  %74 = load ptr, ptr %15, align 8
  %75 = load i32, ptr %16, align 4
  %76 = insertvalue { ptr, i32 } poison, ptr %74, 0
  %77 = insertvalue { ptr, i32 } %76, i32 %75, 1
  resume { ptr, i32 } %77

78:                                               ; preds = %56, %41
  unreachable
}

declare void @_ZN4TPCE7CRandomC1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt11range_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt11range_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4TPCE7CRandomD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5 align 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 = { "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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nobuiltin allocsize(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 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }
attributes #8 = { builtin allocsize(0) }

!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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN4TPCE15BucketSimulatorE", !15, i64 0, !6, i64 8, !12, i64 16, !10, i64 24, !10, i64 28, !12, i64 32, !12, i64 40, !10, i64 48, !6, i64 56}
!15 = !{!"_ZTSN4TPCE7CRandomE", !12, i64 0}
!16 = !{!14, !12, i64 16}
!17 = !{!14, !10, i64 24}
!18 = !{!14, !10, i64 28}
!19 = !{!14, !12, i64 32}
!20 = !{!14, !12, i64 40}
!21 = !{!14, !10, i64 48}


; 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 = external hidden unnamed_addr constant [71 x i8], align 1
@_ZTISt11range_error = external constant ptr
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4TPCE15BucketSimulatorC2EiixxyRNS_14BucketProgressE(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef nonnull align 8 dereferenceable(128) %6) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4TPCE7CRandomC1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %3, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %1, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %2, ptr %11, align 4, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %5, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 %4, ptr %13, align 8, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = sdiv i64 %3, 1000
  %16 = trunc i64 %15 to i32
  store i32 %16, ptr %14, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %6, ptr %17, align 8, !tbaa !19
  %18 = srem i64 %3, 1000
  %.not = icmp eq i64 %18, 0
  br i1 %.not, label %25, label %19

19:                                               ; preds = %7
  %20 = tail call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt11range_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull @.str)
          to label %.invoke unwind label %21

21:                                               ; preds = %19
  %22 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %20) #5
  br label %37

23:                                               ; preds = %.invoke, %32
  %24 = landingpad { ptr, i32 }
          cleanup
  br label %37

25:                                               ; preds = %7
  %26 = icmp slt i32 %16, 2
  br i1 %26, label %27, label %32

27:                                               ; preds = %25
  %28 = tail call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt11range_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull @.str.1)
          to label %.invoke unwind label %30

.invoke:                                          ; preds = %19, %27
  %29 = phi ptr [ %28, %27 ], [ %20, %19 ]
  invoke void @__cxa_throw(ptr nonnull %29, ptr nonnull @_ZTISt11range_error, ptr nonnull @_ZNSt11range_errorD1Ev) #6
          to label %.cont unwind label %23

.cont:                                            ; preds = %.invoke
  unreachable

30:                                               ; preds = %27
  %31 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %28) #5
  br label %37

32:                                               ; preds = %25
  %33 = shl nsw i64 %15, 3
  %34 = and i64 %33, 17179869176
  %35 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %34) #7
          to label %36 unwind label %23

36:                                               ; preds = %32
  store ptr %35, ptr %8, align 8, !tbaa !5
  ret void

37:                                               ; preds = %30, %23, %21
  %.pn = phi { ptr, i32 } [ %24, %23 ], [ %22, %21 ], [ %31, %30 ]
  tail call void @_ZN4TPCE7CRandomD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  resume { ptr, i32 } %.pn
}

declare void @_ZN4TPCE7CRandomC1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt11range_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt11range_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4TPCE7CRandomD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 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 = { "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 = { 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 #3 = { nobuiltin allocsize(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 }
attributes #6 = { noreturn }
attributes #7 = { builtin allocsize(0) }

!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, !11, i64 8}
!6 = !{!"_ZTSN4TPCE15BucketSimulatorE", !7, i64 0, !11, i64 8, !8, i64 16, !12, i64 24, !12, i64 28, !8, i64 32, !8, i64 40, !12, i64 48, !11, i64 56}
!7 = !{!"_ZTSN4TPCE7CRandomE", !8, i64 0}
!8 = !{!"long long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!6, !8, i64 16}
!14 = !{!6, !12, i64 24}
!15 = !{!6, !12, i64 28}
!16 = !{!6, !8, i64 32}
!17 = !{!6, !8, i64 40}
!18 = !{!6, !12, i64 48}
!19 = !{!11, !11, i64 0}


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