; 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 uwtable
declare dso_local noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(ptr noundef nonnull align 8 dereferenceable(37)) #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) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5sc_dt14compare_msw_ffERKNS_8scfx_repES2_(ptr noundef nonnull align 8 dereferenceable(37) %0, ptr noundef nonnull align 8 dereferenceable(37) %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %13, i32 0, i32 4
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(ptr noundef nonnull align 8 dereferenceable(37) %16)
  %18 = sub nsw i32 %17, 1
  %19 = icmp slt i32 %15, %18
  br i1 %19, label %20, label %30

20:                                               ; preds = %2
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %23, i32 0, i32 4
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = add nsw i32 %25, 1
  %27 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %22, i32 noundef %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %20
  store i32 -1, ptr %3, align 4
  br label %106

30:                                               ; preds = %20, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %34, i32 0, i32 5
  %36 = load i32, ptr %35, align 8, !tbaa !15
  %37 = sub nsw i32 %33, %36
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %6, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %39, i32 0, i32 4
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %42, i32 0, i32 5
  %44 = load i32, ptr %43, align 8, !tbaa !15
  %45 = sub nsw i32 %41, %44
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %47 = call noundef i32 @_ZN5sc_dt6sc_minIiEEKT_RS2_S3_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  store i32 %47, ptr %8, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %48, i32 0, i32 4
  %50 = load i32, ptr %49, align 4, !tbaa !9
  store i32 %50, ptr %9, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %51, i32 0, i32 4
  %53 = load i32, ptr %52, align 4, !tbaa !9
  store i32 %53, ptr %10, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !16
  br label %54

54:                                               ; preds = %75, %30
  %55 = load i32, ptr %11, align 4, !tbaa !16
  %56 = load i32, ptr %8, align 4, !tbaa !16
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %58, label %68

58:                                               ; preds = %54
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %59, i32 0, i32 0
  %61 = load i32, ptr %9, align 4, !tbaa !16
  %62 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %60, i32 noundef %61)
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %63, i32 0, i32 0
  %65 = load i32, ptr %10, align 4, !tbaa !16
  %66 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %64, i32 noundef %65)
  %67 = icmp eq i32 %62, %66
  br label %68

68:                                               ; preds = %58, %54
  %69 = phi i1 [ false, %54 ], [ %67, %58 ]
  br i1 %69, label %70, label %78

70:                                               ; preds = %68
  %71 = load i32, ptr %9, align 4, !tbaa !16
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr %9, align 4, !tbaa !16
  %73 = load i32, ptr %10, align 4, !tbaa !16
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr %10, align 4, !tbaa !16
  br label %75

75:                                               ; preds = %70
  %76 = load i32, ptr %11, align 4, !tbaa !16
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %11, align 4, !tbaa !16
  br label %54, !llvm.loop !17

78:                                               ; preds = %68
  %79 = load i32, ptr %11, align 4, !tbaa !16
  %80 = load i32, ptr %8, align 4, !tbaa !16
  %81 = icmp eq i32 %79, %80
  br i1 %81, label %82, label %93

82:                                               ; preds = %78
  %83 = load i32, ptr %6, align 4, !tbaa !16
  %84 = load i32, ptr %7, align 4, !tbaa !16
  %85 = icmp eq i32 %83, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %82
  store i32 0, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %105

87:                                               ; preds = %82
  %88 = load i32, ptr %6, align 4, !tbaa !16
  %89 = load i32, ptr %7, align 4, !tbaa !16
  %90 = icmp slt i32 %88, %89
  br i1 %90, label %91, label %92

91:                                               ; preds = %87
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %105

92:                                               ; preds = %87
  store i32 1, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %105

93:                                               ; preds = %78
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %94, i32 0, i32 0
  %96 = load i32, ptr %9, align 4, !tbaa !16
  %97 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %95, i32 noundef %96)
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %98, i32 0, i32 0
  %100 = load i32, ptr %10, align 4, !tbaa !16
  %101 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %99, i32 noundef %100)
  %102 = icmp ult i32 %97, %101
  br i1 %102, label %103, label %104

103:                                              ; preds = %93
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %105

104:                                              ; preds = %93
  store i32 1, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %105

105:                                              ; preds = %104, %103, %92, %91, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %106

106:                                              ; preds = %105, %29
  %107 = load i32, ptr %3, align 4
  ret i32 %107
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !12, i64 28}
!10 = !{!"_ZTSN5sc_dt8scfx_repE", !11, i64 0, !12, i64 16, !12, i64 20, !13, i64 24, !12, i64 28, !12, i64 32, !14, i64 36}
!11 = !{!"_ZTSN5sc_dt9scfx_mantE", !6, i64 0, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN5sc_dt8scfx_rep5stateE", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!10, !12, i64 32}
!16 = !{!12, !12, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(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 #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -1, 2) i32 @_ZN5sc_dt14compare_msw_ffERKNS_8scfx_repES2_(ptr noundef nonnull align 8 dereferenceable(37) %0, ptr noundef nonnull align 8 dereferenceable(37) %1) local_unnamed_addr #3 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = getelementptr inbounds i8, ptr %1, i64 28
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = tail call noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(ptr noundef nonnull align 8 dereferenceable(37) %1)
  %8 = add nsw i32 %7, -1
  %9 = icmp slt i32 %6, %8
  br i1 %9, label %10, label %14

10:                                               ; preds = %2
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = add nsw i32 %11, 1
  %13 = tail call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %1, i32 noundef %12)
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %14, label %48

14:                                               ; preds = %10, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %15 = getelementptr inbounds i8, ptr %0, i64 28
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = add i32 %16, 1
  %20 = sub i32 %19, %18
  store i32 %20, ptr %3, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 32
  %23 = load i32, ptr %22, align 8, !tbaa !14
  %24 = add i32 %21, 1
  %25 = sub i32 %24, %23
  store i32 %25, ptr %4, align 4, !tbaa !15
  %26 = call noundef i32 @_ZN5sc_dt6sc_minIiEEKT_RS2_S3_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %27 = load i32, ptr %15, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = icmp sgt i32 %26, 0
  br i1 %29, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %14, %33
  %.034 = phi i32 [ %36, %33 ], [ 0, %14 ]
  %.02533 = phi i32 [ %35, %33 ], [ %28, %14 ]
  %.02632 = phi i32 [ %34, %33 ], [ %27, %14 ]
  %30 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %.02632)
  %31 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %1, i32 noundef %.02533)
  %32 = icmp eq i32 %30, %31
  br i1 %32, label %33, label %.critedge

33:                                               ; preds = %.lr.ph
  %34 = add nsw i32 %.02632, -1
  %35 = add nsw i32 %.02533, -1
  %36 = add nuw nsw i32 %.034, 1
  %exitcond.not = icmp eq i32 %36, %26
  br i1 %exitcond.not, label %.critedge.thread, label %.lr.ph, !llvm.loop !16

.critedge:                                        ; preds = %.lr.ph, %14
  %.026.lcssa = phi i32 [ %27, %14 ], [ %.02632, %.lr.ph ]
  %.025.lcssa = phi i32 [ %28, %14 ], [ %.02533, %.lr.ph ]
  %.0.lcssa = phi i32 [ 0, %14 ], [ %.034, %.lr.ph ]
  %37 = icmp eq i32 %.0.lcssa, %26
  br i1 %37, label %.critedge.thread, label %43

.critedge.thread:                                 ; preds = %33, %.critedge
  %38 = load i32, ptr %3, align 4, !tbaa !15
  %39 = load i32, ptr %4, align 4, !tbaa !15
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %47, label %41

41:                                               ; preds = %.critedge.thread
  %42 = icmp slt i32 %38, %39
  %. = select i1 %42, i32 -1, i32 1
  br label %47

43:                                               ; preds = %.critedge
  %44 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %.026.lcssa)
  %45 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %1, i32 noundef %.025.lcssa)
  %46 = icmp ult i32 %44, %45
  %.30 = select i1 %46, i32 -1, i32 1
  br label %47

47:                                               ; preds = %43, %41, %.critedge.thread
  %.027 = phi i32 [ 0, %.critedge.thread ], [ %., %41 ], [ %.30, %43 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  br label %48

48:                                               ; preds = %10, %47
  %.1 = phi i32 [ %.027, %47 ], [ -1, %10 ]
  ret i32 %.1
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !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 32}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass