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

; 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_cor_qt" = type { %"class.sc_core::sc_cor", i64, ptr, ptr, ptr }
%"class.sc_core::sc_cor" = type { ptr }

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

; 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: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @sc_cor_qt_wrapper(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7sc_core13sc_cor_pkg_qt6createEmPFvPvES1_(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %14 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #7
  invoke void @_ZN7sc_core9sc_cor_qtC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %14)
          to label %15 unwind label %94

15:                                               ; preds = %4
  store ptr %14, ptr %9, align 8, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %16, i32 0, i32 4
  store ptr %13, ptr %17, align 8, !tbaa !11
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %19, i32 0, i32 1
  store i64 %18, ptr %20, align 8, !tbaa !14
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %21, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !14
  %24 = call noalias noundef nonnull ptr @_Znam(i64 noundef %23) #7
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %25, i32 0, i32 2
  store ptr %24, ptr %26, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %30, i32 0, i32 1
  %32 = call noundef ptr @_ZN7sc_core11stack_alignEPviPm(ptr noundef %29, i32 noundef 16, ptr noundef %31)
  store ptr %32, ptr %12, align 8, !tbaa !5
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !14
  %37 = sub i64 %36, 16
  %38 = getelementptr inbounds i8, ptr %33, i64 %37
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %39, i32 0, i32 3
  store ptr %38, ptr %40, align 8, !tbaa !16
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = getelementptr inbounds i8, ptr %43, i64 -128
  %45 = getelementptr inbounds i64, ptr %44, i64 10
  store i64 0, ptr %45, align 8, !tbaa !9
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = getelementptr inbounds i8, ptr %48, i64 -128
  %50 = getelementptr inbounds i64, ptr %49, i64 13
  store i64 ptrtoint (ptr @qt_align to i64), ptr %50, align 8, !tbaa !9
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds i8, ptr %53, i64 -128
  %55 = getelementptr inbounds i64, ptr %54, i64 11
  store i64 ptrtoint (ptr @qt_align to i64), ptr %55, align 8, !tbaa !9
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  %59 = getelementptr inbounds i8, ptr %58, i64 -128
  %60 = getelementptr inbounds i64, ptr %59, i64 14
  store i64 ptrtoint (ptr @qt_error to i64), ptr %60, align 8, !tbaa !9
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %61, i32 0, i32 3
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = getelementptr inbounds i8, ptr %63, i64 -128
  %65 = getelementptr inbounds i64, ptr %64, i64 12
  store i64 ptrtoint (ptr @sc_cor_qt_wrapper to i64), ptr %65, align 8, !tbaa !9
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = ptrtoint ptr %66 to i64
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !16
  %71 = getelementptr inbounds i8, ptr %70, i64 -128
  %72 = getelementptr inbounds i64, ptr %71, i64 2
  store i64 %67, ptr %72, align 8, !tbaa !9
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = ptrtoint ptr %73 to i64
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %75, i32 0, i32 3
  %77 = load ptr, ptr %76, align 8, !tbaa !16
  %78 = getelementptr inbounds i8, ptr %77, i64 -128
  %79 = getelementptr inbounds i64, ptr %78, i64 0
  store i64 %74, ptr %79, align 8, !tbaa !9
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = ptrtoint ptr %80 to i64
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %82, i32 0, i32 3
  %84 = load ptr, ptr %83, align 8, !tbaa !16
  %85 = getelementptr inbounds i8, ptr %84, i64 -128
  %86 = getelementptr inbounds i64, ptr %85, i64 1
  store i64 %81, ptr %86, align 8, !tbaa !9
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %87, i32 0, i32 3
  %89 = load ptr, ptr %88, align 8, !tbaa !16
  %90 = getelementptr inbounds i8, ptr %89, i64 -128
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = getelementptr inbounds %"class.sc_core::sc_cor_qt", ptr %91, i32 0, i32 3
  store ptr %90, ptr %92, align 8, !tbaa !16
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret ptr %93

94:                                               ; preds = %4
  %95 = landingpad { ptr, i32 }
          cleanup
  %96 = extractvalue { ptr, i32 } %95, 0
  store ptr %96, ptr %10, align 8
  %97 = extractvalue { ptr, i32 } %95, 1
  store i32 %97, ptr %11, align 4
  call void @_ZdlPvm(ptr noundef %14, i64 noundef 40) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %98

98:                                               ; preds = %94
  %99 = load ptr, ptr %10, align 8
  %100 = load i32, ptr %11, align 4
  %101 = insertvalue { ptr, i32 } poison, ptr %99, 0
  %102 = insertvalue { ptr, i32 } %101, i32 %100, 1
  resume { ptr, i32 } %102
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7sc_core11stack_alignEPviPm(ptr noundef, i32 noundef, ptr noundef) #4

declare void @qt_align() #5

declare void @qt_error() #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nobuiltin allocsize(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 = { "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 allocsize(0) }
attributes #8 = { builtin 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTSN7sc_core9sc_cor_qtE", !13, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!"_ZTSN7sc_core6sc_corE"}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 24}


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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @sc_cor_qt_wrapper(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN7sc_core13sc_cor_pkg_qt6createEmPFvPvES1_(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #5
  invoke void @_ZN7sc_core9sc_cor_qtC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %5)
          to label %6 unwind label %26

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %0, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 8
  store i64 %1, ptr %8, align 8, !tbaa !12
  %9 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %1) #5
  %10 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %9, ptr %10, align 8, !tbaa !13
  %11 = tail call noundef ptr @_ZN7sc_core11stack_alignEPviPm(ptr noundef nonnull %9, i32 noundef 16, ptr noundef nonnull %8)
  %12 = load i64, ptr %8, align 8, !tbaa !12
  %13 = getelementptr i8, ptr %11, i64 %12
  %14 = getelementptr inbounds i8, ptr %5, i64 24
  %15 = getelementptr i8, ptr %13, i64 -64
  store i64 0, ptr %15, align 8, !tbaa !14
  %16 = getelementptr i8, ptr %13, i64 -40
  store i64 ptrtoint (ptr @qt_align to i64), ptr %16, align 8, !tbaa !14
  %17 = getelementptr i8, ptr %13, i64 -56
  store i64 ptrtoint (ptr @qt_align to i64), ptr %17, align 8, !tbaa !14
  %18 = getelementptr i8, ptr %13, i64 -32
  store i64 ptrtoint (ptr @qt_error to i64), ptr %18, align 8, !tbaa !14
  %19 = getelementptr i8, ptr %13, i64 -48
  store i64 ptrtoint (ptr @sc_cor_qt_wrapper to i64), ptr %19, align 8, !tbaa !14
  %20 = ptrtoint ptr %2 to i64
  %21 = getelementptr i8, ptr %13, i64 -128
  store i64 %20, ptr %21, align 8, !tbaa !14
  %22 = ptrtoint ptr %5 to i64
  %23 = getelementptr i8, ptr %13, i64 -144
  store i64 %22, ptr %23, align 8, !tbaa !14
  %24 = ptrtoint ptr %3 to i64
  %25 = getelementptr i8, ptr %13, i64 -136
  store i64 %24, ptr %25, align 8, !tbaa !14
  store ptr %23, ptr %14, align 8, !tbaa !15
  ret ptr %5

26:                                               ; preds = %4
  %27 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 40) #6
  resume { ptr, i32 } %27
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7sc_core11stack_alignEPviPm(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare void @qt_align() #4

declare void @qt_error() #4

attributes #0 = { 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 #1 = { 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 #2 = { nobuiltin allocsize(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 = { 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 #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 = { builtin allocsize(0) }
attributes #6 = { builtin 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 32}
!6 = !{!"_ZTSN7sc_core9sc_cor_qtE", !7, i64 0, !8, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!7 = !{!"_ZTSN7sc_core6sc_corE"}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!6, !8, i64 8}
!13 = !{!6, !11, i64 16}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !11, i64 24}


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