; LLVM IR from gem5/gem5 :: src/systemc/dt/bit (sc_bv_base)

; 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::sc_bv_base" = type { %"class.sc_dt::sc_proxy", i32, i32, ptr }
%"class.sc_dt::sc_proxy" = type { ptr }

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@_ZN7sc_core21SC_ID_CANNOT_CONVERT_E = external constant [0 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1

declare void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5sc_dt10sc_bv_base18assign_from_stringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %12 = getelementptr inbounds %"class.sc_dt::sc_bv_base", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !9
  store i32 %13, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %14) #5
  %16 = sub i64 %15, 1
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr %6, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %18 = call noundef i32 @_ZN5sc_dt6sc_minIiEEKT_RS2_S3_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  store i32 %18, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !13
  br label %19

19:                                               ; preds = %46, %2
  %20 = load i32, ptr %8, align 4, !tbaa !13
  %21 = load i32, ptr %7, align 4, !tbaa !13
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %49

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !13
  %26 = load i32, ptr %8, align 4, !tbaa !13
  %27 = sub nsw i32 %25, %26
  %28 = sub nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %24, i64 noundef %29) #5
  %31 = load i8, ptr %30, align 1, !tbaa !14
  store i8 %31, ptr %9, align 1, !tbaa !14
  %32 = load i8, ptr %9, align 1, !tbaa !14
  %33 = sext i8 %32 to i32
  %34 = icmp ne i32 %33, 48
  br i1 %34, label %35, label %40

35:                                               ; preds = %23
  %36 = load i8, ptr %9, align 1, !tbaa !14
  %37 = sext i8 %36 to i32
  %38 = icmp ne i32 %37, 49
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef @_ZN7sc_core21SC_ID_CANNOT_CONVERT_E, ptr noundef @.str.1, ptr noundef @.str, i32 noundef 106)
  store i8 48, ptr %9, align 1, !tbaa !14
  br label %40

40:                                               ; preds = %39, %35, %23
  %41 = load i32, ptr %8, align 4, !tbaa !13
  %42 = load i8, ptr %9, align 1, !tbaa !14
  %43 = sext i8 %42 to i32
  %44 = sub nsw i32 %43, 48
  %45 = icmp ne i32 %44, 0
  call void @_ZN5sc_dt10sc_bv_base7set_bitEib(ptr noundef nonnull align 8 dereferenceable(24) %11, i32 noundef %41, i1 noundef zeroext %45)
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  br label %46

46:                                               ; preds = %40
  %47 = load i32, ptr %8, align 4, !tbaa !13
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %8, align 4, !tbaa !13
  br label %19, !llvm.loop !15

49:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !13
  %52 = sext i32 %51 to i64
  %53 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %50, i64 noundef %52) #5
  %54 = load i8, ptr %53, align 1, !tbaa !14
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, 70
  br i1 %56, label %57, label %63

57:                                               ; preds = %49
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %58, i64 noundef 0) #5
  %60 = load i8, ptr %59, align 1, !tbaa !14
  %61 = sext i8 %60 to i32
  %62 = sub nsw i32 %61, 48
  br label %64

63:                                               ; preds = %49
  br label %64

64:                                               ; preds = %63, %57
  %65 = phi i32 [ %62, %57 ], [ 0, %63 ]
  store i32 %65, ptr %10, align 4, !tbaa !17
  br label %66

66:                                               ; preds = %74, %64
  %67 = load i32, ptr %8, align 4, !tbaa !13
  %68 = load i32, ptr %5, align 4, !tbaa !13
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %70, label %77

70:                                               ; preds = %66
  %71 = load i32, ptr %8, align 4, !tbaa !13
  %72 = load i32, ptr %10, align 4, !tbaa !17
  %73 = icmp ne i32 %72, 0
  call void @_ZN5sc_dt10sc_bv_base7set_bitEib(ptr noundef nonnull align 8 dereferenceable(24) %11, i32 noundef %71, i1 noundef zeroext %73)
  br label %74

74:                                               ; preds = %70
  %75 = load i32, ptr %8, align 4, !tbaa !13
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %8, align 4, !tbaa !13
  br label %66, !llvm.loop !19

77:                                               ; preds = %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: 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)) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5sc_dt10sc_bv_base7set_bitEib(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i1 noundef zeroext) #4 align 2

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { 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 8}
!10 = !{!"_ZTSN5sc_dt10sc_bv_baseE", !11, i64 0, !12, i64 8, !12, i64 12, !6, i64 16}
!11 = !{!"_ZTSN5sc_dt8sc_proxyINS_10sc_bv_baseEEE"}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !18, i64 0}
!18 = !{!"_ZTSN5sc_dt16sc_logic_value_tE", !7, i64 0}
!19 = distinct !{!19, !16}


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

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@_ZN7sc_core21SC_ID_CANNOT_CONVERT_E = external constant [0 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1

declare void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5sc_dt10sc_bv_base18assign_from_stringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !5
  store i32 %6, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %7 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #5
  %8 = trunc i64 %7 to i32
  %9 = add i32 %8, -1
  store i32 %9, ptr %4, align 4, !tbaa !12
  %10 = call noundef i32 @_ZN5sc_dt6sc_minIiEEKT_RS2_S3_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %20
  %.019 = phi i32 [ %22, %20 ], [ 0, %2 ]
  %12 = load i32, ptr %4, align 4, !tbaa !12
  %13 = xor i32 %.019, -1
  %14 = add i32 %12, %13
  %15 = sext i32 %14 to i64
  %16 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %15) #5
  %17 = load i8, ptr %16, align 1, !tbaa !13
  %18 = add i8 %17, -50
  %or.cond = icmp ult i8 %18, -2
  br i1 %or.cond, label %19, label %20

19:                                               ; preds = %.lr.ph
  call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef nonnull @_ZN7sc_core21SC_ID_CANNOT_CONVERT_E, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str, i32 noundef 106)
  br label %20

20:                                               ; preds = %19, %.lr.ph
  %.018 = phi i8 [ 48, %19 ], [ %17, %.lr.ph ]
  %21 = icmp ne i8 %.018, 48
  call void @_ZN5sc_dt10sc_bv_base7set_bitEib(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.019, i1 noundef zeroext %21)
  %22 = add nuw nsw i32 %.019, 1
  %exitcond.not = icmp eq i32 %22, %10
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %20, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %10, %20 ]
  %23 = load i32, ptr %4, align 4, !tbaa !12
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %24) #5
  %26 = load i8, ptr %25, align 1, !tbaa !13
  %27 = icmp eq i8 %26, 70
  br i1 %27, label %28, label %32

28:                                               ; preds = %._crit_edge
  %29 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef 0) #5
  %30 = load i8, ptr %29, align 1, !tbaa !13
  %31 = icmp ne i8 %30, 48
  br label %32

32:                                               ; preds = %._crit_edge, %28
  %33 = phi i1 [ %31, %28 ], [ false, %._crit_edge ]
  %34 = load i32, ptr %3, align 4, !tbaa !12
  %35 = icmp slt i32 %.0.lcssa, %34
  br i1 %35, label %.lr.ph22, label %._crit_edge23

.lr.ph22:                                         ; preds = %32, %.lr.ph22
  %.120 = phi i32 [ %36, %.lr.ph22 ], [ %.0.lcssa, %32 ]
  call void @_ZN5sc_dt10sc_bv_base7set_bitEib(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.120, i1 noundef zeroext %33)
  %36 = add nuw nsw i32 %.120, 1
  %37 = load i32, ptr %3, align 4, !tbaa !12
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %.lr.ph22, label %._crit_edge23, !llvm.loop !16

._crit_edge23:                                    ; preds = %.lr.ph22, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: 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 #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5sc_dt10sc_bv_base7set_bitEib(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i1 noundef zeroext) local_unnamed_addr #4 align 2

attributes #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { 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, !8, i64 8}
!6 = !{!"_ZTSN5sc_dt10sc_bv_baseE", !7, i64 0, !8, i64 8, !8, i64 12, !11, i64 16}
!7 = !{!"_ZTSN5sc_dt8sc_proxyINS_10sc_bv_baseEEE"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!9, !9, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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