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

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

%"struct.sc_core::sc_msg_def" = type { ptr, i32, [4 x i32], i32, [4 x i32], i32, i32, [4 x i32], ptr, i32 }

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E = external constant [0 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1

; 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

declare noundef ptr @_ZN7sc_core17sc_report_handler8mdlookupEi(i32 noundef) #1

declare noundef ptr @_ZN7sc_core17sc_report_handler12add_msg_typeEPKc(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7sc_core9sc_report11register_idEiPKc(i32 noundef %0, ptr noundef %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @_ZN7sc_coreL24sc_deprecated_report_idsEPKc(ptr noundef @.str)
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 203)
  br label %10

10:                                               ; preds = %9, %2
  %11 = load ptr, ptr %4, align 8, !tbaa !9
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 207)
  br label %14

14:                                               ; preds = %13, %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = call noundef ptr @_ZN7sc_core17sc_report_handler8mdlookupEi(i32 noundef %15)
  store ptr %16, ptr %5, align 8, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %22, label %19

19:                                               ; preds = %14
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  %21 = call noundef ptr @_ZN7sc_core17sc_report_handler12add_msg_typeEPKc(ptr noundef %20)
  store ptr %21, ptr %5, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %19, %14
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 216)
  br label %26

26:                                               ; preds = %25, %22
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds %"struct.sc_core::sc_msg_def", ptr %27, i32 0, i32 9
  %29 = load i32, ptr %28, align 8, !tbaa !11
  %30 = icmp ne i32 %29, -1
  br i1 %30, label %31, label %40

31:                                               ; preds = %26
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds %"struct.sc_core::sc_msg_def", ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = call i32 @strcmp(ptr noundef %32, ptr noundef %35) #5
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %31
  call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef @.str.5, ptr noundef @.str.2, i32 noundef 222)
  br label %39

39:                                               ; preds = %38, %31
  store i32 1, ptr %6, align 4
  br label %44

40:                                               ; preds = %26
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = getelementptr inbounds %"struct.sc_core::sc_msg_def", ptr %42, i32 0, i32 9
  store i32 %41, ptr %43, align 8, !tbaa !11
  store i32 0, ptr %6, align 4
  br label %44

44:                                               ; preds = %40, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %45 = load i32, ptr %6, align 4
  switch i32 %45, label %47 [
    i32 0, label %46
    i32 1, label %46
  ]

46:                                               ; preds = %44, %44
  ret void

47:                                               ; preds = %44
  unreachable
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN7sc_coreL24sc_deprecated_report_idsEPKc(ptr noundef) #2

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { nounwind willreturn memory(read) "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 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"_ZTSN7sc_core10sc_msg_defE", !10, i64 0, !6, i64 8, !7, i64 12, !6, i64 28, !7, i64 32, !6, i64 48, !6, i64 52, !7, i64 56, !10, i64 72, !6, i64 80}
!13 = !{!12, !10, i64 0}


; 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 [25 x i8], align 1
@_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E = external constant [0 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7sc_core9sc_report11register_idEiPKc(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  tail call void @_ZN7sc_coreL24sc_deprecated_report_idsEPKc(ptr noundef nonnull @.str)
  %3 = icmp slt i32 %0, 0
  br i1 %3, label %4, label %5

4:                                                ; preds = %2
  tail call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef nonnull @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 203)
  br label %5

5:                                                ; preds = %4, %2
  %6 = icmp eq ptr %1, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %5
  tail call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef nonnull @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 207)
  br label %8

8:                                                ; preds = %7, %5
  %9 = tail call noundef ptr @_ZN7sc_core17sc_report_handler8mdlookupEi(i32 noundef %0)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %10, label %.thread

10:                                               ; preds = %8
  %11 = tail call noundef ptr @_ZN7sc_core17sc_report_handler12add_msg_typeEPKc(ptr noundef %1)
  %.not11 = icmp eq ptr %11, null
  br i1 %.not11, label %12, label %.thread

12:                                               ; preds = %10
  tail call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef nonnull @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.2, i32 noundef 216)
  unreachable

.thread:                                          ; preds = %8, %10
  %.016 = phi ptr [ %11, %10 ], [ %9, %8 ]
  %13 = getelementptr inbounds i8, ptr %.016, i64 80
  %14 = load i32, ptr %13, align 8, !tbaa !5
  %.not12 = icmp eq i32 %14, -1
  br i1 %.not12, label %19, label %15

15:                                               ; preds = %.thread
  %16 = load ptr, ptr %.016, align 8, !tbaa !11
  %17 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %16) #3
  %.not13 = icmp eq i32 %17, 0
  br i1 %.not13, label %20, label %18

18:                                               ; preds = %15
  tail call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 2, ptr noundef nonnull @_ZN7sc_core25SC_ID_REGISTER_ID_FAILED_E, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 222)
  br label %20

19:                                               ; preds = %.thread
  store i32 %0, ptr %13, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %15, %18, %19
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN7sc_coreL24sc_deprecated_report_idsEPKc(ptr noundef) local_unnamed_addr #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 nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #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 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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = !{!6, !7, i64 0}


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