; LLVM IR from HANDS-FREE/OpenRE :: 3_OS/STM32F1/RTOS/uCOS-III2/uC-LIB (lib_mem)

; 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.mem_pool = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, i32, i32 }

@Mem_PoolHeap = external dso_local global %struct.mem_pool, align 8
@Mem_Heap = external dso_local global [1024 x i8], align 16
@Mem_PoolTbl = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @Mem_Init() #0 {
  %1 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  store ptr @Mem_PoolHeap, ptr %1, align 8, !tbaa !5
  %2 = load ptr, ptr %1, align 8, !tbaa !5
  %3 = getelementptr inbounds %struct.mem_pool, ptr %2, i32 0, i32 0
  store i32 1346454856, ptr %3, align 8, !tbaa !9
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.mem_pool, ptr %4, i32 0, i32 1
  store ptr @Mem_PoolHeap, ptr %5, align 8, !tbaa !12
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.mem_pool, ptr %6, i32 0, i32 2
  store ptr null, ptr %7, align 8, !tbaa !13
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mem_pool, ptr %8, i32 0, i32 3
  store ptr null, ptr %9, align 8, !tbaa !14
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mem_pool, ptr %10, i32 0, i32 4
  store ptr null, ptr %11, align 8, !tbaa !15
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mem_pool, ptr %12, i32 0, i32 5
  store ptr null, ptr %13, align 8, !tbaa !16
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mem_pool, ptr %14, i32 0, i32 6
  store ptr null, ptr %15, align 8, !tbaa !17
  %16 = load ptr, ptr %1, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mem_pool, ptr %16, i32 0, i32 7
  store ptr null, ptr %17, align 8, !tbaa !18
  %18 = load ptr, ptr %1, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mem_pool, ptr %18, i32 0, i32 8
  store ptr null, ptr %19, align 8, !tbaa !19
  %20 = load ptr, ptr %1, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mem_pool, ptr %20, i32 0, i32 12
  store i32 0, ptr %21, align 4, !tbaa !20
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mem_pool, ptr %22, i32 0, i32 11
  store i32 0, ptr %23, align 8, !tbaa !21
  %24 = load ptr, ptr %1, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mem_pool, ptr %24, i32 0, i32 9
  store i32 0, ptr %25, align 8, !tbaa !22
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mem_pool, ptr %26, i32 0, i32 14
  store ptr @Mem_Heap, ptr %27, align 8, !tbaa !23
  %28 = load ptr, ptr %1, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mem_pool, ptr %28, i32 0, i32 15
  store ptr @Mem_Heap, ptr %29, align 8, !tbaa !24
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mem_pool, ptr %30, i32 0, i32 16
  store i32 1024, ptr %31, align 8, !tbaa !25
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.mem_pool, ptr %32, i32 0, i32 17
  store i32 1024, ptr %33, align 4, !tbaa !26
  store ptr @Mem_PoolHeap, ptr @Mem_PoolTbl, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret void
}

; 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

attributes #0 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"mem_pool", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !11, i64 116}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !6, i64 24}
!15 = !{!10, !6, i64 32}
!16 = !{!10, !6, i64 40}
!17 = !{!10, !6, i64 48}
!18 = !{!10, !6, i64 56}
!19 = !{!10, !6, i64 64}
!20 = !{!10, !11, i64 84}
!21 = !{!10, !11, i64 80}
!22 = !{!10, !11, i64 72}
!23 = !{!10, !6, i64 96}
!24 = !{!10, !6, i64 104}
!25 = !{!10, !11, i64 112}
!26 = !{!10, !11, i64 116}


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

%struct.mem_pool = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, i32, i32 }

@Mem_PoolHeap = external dso_local global %struct.mem_pool, align 8
@Mem_Heap = external dso_local global [1024 x i8], align 16
@Mem_PoolTbl = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @Mem_Init() local_unnamed_addr #0 {
  store i32 1346454856, ptr @Mem_PoolHeap, align 8, !tbaa !5
  store ptr @Mem_PoolHeap, ptr getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 8), align 8, !tbaa !11
  store i32 0, ptr getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 84), align 4, !tbaa !12
  store i32 0, ptr getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 80), align 8, !tbaa !13
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(60) getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 16), i8 0, i64 60, i1 false)
  store ptr @Mem_Heap, ptr getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 96), align 8, !tbaa !14
  store ptr @Mem_Heap, ptr getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 104), align 8, !tbaa !15
  store i32 1024, ptr getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 112), align 8, !tbaa !16
  store i32 1024, ptr getelementptr inbounds (i8, ptr @Mem_PoolHeap, i64 116), align 4, !tbaa !17
  store ptr @Mem_PoolHeap, ptr @Mem_PoolTbl, align 8, !tbaa !18
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) 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 nounwind willreturn memory(argmem: write) }

!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, !7, i64 0}
!6 = !{!"mem_pool", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !10, i64 96, !10, i64 104, !7, i64 112, !7, i64 116}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 84}
!13 = !{!6, !7, i64 80}
!14 = !{!6, !10, i64 96}
!15 = !{!6, !10, i64 104}
!16 = !{!6, !7, i64 112}
!17 = !{!6, !7, i64 116}
!18 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass