; LLVM IR from gem5/gem5 :: ext/systemc/src/sysc/kernel/sc_module_name.ll (ZN7sc_core14sc_module_nameD2Ev)

; 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_core::sc_module_name" = type <{ ptr, ptr, ptr, ptr, i8, [7 x i8] }>

@_ZN7sc_core25SC_ID_SC_MODULE_NAME_USE_E = external constant [0 x i8], align 1
@.str = external hidden unnamed_addr constant [90 x i8], align 1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7sc_core13sc_simcontext18get_object_managerEv(ptr noundef nonnull align 8 dereferenceable(344)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7sc_core14sc_module_nameD2Ev(ptr noundef nonnull align 8 dereferenceable(33) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"class.sc_core::sc_module_name", ptr %4, i32 0, i32 4
  %6 = load i8, ptr %5, align 8, !tbaa !9, !range !12, !noundef !13
  %7 = trunc i8 %6 to i1
  br i1 %7, label %8, label %28

8:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %9 = getelementptr inbounds %"class.sc_core::sc_module_name", ptr %4, i32 0, i32 3
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = invoke noundef ptr @_ZN7sc_core13sc_simcontext18get_object_managerEv(ptr noundef nonnull align 8 dereferenceable(344) %10)
          to label %12 unwind label %29

12:                                               ; preds = %8
  %13 = invoke noundef ptr @_ZN7sc_core17sc_object_manager15pop_module_nameEv(ptr noundef nonnull align 8 dereferenceable(105) %11)
          to label %14 unwind label %29

14:                                               ; preds = %12
  store ptr %13, ptr %3, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = icmp ne ptr %4, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  invoke void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef @_ZN7sc_core25SC_ID_SC_MODULE_NAME_USE_E, ptr noundef null, ptr noundef @.str, i32 noundef 64)
          to label %18 unwind label %29

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18, %14
  %20 = getelementptr inbounds %"class.sc_core::sc_module_name", ptr %4, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %27

23:                                               ; preds = %19
  %24 = getelementptr inbounds %"class.sc_core::sc_module_name", ptr %4, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  invoke void @_ZN7sc_core9sc_module10end_moduleEv(ptr noundef nonnull align 8 dereferenceable(232) %25)
          to label %26 unwind label %29

26:                                               ; preds = %23
  br label %27

27:                                               ; preds = %26, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %28

28:                                               ; preds = %27, %1
  ret void

29:                                               ; preds = %23, %17, %12, %8
  %30 = landingpad { ptr, i32 }
          catch ptr null
  %31 = extractvalue { ptr, i32 } %30, 0
  call void @__clang_call_terminate(ptr %31) #6
  unreachable
}

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

declare noundef ptr @_ZN7sc_core17sc_object_manager15pop_module_nameEv(ptr noundef nonnull align 8 dereferenceable(105)) #4

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

declare void @_ZN7sc_core9sc_module10end_moduleEv(ptr noundef nonnull align 8 dereferenceable(232)) #4

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

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { noinline noreturn nounwind uwtable "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 = { "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 }
attributes #6 = { noreturn 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, !11, i64 32}
!10 = !{!"_ZTSN7sc_core14sc_module_nameE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!11 = !{!"bool", !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!10, !6, i64 24}
!15 = !{!10, !6, i64 8}


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

@_ZN7sc_core25SC_ID_SC_MODULE_NAME_USE_E = external constant [0 x i8], align 1
@.str = external hidden unnamed_addr constant [90 x i8], align 1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7sc_core13sc_simcontext18get_object_managerEv(ptr noundef nonnull align 8 dereferenceable(344)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7sc_core14sc_module_nameD2Ev(ptr noundef nonnull readonly align 8 dereferenceable(33) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !11, !noundef !12
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %16

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = tail call noundef ptr @_ZN7sc_core13sc_simcontext18get_object_managerEv(ptr noundef nonnull align 8 dereferenceable(344) %7)
  %9 = invoke noundef ptr @_ZN7sc_core17sc_object_manager15pop_module_nameEv(ptr noundef nonnull align 8 dereferenceable(105) %8)
          to label %10 unwind label %17

10:                                               ; preds = %5
  %.not = icmp eq ptr %9, %0
  br i1 %.not, label %12, label %11

11:                                               ; preds = %10
  invoke void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef nonnull @_ZN7sc_core25SC_ID_SC_MODULE_NAME_USE_E, ptr noundef null, ptr noundef nonnull @.str, i32 noundef 64)
          to label %12 unwind label %17

12:                                               ; preds = %11, %10
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %.not2 = icmp eq ptr %14, null
  br i1 %.not2, label %16, label %15

15:                                               ; preds = %12
  invoke void @_ZN7sc_core9sc_module10end_moduleEv(ptr noundef nonnull align 8 dereferenceable(232) %14)
          to label %16 unwind label %17

16:                                               ; preds = %12, %15, %1
  ret void

17:                                               ; preds = %15, %11, %5
  %18 = landingpad { ptr, i32 }
          catch ptr null
  %19 = extractvalue { ptr, i32 } %18, 0
  tail call void @__clang_call_terminate(ptr %19) #4
  unreachable
}

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #2

declare noundef ptr @_ZN7sc_core17sc_object_manager15pop_module_nameEv(ptr noundef nonnull align 8 dereferenceable(105)) local_unnamed_addr #3

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

declare void @_ZN7sc_core9sc_module10end_moduleEv(ptr noundef nonnull align 8 dereferenceable(232)) local_unnamed_addr #3

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 = { 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 = { noinline noreturn nounwind uwtable "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 = { "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 = { noreturn 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, !10, i64 32}
!6 = !{!"_ZTSN7sc_core14sc_module_nameE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !7, i64 24}
!14 = !{!6, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass