; LLVM IR from gem5/gem5 :: src/systemc/tests/tlm/nb2b_adapter (nb2b_adapter)

; 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.mm = type { %"class.tlm::tlm_mm_interface", ptr, ptr }
%"class.tlm::tlm_mm_interface" = type { ptr }
%"struct.mm::access" = type { ptr, ptr, ptr }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2mm4freeEPN3tlm19tlm_generic_payloadE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3tlm19tlm_generic_payload5resetEv(ptr noundef nonnull align 8 dereferenceable(140) %6)
  %7 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 2
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %31, label %10

10:                                               ; preds = %2
  %11 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #2
  %12 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 2
  store ptr %11, ptr %12, align 8, !tbaa !9
  %13 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %"struct.mm::access", ptr %16, i32 0, i32 1
  store ptr %14, ptr %17, align 8, !tbaa !13
  %18 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %"struct.mm::access", ptr %19, i32 0, i32 2
  store ptr null, ptr %20, align 8, !tbaa !15
  %21 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %30

24:                                               ; preds = %10
  %25 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %29 = getelementptr inbounds %"struct.mm::access", ptr %28, i32 0, i32 2
  store ptr %26, ptr %29, align 8, !tbaa !15
  br label %30

30:                                               ; preds = %24, %10
  br label %31

31:                                               ; preds = %30, %2
  %32 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 1
  store ptr %33, ptr %34, align 8, !tbaa !12
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !12
  %38 = getelementptr inbounds %"struct.mm::access", ptr %37, i32 0, i32 0
  store ptr %35, ptr %38, align 8, !tbaa !16
  %39 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = getelementptr inbounds %"struct.mm::access", ptr %40, i32 0, i32 2
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = getelementptr inbounds %class.mm, ptr %5, i32 0, i32 2
  store ptr %42, ptr %43, align 8, !tbaa !9
  ret void
}

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

attributes #0 = { 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 #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 = { builtin allocsize(0) }

!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, !6, i64 16}
!10 = !{!"_ZTS2mm", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"_ZTSN3tlm16tlm_mm_interfaceE"}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN2mm6accessE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!14, !6, i64 16}
!16 = !{!14, !6, 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"

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2mm4freeEPN3tlm19tlm_generic_payloadE(ptr nocapture noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %1) unnamed_addr #1 align 2 {
  tail call void @_ZN3tlm19tlm_generic_payload5resetEv(ptr noundef nonnull align 8 dereferenceable(140) %1)
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %13

5:                                                ; preds = %2
  %6 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %8, ptr %9, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr null, ptr %10, align 8, !tbaa !14
  %.not3 = icmp eq ptr %8, null
  br i1 %.not3, label %13, label %11

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %6, ptr %12, align 8, !tbaa !14
  br label %13

13:                                               ; preds = %5, %11, %2
  %14 = phi ptr [ %6, %5 ], [ %6, %11 ], [ %4, %2 ]
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %14, ptr %15, align 8, !tbaa !11
  store ptr %1, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %14, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr %17, ptr %3, align 8, !tbaa !5
  ret void
}

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

attributes #0 = { 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 #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 = { builtin allocsize(0) }

!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, !8, i64 16}
!6 = !{!"_ZTS2mm", !7, i64 0, !8, i64 8, !8, i64 16}
!7 = !{!"_ZTSN3tlm16tlm_mm_interfaceE"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 8}
!12 = !{!13, !8, i64 8}
!13 = !{!"_ZTSN2mm6accessE", !8, i64 0, !8, i64 8, !8, i64 16}
!14 = !{!13, !8, i64 16}
!15 = !{!13, !8, i64 0}


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