; LLVM IR from liaojing/MorphLib :: MorphLib/Morph.ll (ZN8MorphLib6CMorph13load_identityEi)

; 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.MorphLib::CMorph" = type <{ ptr, ptr, i32, i32, i32, i32, i32, [4 x i8], ptr, i8, [7 x i8] }>
%class.CPyramid = type { %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<CPyramidLevel, std::allocator<CPyramidLevel>>::_Vector_impl" }
%"struct.std::_Vector_base<CPyramidLevel, std::allocator<CPyramidLevel>>::_Vector_impl" = type { %"struct.std::_Vector_base<CPyramidLevel, std::allocator<CPyramidLevel>>::_Vector_impl_data" }
%"struct.std::_Vector_base<CPyramidLevel, std::allocator<CPyramidLevel>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.CPyramidLevel = type { i32, i32, float, i32, i32, i32, ptr, ptr, ptr, ptr }
%"struct.MorphLib::CData" = type { %struct.anon, %struct.anon.5, %struct.anon.6, ptr, ptr, ptr, ptr, i32 }
%struct.anon = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.anon.5 = type { ptr, ptr, ptr }
%struct.anon.6 = type { ptr, ptr, ptr }

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt6vectorI13CPyramidLevelSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8MorphLib6CMorph13load_identityEi(ptr noundef nonnull align 8 dereferenceable(49) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %7 = getelementptr inbounds %"class.MorphLib::CMorph", ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds %class.CPyramid, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = call noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt6vectorI13CPyramidLevelSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %11) #4
  %13 = getelementptr inbounds %class.CPyramidLevel, ptr %12, i32 0, i32 5
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %15 = mul nsw i32 %14, 25
  %16 = sext i32 %15 to i64
  %17 = mul i64 %16, 4
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %5, align 4, !tbaa !9
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = call noalias ptr @malloc(i64 noundef %20) #5
  %22 = getelementptr inbounds %"class.MorphLib::CMorph", ptr %6, i32 0, i32 8
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds %"struct.MorphLib::CData", ptr %23, i64 %25
  %27 = getelementptr inbounds %"struct.MorphLib::CData", ptr %26, i32 0, i32 4
  store ptr %21, ptr %27, align 8, !tbaa !18
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = call noalias ptr @malloc(i64 noundef %29) #5
  %31 = getelementptr inbounds %"class.MorphLib::CMorph", ptr %6, i32 0, i32 8
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %"struct.MorphLib::CData", ptr %32, i64 %34
  %36 = getelementptr inbounds %"struct.MorphLib::CData", ptr %35, i32 0, i32 5
  store ptr %30, ptr %36, align 8, !tbaa !23
  %37 = getelementptr inbounds %"class.MorphLib::CMorph", ptr %6, i32 0, i32 8
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %"struct.MorphLib::CData", ptr %38, i64 %40
  %42 = getelementptr inbounds %"struct.MorphLib::CData", ptr %41, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !18
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  call void @llvm.memset.p0.i64(ptr align 4 %43, i8 0, i64 %45, i1 false)
  %46 = getelementptr inbounds %"class.MorphLib::CMorph", ptr %6, i32 0, i32 8
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %"struct.MorphLib::CData", ptr %47, i64 %49
  %51 = getelementptr inbounds %"struct.MorphLib::CData", ptr %50, i32 0, i32 5
  %52 = load ptr, ptr %51, align 8, !tbaa !23
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  call void @llvm.memset.p0.i64(ptr align 4 %52, i8 0, i64 %54, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind 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 = { nounwind }
attributes #5 = { nounwind 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN8MorphLib6CMorphE", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !13, i64 48}
!13 = !{!"bool", !7, i64 0}
!14 = !{!15, !10, i64 20}
!15 = !{!"_ZTS13CPyramidLevel", !10, i64 0, !10, i64 4, !16, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!16 = !{!"float", !7, i64 0}
!17 = !{!12, !6, i64 40}
!18 = !{!19, !6, i64 128}
!19 = !{!"_ZTSN8MorphLib5CDataE", !20, i64 0, !21, i64 72, !22, i64 96, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !10, i64 152}
!20 = !{!"_ZTSN8MorphLib5CDataUt_E", !6, 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}
!21 = !{!"_ZTSN8MorphLib5CDataUt0_E", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"_ZTSN8MorphLib5CDataUt1_E", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!19, !6, i64 136}


; 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.MorphLib::CData" = type { %struct.anon, %struct.anon.5, %struct.anon.6, ptr, ptr, ptr, ptr, i32 }
%struct.anon = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.anon.5 = type { ptr, ptr, ptr }
%struct.anon.6 = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt6vectorI13CPyramidLevelSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8MorphLib6CMorph13load_identityEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(49) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = sext i32 %1 to i64
  %6 = tail call noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt6vectorI13CPyramidLevelSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %5) #2
  %7 = getelementptr inbounds i8, ptr %6, i64 20
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %9 = mul i32 %8, 100
  %10 = sext i32 %9 to i64
  %calloc = tail call ptr @calloc(i64 1, i64 %10)
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds %"struct.MorphLib::CData", ptr %12, i64 %5, i32 4
  store ptr %calloc, ptr %13, align 8, !tbaa !16
  %calloc9 = tail call ptr @calloc(i64 1, i64 %10)
  %14 = getelementptr inbounds %"struct.MorphLib::CData", ptr %12, i64 %5, i32 5
  store ptr %calloc9, ptr %14, align 8, !tbaa !21
  ret void
}

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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, !7, i64 8}
!6 = !{!"_ZTSN8MorphLib6CMorphE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !7, i64 40, !11, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!13, !10, i64 20}
!13 = !{!"_ZTS13CPyramidLevel", !10, i64 0, !10, i64 4, !14, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!14 = !{!"float", !8, i64 0}
!15 = !{!6, !7, i64 40}
!16 = !{!17, !7, i64 128}
!17 = !{!"_ZTSN8MorphLib5CDataE", !18, i64 0, !19, i64 72, !20, i64 96, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !10, i64 152}
!18 = !{!"_ZTSN8MorphLib5CDataUt_E", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!19 = !{!"_ZTSN8MorphLib5CDataUt0_E", !7, i64 0, !7, i64 8, !7, i64 16}
!20 = !{!"_ZTSN8MorphLib5CDataUt1_E", !7, i64 0, !7, i64 8, !7, i64 16}
!21 = !{!17, !7, i64 136}


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