; LLVM IR from gem5/gem5 :: ext/systemc/src/sysc/datatypes/fx/scfx_rep.ll (ZN5sc_dt8scfx_repC2Em)

; 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.sc_dt::scfx_rep" = type <{ %"class.sc_dt::scfx_mant", i32, i32, i32, i32, i32, i8, [3 x i8] }>
%"class.sc_dt::scfx_mant" = type <{ ptr, i32, [4 x i8] }>

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt9scfx_mantC2Em(ptr noundef nonnull align 8 dereferenceable(12), i64 noundef) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt8scfx_rep8set_zeroEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt9scfx_mant5clearEv(ptr noundef nonnull align 8 dereferenceable(12)) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt8scfx_rep7find_swEv(ptr noundef nonnull align 8 dereferenceable(37)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5sc_dt8scfx_repC2Em(ptr noundef nonnull align 8 dereferenceable(37) %0, i64 noundef %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 0
  call void @_ZN5sc_dt9scfx_mantC2Em(ptr noundef nonnull align 8 dereferenceable(12) %8, i64 noundef 4)
  %9 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 1
  store i32 0, ptr %9, align 8, !tbaa !11
  %10 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 2
  store i32 0, ptr %10, align 4, !tbaa !17
  %11 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 3
  store i32 0, ptr %11, align 8, !tbaa !18
  %12 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 4
  store i32 0, ptr %12, align 4, !tbaa !19
  %13 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 5
  store i32 0, ptr %13, align 8, !tbaa !20
  %14 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 6
  store i8 0, ptr %14, align 4, !tbaa !21
  %15 = load i64, ptr %4, align 8, !tbaa !9
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %17, label %42

17:                                               ; preds = %2
  %18 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 0
  invoke void @_ZN5sc_dt9scfx_mant5clearEv(ptr noundef nonnull align 8 dereferenceable(12) %18)
          to label %19 unwind label %38

19:                                               ; preds = %17
  %20 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 5
  store i32 2, ptr %20, align 8, !tbaa !20
  %21 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 4
  store i32 2, ptr %21, align 4, !tbaa !19
  %22 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 1
  store i32 2, ptr %22, align 8, !tbaa !11
  %23 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 3
  store i32 0, ptr %23, align 8, !tbaa !18
  %24 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 1
  store i32 1, ptr %24, align 8, !tbaa !11
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = trunc i64 %25 to i32
  %27 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 0
  %28 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %27, i32 noundef 1)
          to label %29 unwind label %38

29:                                               ; preds = %19
  store i32 %26, ptr %28, align 4, !tbaa !22
  %30 = load i64, ptr %4, align 8, !tbaa !9
  %31 = lshr i64 %30, 32
  %32 = trunc i64 %31 to i32
  %33 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 0
  %34 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %33, i32 noundef 2)
          to label %35 unwind label %38

35:                                               ; preds = %29
  store i32 %32, ptr %34, align 4, !tbaa !22
  invoke void @_ZN5sc_dt8scfx_rep7find_swEv(ptr noundef nonnull align 8 dereferenceable(37) %7)
          to label %36 unwind label %38

36:                                               ; preds = %35
  %37 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 2
  store i32 1, ptr %37, align 4, !tbaa !17
  br label %44

38:                                               ; preds = %42, %35, %29, %19, %17
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %5, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %6, align 4
  call void @_ZN5sc_dt9scfx_mantD2Ev(ptr noundef nonnull align 8 dereferenceable(12) %8) #3
  br label %45

42:                                               ; preds = %2
  invoke void @_ZN5sc_dt8scfx_rep8set_zeroEi(ptr noundef nonnull align 8 dereferenceable(37) %7, i32 noundef 1)
          to label %43 unwind label %38

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43, %36
  ret void

45:                                               ; preds = %38
  %46 = load ptr, ptr %5, align 8
  %47 = load i32, ptr %6, align 4
  %48 = insertvalue { ptr, i32 } poison, ptr %46, 0
  %49 = insertvalue { ptr, i32 } %48, i32 %47, 1
  resume { ptr, i32 } %49
}

attributes #0 = { 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 #1 = { inlinehint 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 #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 }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 16}
!12 = !{!"_ZTSN5sc_dt8scfx_repE", !13, i64 0, !14, i64 16, !14, i64 20, !15, i64 24, !14, i64 28, !14, i64 32, !16, i64 36}
!13 = !{!"_ZTSN5sc_dt9scfx_mantE", !6, i64 0, !14, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSN5sc_dt8scfx_rep5stateE", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!12, !14, i64 20}
!18 = !{!12, !15, i64 24}
!19 = !{!12, !14, i64 28}
!20 = !{!12, !14, i64 32}
!21 = !{!12, !16, i64 36}
!22 = !{!14, !14, 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"

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt9scfx_mantC2Em(ptr noundef nonnull align 8 dereferenceable(12), i64 noundef) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt8scfx_rep8set_zeroEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt9scfx_mant5clearEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt8scfx_rep7find_swEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5sc_dt8scfx_repC2Em(ptr noundef nonnull align 8 dereferenceable(37) %0, i64 noundef %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN5sc_dt9scfx_mantC2Em(ptr noundef nonnull align 8 dereferenceable(12) %0, i64 noundef 4)
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = getelementptr inbounds i8, ptr %0, i64 20
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %.not = icmp eq i64 %1, 0
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(21) %3, i8 0, i64 21, i1 false)
  br i1 %.not, label %18, label %8

8:                                                ; preds = %2
  invoke void @_ZN5sc_dt9scfx_mant5clearEv(ptr noundef nonnull align 8 dereferenceable(12) %0)
          to label %9 unwind label %16

9:                                                ; preds = %8
  store i32 2, ptr %7, align 8, !tbaa !5
  store i32 2, ptr %6, align 4, !tbaa !14
  store i32 0, ptr %5, align 8, !tbaa !15
  store i32 1, ptr %3, align 8, !tbaa !16
  %10 = trunc i64 %1 to i32
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef 1)
  store i32 %10, ptr %11, align 4, !tbaa !17
  %12 = lshr i64 %1, 32
  %13 = trunc nuw i64 %12 to i32
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef 2)
  store i32 %13, ptr %14, align 4, !tbaa !17
  invoke void @_ZN5sc_dt8scfx_rep7find_swEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
          to label %15 unwind label %16

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

16:                                               ; preds = %18, %9, %8
  %17 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN5sc_dt9scfx_mantD2Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) #4
  resume { ptr, i32 } %17

18:                                               ; preds = %2
  invoke void @_ZN5sc_dt8scfx_rep8set_zeroEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef 1)
          to label %19 unwind label %16

19:                                               ; preds = %18, %15
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { 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 #1 = { inlinehint 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !11, i64 32}
!6 = !{!"_ZTSN5sc_dt8scfx_repE", !7, i64 0, !11, i64 16, !11, i64 20, !12, i64 24, !11, i64 28, !11, i64 32, !13, i64 36}
!7 = !{!"_ZTSN5sc_dt9scfx_mantE", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTSN5sc_dt8scfx_rep5stateE", !9, i64 0}
!13 = !{!"bool", !9, i64 0}
!14 = !{!6, !11, i64 28}
!15 = !{!6, !12, i64 24}
!16 = !{!6, !11, i64 16}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 20}


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