; LLVM IR from wangziqi2013/EpochManager :: test/basic_test.ll (Z9MixedTestmm)

; 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.peloton::index::AtomicStack" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { ptr }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i64 }
%class.anon.3 = type { ptr, ptr, ptr, i64, i64 }

@.str.2 = external hidden unnamed_addr constant [79 x i8], align 1
@stderr = external global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@stdout = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@__PRETTY_FUNCTION__._Z9MixedTestmm = external hidden unnamed_addr constant [35 x i8], align 1

declare void @_Z13PrintTestNamePKc(ptr noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7peloton5index11AtomicStackImEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i32 noundef) #4 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4 align 2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #5

declare i32 @fflush(ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9MixedTestmm(i64 noundef %0, i64 noundef %1) #6 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %"class.peloton::index::AtomicStack", align 8
  %6 = alloca %"struct.std::atomic.0", align 8
  %7 = alloca %"struct.std::atomic.0", align 8
  %8 = alloca %class.anon.3, align 8
  %9 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  call void @_Z13PrintTestNamePKc(ptr noundef @.str.8)
  %10 = load i64, ptr %3, align 8, !tbaa !5
  %11 = urem i64 %10, 2
  %12 = icmp ne i64 %11, 0
  br i1 %12, label %13, label %20

13:                                               ; preds = %2
  br label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef @.str.9, ptr noundef @.str.8) #7
  %17 = load ptr, ptr @stdout, align 8, !tbaa !9
  %18 = call i32 @fflush(ptr noundef %17)
  br label %19

19:                                               ; preds = %14
  br label %65

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @_ZN7peloton5index11AtomicStackImEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %7, i64 noundef 0, i32 noundef 5) #7
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %6, i64 noundef 0, i32 noundef 5) #7
  call void @llvm.lifetime.start.p0(i64 40, ptr %8) #7
  %21 = getelementptr inbounds %class.anon.3, ptr %8, i32 0, i32 0
  store ptr %5, ptr %21, align 8, !tbaa !9
  %22 = getelementptr inbounds %class.anon.3, ptr %8, i32 0, i32 1
  store ptr %6, ptr %22, align 8, !tbaa !9
  %23 = getelementptr inbounds %class.anon.3, ptr %8, i32 0, i32 2
  store ptr %7, ptr %23, align 8, !tbaa !9
  %24 = getelementptr inbounds %class.anon.3, ptr %8, i32 0, i32 3
  %25 = load i64, ptr %3, align 8, !tbaa !5
  store i64 %25, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %class.anon.3, ptr %8, i32 0, i32 4
  %27 = load i64, ptr %4, align 8, !tbaa !5
  store i64 %27, ptr %26, align 8, !tbaa !13
  %28 = load i64, ptr %3, align 8, !tbaa !5
  call void @"_Z12StartThreadsIRZ9MixedTestmmE3$_0JEEvmOT_DpOT0_"(i64 noundef %28, ptr noundef nonnull align 8 dereferenceable(40) %8)
  %29 = load i64, ptr %3, align 8, !tbaa !5
  %30 = lshr i64 %29, 1
  store i64 %30, ptr %3, align 8, !tbaa !5
  %31 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef 5) #7
  %32 = load i64, ptr %3, align 8, !tbaa !5
  %33 = load i64, ptr %4, align 8, !tbaa !5
  %34 = mul i64 %32, %33
  %35 = icmp eq i64 %31, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %20
  br label %39

37:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.2, i32 noundef 144, ptr noundef @__PRETTY_FUNCTION__._Z9MixedTestmm) #8
  unreachable

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %40 = load i64, ptr %4, align 8, !tbaa !5
  %41 = load i64, ptr %3, align 8, !tbaa !5
  %42 = mul i64 %40, %41
  %43 = load i64, ptr %4, align 8, !tbaa !5
  %44 = load i64, ptr %3, align 8, !tbaa !5
  %45 = mul i64 %43, %44
  %46 = sub i64 %45, 1
  %47 = mul i64 %42, %46
  %48 = udiv i64 %47, 2
  store i64 %48, ptr %9, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %39
  %50 = load ptr, ptr @stderr, align 8, !tbaa !9
  %51 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef 5) #7
  %52 = load i64, ptr %9, align 8, !tbaa !5
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.6, ptr noundef @.str.8, i64 noundef %51, i64 noundef %52) #7
  %54 = load ptr, ptr @stdout, align 8, !tbaa !9
  %55 = call i32 @fflush(ptr noundef %54)
  br label %56

56:                                               ; preds = %49
  br label %57

57:                                               ; preds = %56
  %58 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef 5) #7
  %59 = load i64, ptr %9, align 8, !tbaa !5
  %60 = icmp eq i64 %58, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %57
  br label %64

62:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.2, i32 noundef 149, ptr noundef @__PRETTY_FUNCTION__._Z9MixedTestmm) #8
  unreachable

63:                                               ; No predecessors!
  br label %64

64:                                               ; preds = %63, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %65

65:                                               ; preds = %64, %19
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @"_Z12StartThreadsIRZ9MixedTestmmE3$_0JEEvmOT_DpOT0_"(i64 noundef, ptr noundef nonnull align 8 dereferenceable(40)) #6

attributes #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 = { 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 = { 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 = { alwaysinline 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 "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 = { 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 #7 = { nounwind }
attributes #8 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 24}
!12 = !{!"_ZTSZ9MixedTestmmE3$_0", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!12, !6, i64 32}


; 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.peloton::index::AtomicStack" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { ptr }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i64 }
%class.anon.3 = type { ptr, ptr, ptr, i64, i64 }

@.str.2 = external hidden unnamed_addr constant [79 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@__PRETTY_FUNCTION__._Z9MixedTestmm = external hidden unnamed_addr constant [35 x i8], align 1

declare void @_Z13PrintTestNamePKc(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7peloton5index11AtomicStackImEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9MixedTestmm(i64 noundef %0, i64 noundef %1) local_unnamed_addr #6 {
  %3 = alloca %"class.peloton::index::AtomicStack", align 8
  %4 = alloca %"struct.std::atomic.0", align 8
  %5 = alloca %"struct.std::atomic.0", align 8
  %6 = alloca %class.anon.3, align 8
  tail call void @_Z13PrintTestNamePKc(ptr noundef nonnull @.str.8)
  %7 = and i64 %0, 1
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %13, label %8

8:                                                ; preds = %2
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.8) #7
  %11 = load ptr, ptr @stdout, align 8, !tbaa !5
  %12 = tail call i32 @fflush(ptr noundef %11)
  br label %36

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  call void @_ZN7peloton5index11AtomicStackImEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef 0, i32 noundef 5) #8
  call void @_ZNSt13__atomic_baseImE5storeEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %4, i64 noundef 0, i32 noundef 5) #8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #8
  store ptr %3, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %4, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %5, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %6, i64 24
  store i64 %0, ptr %16, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %6, i64 32
  store i64 %1, ptr %17, align 8, !tbaa !12
  call void @"_Z12StartThreadsIRZ9MixedTestmmE3$_0JEEvmOT_DpOT0_"(i64 noundef %0, ptr noundef nonnull align 8 dereferenceable(40) %6)
  %18 = lshr exact i64 %0, 1
  %19 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef 5) #8
  %20 = mul i64 %18, %1
  %21 = icmp eq i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %13
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2, i32 noundef 144, ptr noundef nonnull @__PRETTY_FUNCTION__._Z9MixedTestmm) #9
  unreachable

23:                                               ; preds = %13
  %24 = add i64 %19, -1
  %25 = mul i64 %24, %19
  %26 = lshr i64 %25, 1
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef 5) #8
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.8, i64 noundef %28, i64 noundef %26) #7
  %30 = load ptr, ptr @stdout, align 8, !tbaa !5
  %31 = call i32 @fflush(ptr noundef %30)
  %32 = call noundef i64 @_ZNKSt13__atomic_baseImE4loadESt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef 5) #8
  %33 = icmp eq i64 %32, %26
  br i1 %33, label %35, label %34

34:                                               ; preds = %23
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.2, i32 noundef 149, ptr noundef nonnull @__PRETTY_FUNCTION__._Z9MixedTestmm) #9
  unreachable

35:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  br label %36

36:                                               ; preds = %35, %8
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @"_Z12StartThreadsIRZ9MixedTestmmE3$_0JEEvmOT_DpOT0_"(i64 noundef, ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #6

attributes #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 = { 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 = { 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 = { alwaysinline 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 = { nofree 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 #6 = { 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 #7 = { cold nounwind }
attributes #8 = { nounwind }
attributes #9 = { 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, !11, i64 24}
!10 = !{!"_ZTSZ9MixedTestmmE3$_0", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 32}


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