; LLVM IR from gem5/gem5 :: ext/systemc/src/sysc/utils (sc_report)

; 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_report" = type { %"class.std::exception", i32, ptr, ptr, ptr, i32, ptr, ptr, i32, ptr }
%"class.std::exception" = type { ptr }
%"struct.sc_core::sc_msg_def" = type { ptr, i32, [4 x i32], i32, [4 x i32], i32, i32, [4 x i32], ptr, i32 }

@_ZN7sc_coreL10unknown_idE = external hidden constant [11 x i8], align 1
@_ZN7sc_coreL19warnings_are_errorsE = external hidden global i8, align 1
@_ZN7sc_core17sc_report_handler7handlerE = external global ptr, align 8

declare i32 @__gxx_personality_v0(...)

; 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: mustprogress uwtable
define dso_local void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEiPKcS3_i(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #1 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.sc_core::sc_report", align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !11
  store ptr %3, ptr %9, align 8, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = call noundef ptr @_ZN7sc_core17sc_report_handler8mdlookupEi(i32 noundef %16)
  store ptr %17, ptr %11, align 8, !tbaa !11
  %18 = load ptr, ptr %11, align 8, !tbaa !11
  %19 = icmp ne ptr %18, null
  br i1 %19, label %25, label %20

20:                                               ; preds = %5
  %21 = call noundef ptr @_ZN7sc_core17sc_report_handler12add_msg_typeEPKc(ptr noundef @_ZN7sc_coreL10unknown_idE)
  store ptr %21, ptr %11, align 8, !tbaa !11
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = load ptr, ptr %11, align 8, !tbaa !11
  %24 = getelementptr inbounds %"struct.sc_core::sc_msg_def", ptr %23, i32 0, i32 9
  store i32 %22, ptr %24, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %20, %5
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = load i8, ptr @_ZN7sc_coreL19warnings_are_errorsE, align 1, !tbaa !15, !range !17, !noundef !18
  %30 = trunc i8 %29 to i1
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  store i32 2, ptr %6, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %31, %28, %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %33 = load ptr, ptr %11, align 8, !tbaa !11
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = call noundef i32 @_ZN7sc_core17sc_report_handler7executeEPNS_10sc_msg_defENS_11sc_severityE(ptr noundef %33, i32 noundef %34)
  store i32 %35, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 80, ptr %13) #3
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load ptr, ptr %11, align 8, !tbaa !11
  %38 = load ptr, ptr %8, align 8, !tbaa !11
  %39 = load ptr, ptr %9, align 8, !tbaa !11
  %40 = load i32, ptr %10, align 4, !tbaa !9
  call void @_ZN7sc_core9sc_reportC1ENS_11sc_severityEPKNS_10sc_msg_defEPKcS6_ii(ptr noundef nonnull align 8 dereferenceable(80) %13, i32 noundef %36, ptr noundef %37, ptr noundef %38, ptr noundef %39, i32 noundef %40, i32 noundef 200)
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = and i32 %41, 16
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %50

44:                                               ; preds = %32
  invoke void @_ZN7sc_core17sc_report_handler12cache_reportERKNS_9sc_reportE(ptr noundef nonnull align 8 dereferenceable(80) %13)
          to label %45 unwind label %46

45:                                               ; preds = %44
  br label %50

46:                                               ; preds = %63, %44
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %14, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %15, align 4
  call void @_ZN7sc_core9sc_reportD1Ev(ptr noundef nonnull align 8 dereferenceable(80) %13) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %66

50:                                               ; preds = %45, %32
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = icmp eq i32 %51, 2
  br i1 %52, label %53, label %56

53:                                               ; preds = %50
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = or i32 %54, 2
  store i32 %55, ptr %12, align 4, !tbaa !9
  br label %63

56:                                               ; preds = %50
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = icmp eq i32 %57, 3
  br i1 %58, label %59, label %62

59:                                               ; preds = %56
  %60 = load i32, ptr %12, align 4, !tbaa !9
  %61 = or i32 %60, 128
  store i32 %61, ptr %12, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %59, %56
  br label %63

63:                                               ; preds = %62, %53
  %64 = load ptr, ptr @_ZN7sc_core17sc_report_handler7handlerE, align 8, !tbaa !11
  invoke void %64(ptr noundef nonnull align 8 dereferenceable(80) %13, ptr noundef nonnull align 4 dereferenceable(4) %12)
          to label %65 unwind label %46

65:                                               ; preds = %63
  call void @_ZN7sc_core9sc_reportD1Ev(ptr noundef nonnull align 8 dereferenceable(80) %13) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret void

66:                                               ; preds = %46
  %67 = load ptr, ptr %14, align 8
  %68 = load i32, ptr %15, align 4
  %69 = insertvalue { ptr, i32 } poison, ptr %67, 0
  %70 = insertvalue { ptr, i32 } %69, i32 %68, 1
  resume { ptr, i32 } %70
}

declare noundef ptr @_ZN7sc_core17sc_report_handler8mdlookupEi(i32 noundef) #2

declare noundef ptr @_ZN7sc_core17sc_report_handler12add_msg_typeEPKc(ptr noundef) #2

declare noundef i32 @_ZN7sc_core17sc_report_handler7executeEPNS_10sc_msg_defENS_11sc_severityE(ptr noundef, i32 noundef) #2

declare void @_ZN7sc_core17sc_report_handler12cache_reportERKNS_9sc_reportE(ptr noundef nonnull align 8 dereferenceable(80)) #2

declare void @_ZN7sc_core9sc_reportC1ENS_11sc_severityEPKNS_10sc_msg_defEPKcS6_ii(ptr, i32, ptr, ptr, ptr, i32, i32)

declare void @_ZN7sc_core9sc_reportD1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { 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 = !{!"_ZTSN7sc_core11sc_severityE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !10, i64 80}
!14 = !{!"_ZTSN7sc_core10sc_msg_defE", !12, i64 0, !10, i64 8, !7, i64 12, !10, i64 28, !7, i64 32, !10, i64 48, !10, i64 52, !7, i64 56, !12, i64 72, !10, i64 80}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}


; 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_report" = type { %"class.std::exception", i32, ptr, ptr, ptr, i32, ptr, ptr, i32, ptr }
%"class.std::exception" = type { ptr }

@_ZN7sc_coreL10unknown_idE = external hidden constant [11 x i8], align 1
@_ZN7sc_coreL19warnings_are_errorsE = external hidden local_unnamed_addr global i8, align 1
@_ZN7sc_core17sc_report_handler7handlerE = external local_unnamed_addr global ptr, align 8

declare i32 @__gxx_personality_v0(...)

; 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: mustprogress uwtable
define dso_local void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEiPKcS3_i(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca i32, align 4
  %7 = alloca %"class.sc_core::sc_report", align 8
  %8 = tail call noundef ptr @_ZN7sc_core17sc_report_handler8mdlookupEi(i32 noundef %1)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %12

9:                                                ; preds = %5
  %10 = tail call noundef ptr @_ZN7sc_core17sc_report_handler12add_msg_typeEPKc(ptr noundef nonnull @_ZN7sc_coreL10unknown_idE)
  %11 = getelementptr inbounds i8, ptr %10, i64 80
  store i32 %1, ptr %11, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %9, %5
  %.015 = phi ptr [ %8, %5 ], [ %10, %9 ]
  %13 = icmp eq i32 %0, 1
  %14 = load i8, ptr @_ZN7sc_coreL19warnings_are_errorsE, align 1, !range !11
  %15 = trunc nuw i8 %14 to i1
  %spec.select = select i1 %15, i32 2, i32 1
  %.0 = select i1 %13, i32 %spec.select, i32 %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %16 = tail call noundef i32 @_ZN7sc_core17sc_report_handler7executeEPNS_10sc_msg_defENS_11sc_severityE(ptr noundef nonnull %.015, i32 noundef %.0)
  store i32 %16, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %7) #3
  call void @_ZN7sc_core9sc_reportC1ENS_11sc_severityEPKNS_10sc_msg_defEPKcS6_ii(ptr noundef nonnull align 8 dereferenceable(80) %7, i32 noundef %.0, ptr noundef nonnull %.015, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef 200)
  %17 = and i32 %16, 16
  %.not18 = icmp eq i32 %17, 0
  br i1 %.not18, label %21, label %18

18:                                               ; preds = %12
  invoke void @_ZN7sc_core17sc_report_handler12cache_reportERKNS_9sc_reportE(ptr noundef nonnull align 8 dereferenceable(80) %7)
          to label %21 unwind label %19

19:                                               ; preds = %26, %18
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7sc_core9sc_reportD1Ev(ptr noundef nonnull align 8 dereferenceable(80) %7) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  resume { ptr, i32 } %20

21:                                               ; preds = %18, %12
  switch i32 %.0, label %26 [
    i32 2, label %22
    i32 3, label %24
  ]

22:                                               ; preds = %21
  %23 = or i32 %16, 2
  store i32 %23, ptr %6, align 4, !tbaa !12
  br label %26

24:                                               ; preds = %21
  %25 = or i32 %16, 128
  store i32 %25, ptr %6, align 4, !tbaa !12
  br label %26

26:                                               ; preds = %21, %24, %22
  %27 = load ptr, ptr @_ZN7sc_core17sc_report_handler7handlerE, align 8, !tbaa !13
  invoke void %27(ptr noundef nonnull align 8 dereferenceable(80) %7, ptr noundef nonnull align 4 dereferenceable(4) %6)
          to label %28 unwind label %19

28:                                               ; preds = %26
  call void @_ZN7sc_core9sc_reportD1Ev(ptr noundef nonnull align 8 dereferenceable(80) %7) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  ret void
}

declare noundef ptr @_ZN7sc_core17sc_report_handler8mdlookupEi(i32 noundef) local_unnamed_addr #2

declare noundef ptr @_ZN7sc_core17sc_report_handler12add_msg_typeEPKc(ptr noundef) local_unnamed_addr #2

declare noundef i32 @_ZN7sc_core17sc_report_handler7executeEPNS_10sc_msg_defENS_11sc_severityE(ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @_ZN7sc_core17sc_report_handler12cache_reportERKNS_9sc_reportE(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2

declare void @_ZN7sc_core9sc_reportC1ENS_11sc_severityEPKNS_10sc_msg_defEPKcS6_ii(ptr, i32, ptr, ptr, ptr, i32, i32) local_unnamed_addr

declare void @_ZN7sc_core9sc_reportD1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { 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 80}
!6 = !{!"_ZTSN7sc_core10sc_msg_defE", !7, i64 0, !10, i64 8, !8, i64 12, !10, i64 28, !8, i64 32, !10, i64 48, !10, i64 52, !8, i64 56, !7, i64 72, !10, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{!10, !10, i64 0}
!13 = !{!7, !7, i64 0}


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