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

; 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: mustprogress uwtable
define dso_local void @_ZN5sc_dt8scfx_repC2Ej(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !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 !16
  %11 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 3
  store i32 0, ptr %11, align 8, !tbaa !17
  %12 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 4
  store i32 0, ptr %12, align 4, !tbaa !18
  %13 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 5
  store i32 0, ptr %13, align 8, !tbaa !19
  %14 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 6
  store i8 0, ptr %14, align 4, !tbaa !20
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %33

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 %29

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 !19
  %21 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 4
  store i32 2, ptr %21, align 4, !tbaa !18
  %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 !17
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 0
  %26 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %25, i32 noundef 2)
          to label %27 unwind label %29

27:                                               ; preds = %19
  store i32 %24, ptr %26, align 4, !tbaa !9
  %28 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %7, i32 0, i32 2
  store i32 1, ptr %28, align 4, !tbaa !16
  br label %35

29:                                               ; preds = %33, %19, %17
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %5, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %6, align 4
  call void @_ZN5sc_dt9scfx_mantD2Ev(ptr noundef nonnull align 8 dereferenceable(12) %8) #3
  br label %36

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

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34, %27
  ret void

36:                                               ; preds = %29
  %37 = load ptr, ptr %5, align 8
  %38 = load i32, ptr %6, align 4
  %39 = insertvalue { ptr, i32 } poison, ptr %37, 0
  %40 = insertvalue { ptr, i32 } %39, i32 %38, 1
  resume { ptr, i32 } %40
}

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


; 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: mustprogress uwtable
define dso_local void @_ZN5sc_dt8scfx_repC2Ej(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 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 i32 %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 %13, label %8

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

9:                                                ; preds = %8
  store i32 2, ptr %7, align 8, !tbaa !5
  store i32 2, ptr %6, align 4, !tbaa !14
  store i32 2, ptr %3, align 8, !tbaa !15
  store i32 0, ptr %5, align 8, !tbaa !16
  %10 = 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 %1, ptr %10, align 4, !tbaa !17
  store i32 1, ptr %4, align 4, !tbaa !18
  br label %14

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

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

14:                                               ; preds = %13, %9
  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, !11, i64 16}
!16 = !{!6, !12, i64 24}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 20}


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