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

; 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_strhash_iter" = type { %"class.sc_core::sc_phash_base_iter.base", [4 x i8] }
%"class.sc_core::sc_phash_base_iter.base" = type <{ ptr, ptr, ptr, ptr, i32 }>
%"class.sc_core::sc_name_gen" = type { %"class.sc_core::sc_strhash", [8192 x i8] }
%"class.sc_core::sc_strhash" = type { %"class.sc_core::sc_phash_base" }
%"class.sc_core::sc_phash_base" = type { ptr, i32, i32, i32, i32, double, ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7sc_core11sc_name_genD2Ev(ptr noundef nonnull align 8 dereferenceable(8248) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.sc_core::sc_strhash_iter", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr %3) #6
  %5 = getelementptr inbounds %"class.sc_core::sc_name_gen", ptr %4, i32 0, i32 0
  invoke void @_ZN7sc_core15sc_strhash_iterIPiEC2ERNS_10sc_strhashIS1_EE(ptr noundef nonnull align 8 dereferenceable(36) %3, ptr noundef nonnull align 8 dereferenceable(56) %5)
          to label %6 unwind label %23

6:                                                ; preds = %1
  br label %7

7:                                                ; preds = %18, %6
  %8 = invoke noundef zeroext i1 @_ZNK7sc_core18sc_phash_base_iter5emptyEv(ptr noundef nonnull align 8 dereferenceable(36) %3)
          to label %9 unwind label %23

9:                                                ; preds = %7
  %10 = xor i1 %8, true
  br i1 %10, label %11, label %19

11:                                               ; preds = %9
  %12 = invoke noundef ptr @_ZN7sc_core15sc_strhash_iterIPiE8contentsEv(ptr noundef nonnull align 8 dereferenceable(36) %3)
          to label %13 unwind label %23

13:                                               ; preds = %11
  %14 = icmp eq ptr %12, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %13
  call void @_ZdlPvm(ptr noundef %12, i64 noundef 4) #7
  br label %16

16:                                               ; preds = %15, %13
  br label %17

17:                                               ; preds = %16
  invoke void @_ZN7sc_core18sc_phash_base_iterppEi(ptr noundef nonnull align 8 dereferenceable(36) %3, i32 noundef 0)
          to label %18 unwind label %23

18:                                               ; preds = %17
  br label %7, !llvm.loop !9

19:                                               ; preds = %9
  %20 = getelementptr inbounds %"class.sc_core::sc_name_gen", ptr %4, i32 0, i32 0
  invoke void @_ZN7sc_core10sc_strhashIPiE5eraseEv(ptr noundef nonnull align 8 dereferenceable(56) %20)
          to label %21 unwind label %23

21:                                               ; preds = %19
  call void @_ZN7sc_core18sc_phash_base_iterD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %3) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #6
  %22 = getelementptr inbounds %"class.sc_core::sc_name_gen", ptr %4, i32 0, i32 0
  call void @_ZN7sc_core10sc_strhashIPiED2Ev(ptr noundef nonnull align 8 dereferenceable(56) %22) #6
  ret void

23:                                               ; preds = %19, %17, %11, %7, %1
  %24 = landingpad { ptr, i32 }
          catch ptr null
  %25 = extractvalue { ptr, i32 } %24, 0
  call void @__clang_call_terminate(ptr %25) #8
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7sc_core15sc_strhash_iterIPiEC2ERNS_10sc_strhashIS1_EE(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

declare noundef zeroext i1 @_ZNK7sc_core18sc_phash_base_iter5emptyEv(ptr noundef nonnull align 8 dereferenceable(36)) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7sc_core15sc_strhash_iterIPiE8contentsEv(ptr noundef nonnull align 8 dereferenceable(36)) #2 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7sc_core18sc_phash_base_iterppEi(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7sc_core10sc_strhashIPiE5eraseEv(ptr noundef nonnull align 8 dereferenceable(56)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7sc_core18sc_phash_base_iterD2Ev(ptr noundef nonnull align 8 dereferenceable(36)) unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7sc_core10sc_strhashIPiED2Ev(ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #0 align 2

attributes #0 = { 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 = { 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 = { 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 = { nobuiltin nounwind "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 #6 = { nounwind }
attributes #7 = { builtin nounwind }
attributes #8 = { 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 = distinct !{!9, !10}
!10 = !{!"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"

%"class.sc_core::sc_strhash_iter" = type { %"class.sc_core::sc_phash_base_iter.base", [4 x i8] }
%"class.sc_core::sc_phash_base_iter.base" = type <{ ptr, ptr, ptr, ptr, i32 }>

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7sc_core11sc_name_genD2Ev(ptr noundef nonnull align 8 dereferenceable(8248) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.sc_core::sc_strhash_iter", align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #6
  invoke void @_ZN7sc_core15sc_strhash_iterIPiEC2ERNS_10sc_strhashIS1_EE(ptr noundef nonnull align 8 dereferenceable(36) %2, ptr noundef nonnull align 8 dereferenceable(56) %0)
          to label %.preheader unwind label %.loopexit.split-lp

.preheader:                                       ; preds = %1, %10
  %3 = invoke noundef zeroext i1 @_ZNK7sc_core18sc_phash_base_iter5emptyEv(ptr noundef nonnull align 8 dereferenceable(36) %2)
          to label %4 unwind label %.loopexit

4:                                                ; preds = %.preheader
  br i1 %3, label %11, label %5

5:                                                ; preds = %4
  %6 = invoke noundef ptr @_ZN7sc_core15sc_strhash_iterIPiE8contentsEv(ptr noundef nonnull align 8 dereferenceable(36) %2)
          to label %7 unwind label %.loopexit

7:                                                ; preds = %5
  %8 = icmp eq ptr %6, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %7
  call void @_ZdlPvm(ptr noundef nonnull %6, i64 noundef 4) #7
  br label %10

10:                                               ; preds = %7, %9
  invoke void @_ZN7sc_core18sc_phash_base_iterppEi(ptr noundef nonnull align 8 dereferenceable(36) %2, i32 noundef 0)
          to label %.preheader unwind label %.loopexit, !llvm.loop !5

11:                                               ; preds = %4
  invoke void @_ZN7sc_core10sc_strhashIPiE5eraseEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
          to label %12 unwind label %.loopexit.split-lp

12:                                               ; preds = %11
  call void @_ZN7sc_core18sc_phash_base_iterD2Ev(ptr noundef nonnull align 8 dereferenceable(36) %2) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #6
  call void @_ZN7sc_core10sc_strhashIPiED2Ev(ptr noundef nonnull align 8 dereferenceable(56) %0) #6
  ret void

.loopexit:                                        ; preds = %.preheader, %5, %10
  %lpad.loopexit = landingpad { ptr, i32 }
          catch ptr null
  br label %13

.loopexit.split-lp:                               ; preds = %1, %11
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          catch ptr null
  br label %13

13:                                               ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  %14 = extractvalue { ptr, i32 } %lpad.phi, 0
  call void @__clang_call_terminate(ptr %14) #8
  unreachable
}

; 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 uwtable
declare dso_local void @_ZN7sc_core15sc_strhash_iterIPiEC2ERNS_10sc_strhashIS1_EE(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

declare noundef zeroext i1 @_ZNK7sc_core18sc_phash_base_iter5emptyEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7sc_core15sc_strhash_iterIPiE8contentsEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #2 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7sc_core18sc_phash_base_iterppEi(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7sc_core10sc_strhashIPiE5eraseEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7sc_core18sc_phash_base_iterD2Ev(ptr noundef nonnull align 8 dereferenceable(36)) unnamed_addr #0 align 2

; 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 nounwind uwtable
declare dso_local void @_ZN7sc_core10sc_strhashIPiED2Ev(ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #0 align 2

attributes #0 = { 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 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 = { 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 = { nobuiltin nounwind "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 #6 = { nounwind }
attributes #7 = { builtin nounwind }
attributes #8 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass