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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt13scfx_find_msbEm(i64 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_nanEv(ptr noundef nonnull align 8 dereferenceable(37)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_infEv(ptr noundef nonnull align 8 dereferenceable(37)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7is_zeroEv(ptr noundef nonnull align 8 dereferenceable(37)) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_negEv(ptr noundef nonnull align 8 dereferenceable(37)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt13scfx_find_lsbEm(i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK5sc_dt8scfx_rep8get_typeERiS1_RNS_6sc_encE(ptr noundef nonnull align 8 dereferenceable(37) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_nanEv(ptr noundef nonnull align 8 dereferenceable(37) %11)
  br i1 %12, label %15, label %13

13:                                               ; preds = %4
  %14 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_infEv(ptr noundef nonnull align 8 dereferenceable(37) %11)
  br i1 %14, label %15, label %19

15:                                               ; preds = %13, %4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %16, align 4, !tbaa !9
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !9
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %18, align 4, !tbaa !11
  br label %86

19:                                               ; preds = %13
  %20 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7is_zeroEv(ptr noundef nonnull align 8 dereferenceable(37) %11)
  br i1 %20, label %21, label %25

21:                                               ; preds = %19
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 1, ptr %22, align 4, !tbaa !9
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 1, ptr %23, align 4, !tbaa !9
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 1, ptr %24, align 4, !tbaa !11
  br label %86

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %26 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 4
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !18
  %30 = sub nsw i32 %27, %29
  %31 = mul nsw i32 %30, 32
  %32 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 0
  %33 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 4
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %32, i32 noundef %34)
  %36 = zext i32 %35 to i64
  %37 = call noundef i32 @_ZN5sc_dt13scfx_find_msbEm(i64 noundef %36)
  %38 = add nsw i32 %31, %37
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %49, %25
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37) %11, i32 noundef %41)
  %43 = zext i1 %42 to i32
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = sub nsw i32 %44, 1
  %46 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37) %11, i32 noundef %45)
  %47 = zext i1 %46 to i32
  %48 = icmp eq i32 %43, %47
  br i1 %48, label %49, label %52

49:                                               ; preds = %40
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr %9, align 4, !tbaa !9
  br label %40, !llvm.loop !19

52:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %53 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 5
  %54 = load i32, ptr %53, align 8, !tbaa !21
  %55 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 1
  %56 = load i32, ptr %55, align 8, !tbaa !18
  %57 = sub nsw i32 %54, %56
  %58 = mul nsw i32 %57, 32
  %59 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 0
  %60 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %11, i32 0, i32 5
  %61 = load i32, ptr %60, align 8, !tbaa !21
  %62 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %59, i32 noundef %61)
  %63 = zext i32 %62 to i64
  %64 = call noundef i32 @_ZN5sc_dt13scfx_find_lsbEm(i64 noundef %63)
  %65 = add nsw i32 %58, %64
  store i32 %65, ptr %10, align 4, !tbaa !9
  %66 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_negEv(ptr noundef nonnull align 8 dereferenceable(37) %11)
  br i1 %66, label %67, label %77

67:                                               ; preds = %52
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = sub nsw i32 %68, %69
  %71 = add nsw i32 %70, 1
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %71, ptr %72, align 4, !tbaa !9
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %74, ptr %75, align 4, !tbaa !9
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %76, align 4, !tbaa !11
  br label %85

77:                                               ; preds = %52
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = sub nsw i32 %78, %79
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %80, ptr %81, align 4, !tbaa !9
  %82 = load i32, ptr %9, align 4, !tbaa !9
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %82, ptr %83, align 4, !tbaa !9
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 1, ptr %84, align 4, !tbaa !11
  br label %85

85:                                               ; preds = %77, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %86

86:                                               ; preds = %85, %21, %15
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 }

!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 = !{!"_ZTSN5sc_dt6sc_encE", !7, i64 0}
!13 = !{!14, !10, i64 28}
!14 = !{!"_ZTSN5sc_dt8scfx_repE", !15, i64 0, !10, i64 16, !10, i64 20, !16, i64 24, !10, i64 28, !10, i64 32, !17, i64 36}
!15 = !{!"_ZTSN5sc_dt9scfx_mantE", !6, i64 0, !10, i64 8}
!16 = !{!"_ZTSN5sc_dt8scfx_rep5stateE", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!14, !10, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!14, !10, 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"

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt13scfx_find_msbEm(i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_nanEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_infEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7is_zeroEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_negEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5sc_dt13scfx_find_lsbEm(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK5sc_dt8scfx_rep8get_typeERiS1_RNS_6sc_encE(ptr noundef nonnull align 8 dereferenceable(37) %0, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %1, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %2, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %3) local_unnamed_addr #2 align 2 {
  %5 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_nanEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  br i1 %5, label %39, label %6

6:                                                ; preds = %4
  %7 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_infEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  br i1 %7, label %39, label %8

8:                                                ; preds = %6
  %9 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7is_zeroEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  br i1 %9, label %39, label %10

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 28
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load i32, ptr %13, align 8, !tbaa !14
  %15 = sub nsw i32 %12, %14
  %16 = shl nsw i32 %15, 5
  %17 = tail call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %12)
  %18 = zext i32 %17 to i64
  %19 = tail call noundef i32 @_ZN5sc_dt13scfx_find_msbEm(i64 noundef %18)
  %20 = add i32 %19, 1
  %21 = add i32 %20, %16
  br label %22

22:                                               ; preds = %22, %10
  %.0 = phi i32 [ %21, %10 ], [ %24, %22 ]
  %23 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %.0)
  %24 = add nsw i32 %.0, -1
  %25 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %24)
  %26 = xor i1 %23, %25
  br i1 %26, label %27, label %22, !llvm.loop !15

27:                                               ; preds = %22
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  %29 = load i32, ptr %28, align 8, !tbaa !17
  %30 = load i32, ptr %13, align 8, !tbaa !14
  %31 = sub nsw i32 %29, %30
  %32 = shl nsw i32 %31, 5
  %33 = tail call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %29)
  %34 = zext i32 %33 to i64
  %35 = tail call noundef i32 @_ZN5sc_dt13scfx_find_lsbEm(i64 noundef %34)
  %36 = add nsw i32 %32, %35
  %37 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_negEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  %38 = zext i1 %37 to i32
  %spec.select = add i32 %.0, %38
  %not. = xor i1 %37, true
  %spec.select23 = zext i1 %not. to i32
  %.sink = sub i32 %spec.select, %36
  br label %39

39:                                               ; preds = %8, %4, %6, %27
  %.sink.sink = phi i32 [ %.sink, %27 ], [ 0, %6 ], [ 0, %4 ], [ 1, %8 ]
  %spec.select.sink = phi i32 [ %spec.select, %27 ], [ 0, %6 ], [ 0, %4 ], [ 1, %8 ]
  %spec.select23.sink = phi i32 [ %spec.select23, %27 ], [ 0, %6 ], [ 0, %4 ], [ 1, %8 ]
  store i32 %.sink.sink, ptr %1, align 4
  store i32 %spec.select.sink, ptr %2, align 4, !tbaa !18
  store i32 %spec.select23.sink, ptr %3, align 4, !tbaa !19
  ret void
}

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

!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 28}
!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 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !11, i64 32}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"_ZTSN5sc_dt6sc_encE", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass