; LLVM IR from stonne-simulator/omega :: omega-code/stonne/src/Accumulator.ll (ZN11Accumulator5routeEv)

; 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.Accumulator = type { %class.Unit, i32, i32, i32, i32, i32, i32, ptr, ptr, i32, i32, ptr, ptr, i32, i32, %class.ASwitchStats, ptr, i32, i32, i32, [4 x i8], %class.AccumulatorStats }
%class.Unit = type { ptr, i32, %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.ASwitchStats = type <{ %class.Stats, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i8] }>
%class.Stats = type { ptr }
%class.AccumulatorStats = type <{ %class.Stats, i32, i32, i32, i32, i32, i32, i32, [4 x i8] }>

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #0

declare noundef zeroext i1 @_ZN4Fifo7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(120)) #1

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

declare noundef ptr @_ZN4Fifo3popEv(ptr noundef nonnull align 8 dereferenceable(120)) #1

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

declare void @_ZN4Fifo4pushEP11DataPackage(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11Accumulator28perform_operation_2_operandsEP11DataPackageS1_(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef, ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11Accumulator5routeEv(ptr noundef nonnull align 8 dereferenceable(232) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %6 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 7
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = call noundef zeroext i1 @_ZN4Fifo7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(120) %7)
  br i1 %8, label %65, label %9

9:                                                ; preds = %1
  %10 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 7
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = call noundef ptr @_ZN4Fifo3popEv(ptr noundef nonnull align 8 dereferenceable(120) %11)
  store ptr %12, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %13 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 18
  %14 = load i32, ptr %13, align 4, !tbaa !20
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %23

16:                                               ; preds = %9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 16
  store ptr %17, ptr %18, align 8, !tbaa !21
  %19 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 21
  %20 = getelementptr inbounds %class.AccumulatorStats, ptr %19, i32 0, i32 6
  %21 = load i32, ptr %20, align 4, !tbaa !22
  %22 = add i32 %21, 1
  store i32 %22, ptr %20, align 4, !tbaa !22
  br label %47

23:                                               ; preds = %9
  %24 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 16
  %25 = load ptr, ptr %24, align 8, !tbaa !21
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call noundef ptr @_ZN11Accumulator28perform_operation_2_operandsEP11DataPackageS1_(ptr noundef nonnull align 8 dereferenceable(232) %5, ptr noundef %25, ptr noundef %26)
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 21
  %29 = getelementptr inbounds %class.AccumulatorStats, ptr %28, i32 0, i32 5
  %30 = load i32, ptr %29, align 8, !tbaa !23
  %31 = add i32 %30, 1
  store i32 %31, ptr %29, align 8, !tbaa !23
  %32 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 16
  %33 = load ptr, ptr %32, align 8, !tbaa !21
  %34 = icmp eq ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %23
  call void @_ZN11DataPackageD1Ev(ptr noundef nonnull align 8 dereferenceable(64) %33) #5
  call void @_ZdlPvm(ptr noundef %33, i64 noundef 64) #6
  br label %36

36:                                               ; preds = %35, %23
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = icmp eq ptr %37, null
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  call void @_ZN11DataPackageD1Ev(ptr noundef nonnull align 8 dereferenceable(64) %37) #5
  call void @_ZdlPvm(ptr noundef %37, i64 noundef 64) #6
  br label %40

40:                                               ; preds = %39, %36
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 16
  store ptr %41, ptr %42, align 8, !tbaa !21
  %43 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 21
  %44 = getelementptr inbounds %class.AccumulatorStats, ptr %43, i32 0, i32 6
  %45 = load i32, ptr %44, align 4, !tbaa !22
  %46 = add i32 %45, 1
  store i32 %46, ptr %44, align 4, !tbaa !22
  br label %47

47:                                               ; preds = %40, %16
  %48 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 18
  %49 = load i32, ptr %48, align 4, !tbaa !20
  %50 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 17
  %51 = load i32, ptr %50, align 8, !tbaa !24
  %52 = sub i32 %51, 1
  %53 = icmp eq i32 %49, %52
  br i1 %53, label %54, label %60

54:                                               ; preds = %47
  %55 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 8
  %56 = load ptr, ptr %55, align 8, !tbaa !25
  %57 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 16
  %58 = load ptr, ptr %57, align 8, !tbaa !21
  call void @_ZN4Fifo4pushEP11DataPackage(ptr noundef nonnull align 8 dereferenceable(120) %56, ptr noundef %58)
  %59 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 18
  store i32 0, ptr %59, align 4, !tbaa !20
  br label %64

60:                                               ; preds = %47
  %61 = getelementptr inbounds %class.Accumulator, ptr %5, i32 0, i32 18
  %62 = load i32, ptr %61, align 4, !tbaa !20
  %63 = add i32 %62, 1
  store i32 %63, ptr %61, align 4, !tbaa !20
  br label %64

64:                                               ; preds = %60, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %65

65:                                               ; preds = %64, %1
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: nounwind
declare void @_ZN11DataPackageD1Ev(ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #4

attributes #0 = { nobuiltin 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 "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 = { builtin 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, !6, i64 72}
!10 = !{!"_ZTS11Accumulator", !11, i64 0, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !6, i64 72, !6, i64 80, !16, i64 88, !12, i64 92, !6, i64 96, !6, i64 104, !12, i64 112, !12, i64 116, !17, i64 120, !6, i64 168, !12, i64 176, !12, i64 180, !12, i64 184, !19, i64 192}
!11 = !{!"_ZTS4Unit", !12, i64 8, !13, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !15, i64 8, !7, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTS16adderoperation_t", !7, i64 0}
!17 = !{!"_ZTS12ASwitchStats", !18, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40}
!18 = !{!"_ZTS5Stats"}
!19 = !{!"_ZTS16AccumulatorStats", !18, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32}
!20 = !{!10, !12, i64 180}
!21 = !{!10, !6, i64 168}
!22 = !{!10, !12, i64 220}
!23 = !{!10, !12, i64 216}
!24 = !{!10, !12, i64 176}
!25 = !{!10, !6, i64 80}


; 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"

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

declare noundef zeroext i1 @_ZN4Fifo7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(120)) local_unnamed_addr #1

declare noundef ptr @_ZN4Fifo3popEv(ptr noundef nonnull align 8 dereferenceable(120)) local_unnamed_addr #1

declare void @_ZN4Fifo4pushEP11DataPackage(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11Accumulator5routeEv(ptr noundef nonnull align 8 dereferenceable(232) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call noundef zeroext i1 @_ZN4Fifo7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(120) %3)
  br i1 %4, label %45, label %5

5:                                                ; preds = %1
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = tail call noundef ptr @_ZN4Fifo3popEv(ptr noundef nonnull align 8 dereferenceable(120) %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 180
  %9 = load i32, ptr %8, align 4, !tbaa !19
  %10 = icmp eq i32 %9, 0
  %11 = getelementptr inbounds i8, ptr %0, i64 168
  br i1 %10, label %12, label %16

12:                                               ; preds = %5
  store ptr %7, ptr %11, align 8, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %0, i64 220
  %14 = load i32, ptr %13, align 4, !tbaa !21
  %15 = add i32 %14, 1
  store i32 %15, ptr %13, align 4, !tbaa !21
  br label %32

16:                                               ; preds = %5
  %17 = load ptr, ptr %11, align 8, !tbaa !20
  %18 = tail call noundef ptr @_ZN11Accumulator28perform_operation_2_operandsEP11DataPackageS1_(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef %17, ptr noundef %7)
  %19 = getelementptr inbounds i8, ptr %0, i64 216
  %20 = load i32, ptr %19, align 8, !tbaa !22
  %21 = add i32 %20, 1
  store i32 %21, ptr %19, align 8, !tbaa !22
  %22 = load ptr, ptr %11, align 8, !tbaa !20
  %23 = icmp eq ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %16
  tail call void @_ZN11DataPackageD1Ev(ptr noundef nonnull align 8 dereferenceable(64) %22) #4
  tail call void @_ZdlPvm(ptr noundef nonnull %22, i64 noundef 64) #5
  br label %25

25:                                               ; preds = %24, %16
  %26 = icmp eq ptr %7, null
  br i1 %26, label %28, label %27

27:                                               ; preds = %25
  tail call void @_ZN11DataPackageD1Ev(ptr noundef nonnull align 8 dereferenceable(64) %7) #4
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 64) #5
  br label %28

28:                                               ; preds = %27, %25
  store ptr %18, ptr %11, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %0, i64 220
  %30 = load i32, ptr %29, align 4, !tbaa !21
  %31 = add i32 %30, 1
  store i32 %31, ptr %29, align 4, !tbaa !21
  %.pre = load i32, ptr %8, align 4, !tbaa !19
  br label %32

32:                                               ; preds = %28, %12
  %33 = phi ptr [ %18, %28 ], [ %7, %12 ]
  %34 = phi i32 [ %.pre, %28 ], [ 0, %12 ]
  %35 = getelementptr inbounds i8, ptr %0, i64 176
  %36 = load i32, ptr %35, align 8, !tbaa !23
  %37 = add i32 %36, -1
  %38 = icmp eq i32 %34, %37
  br i1 %38, label %39, label %42

39:                                               ; preds = %32
  %40 = getelementptr inbounds i8, ptr %0, i64 80
  %41 = load ptr, ptr %40, align 8, !tbaa !24
  tail call void @_ZN4Fifo4pushEP11DataPackage(ptr noundef nonnull align 8 dereferenceable(120) %41, ptr noundef %33)
  br label %44

42:                                               ; preds = %32
  %43 = add i32 %34, 1
  br label %44

44:                                               ; preds = %42, %39
  %storemerge = phi i32 [ %43, %42 ], [ 0, %39 ]
  store i32 %storemerge, ptr %8, align 4, !tbaa !19
  br label %45

45:                                               ; preds = %44, %1
  ret void
}

; Function Attrs: nounwind
declare void @_ZN11DataPackageD1Ev(ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #3

attributes #0 = { nobuiltin 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 = { "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 = { 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 = { nounwind }
attributes #5 = { builtin 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, !13, i64 72}
!6 = !{!"_ZTS11Accumulator", !7, i64 0, !8, i64 48, !8, i64 52, !8, i64 56, !8, i64 60, !8, i64 64, !8, i64 68, !13, i64 72, !13, i64 80, !15, i64 88, !8, i64 92, !13, i64 96, !13, i64 104, !8, i64 112, !8, i64 116, !16, i64 120, !13, i64 168, !8, i64 176, !8, i64 180, !8, i64 184, !18, i64 192}
!7 = !{!"_ZTS4Unit", !8, i64 8, !11, i64 16}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !14, i64 8, !9, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!"long", !9, i64 0}
!15 = !{!"_ZTS16adderoperation_t", !9, i64 0}
!16 = !{!"_ZTS12ASwitchStats", !17, i64 0, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28, !8, i64 32, !8, i64 36, !8, i64 40}
!17 = !{!"_ZTS5Stats"}
!18 = !{!"_ZTS16AccumulatorStats", !17, i64 0, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28, !8, i64 32}
!19 = !{!6, !8, i64 180}
!20 = !{!6, !13, i64 168}
!21 = !{!6, !8, i64 220}
!22 = !{!6, !8, i64 216}
!23 = !{!6, !8, i64 176}
!24 = !{!6, !13, i64 80}


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