; LLVM IR from thepowersgang/mrustc :: src/hir_conv/constant_evaluation.ll (ZN3MIR4eval13AllocationPtr11allocate_roEPKvm)

; 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.MIR::eval::AllocationPtr" = type { %"class.MIR::eval::RefCountPtr" }
%"class.MIR::eval::RefCountPtr" = type { ptr }
%"class.HIR::TypeRef" = type { ptr }
%"class.MIR::eval::Allocation" = type <{ %"class.MIR::eval::IValue", i32, i32, i8, [7 x i8], %"class.HIR::TypeRef", %"class.std::vector.15", [1 x i8], [7 x i8] }>
%"class.MIR::eval::IValue" = type { ptr }
%"class.std::vector.15" = type { %"struct.std::_Vector_base.16" }
%"struct.std::_Vector_base.16" = type { %"struct.std::_Vector_base<MIR::eval::Allocation::Reloc, std::allocator<MIR::eval::Allocation::Reloc>>::_Vector_impl" }
%"struct.std::_Vector_base<MIR::eval::Allocation::Reloc, std::allocator<MIR::eval::Allocation::Reloc>>::_Vector_impl" = type { %"struct.std::_Vector_base<MIR::eval::Allocation::Reloc, std::allocator<MIR::eval::Allocation::Reloc>>::_Vector_impl_data" }
%"struct.std::_Vector_base<MIR::eval::Allocation::Reloc, std::allocator<MIR::eval::Allocation::Reloc>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3HIR7TypeRefD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3MIR4eval13AllocationPtrC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3MIR4eval10AllocationC2EmRKN3HIR7TypeRefE(ptr noundef nonnull align 8 dereferenceable(64), i64 noundef, ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3MIR4eval13AllocationPtr11allocate_roEPKvm(ptr dead_on_unwind noalias writable sret(%"class.MIR::eval::AllocationPtr") align 8 %0, ptr noundef %1, i64 noundef %2) #5 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i1, align 1
  %9 = alloca %"class.HIR::TypeRef", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = add i64 64, %12
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = add i64 %14, 7
  %16 = udiv i64 %15, 8
  %17 = add i64 %13, %16
  %18 = call noalias ptr @malloc(i64 noundef %17) #7
  store ptr %18, ptr %7, align 8, !tbaa !5
  store i1 false, ptr %8, align 1
  call void @_ZN3MIR4eval13AllocationPtrC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load i64, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  invoke void @_ZN3HIR7TypeRefC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %21 unwind label %33

21:                                               ; preds = %3
  invoke void @_ZN3MIR4eval10AllocationC2EmRKN3HIR7TypeRefE(ptr noundef nonnull align 8 dereferenceable(64) %19, i64 noundef %20, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %22 unwind label %37

22:                                               ; preds = %21
  %23 = getelementptr inbounds %"class.MIR::eval::RefCountPtr", ptr %0, i32 0, i32 0
  store ptr %19, ptr %23, align 8, !tbaa !11
  call void @_ZN3HIR7TypeRefD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %24 = invoke noundef ptr @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
          to label %25 unwind label %42

25:                                               ; preds = %22
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i64, ptr %6, align 8, !tbaa !9
  invoke void @_ZN3MIR4eval6IValue11write_bytesEmPKvm(ptr noundef nonnull align 8 dereferenceable(8) %24, i64 noundef 0, ptr noundef %26, i64 noundef %27)
          to label %28 unwind label %42

28:                                               ; preds = %25
  %29 = invoke noundef ptr @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
          to label %30 unwind label %42

30:                                               ; preds = %28
  %31 = getelementptr inbounds %"class.MIR::eval::Allocation", ptr %29, i32 0, i32 3
  store i8 1, ptr %31, align 8, !tbaa !13
  store i1 true, ptr %8, align 1
  %32 = load i1, ptr %8, align 1
  br i1 %32, label %47, label %46

33:                                               ; preds = %3
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %10, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %11, align 4
  br label %41

37:                                               ; preds = %21
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %10, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %11, align 4
  call void @_ZN3HIR7TypeRefD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #6
  br label %41

41:                                               ; preds = %37, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %48

42:                                               ; preds = %28, %25, %22
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %10, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %11, align 4
  br label %48

46:                                               ; preds = %30
  call void @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #6
  br label %47

47:                                               ; preds = %46, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret void

48:                                               ; preds = %42, %41
  call void @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %10, align 8
  %51 = load i32, ptr %11, align 4
  %52 = insertvalue { ptr, i32 } poison, ptr %50, 0
  %53 = insertvalue { ptr, i32 } %52, i32 %51, 1
  resume { ptr, i32 } %53
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3HIR7TypeRefC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3MIR4eval6IValue11write_bytesEmPKvm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, ptr noundef, i64 noundef) #5 align 2

attributes #0 = { inlinehint 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 = { 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 = { inlinehint 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN3MIR4eval11RefCountPtrINS0_10AllocationEEE", !6, i64 0}
!13 = !{!14, !17, i64 16}
!14 = !{!"_ZTSN3MIR4eval10AllocationE", !15, i64 0, !16, i64 8, !16, i64 12, !17, i64 16, !18, i64 24, !19, i64 32, !7, i64 56}
!15 = !{!"_ZTSN3MIR4eval6IValueE"}
!16 = !{!"int", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSN3HIR7TypeRefE", !6, i64 0}
!19 = !{!"_ZTSSt6vectorIN3MIR4eval10Allocation5RelocESaIS3_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIN3MIR4eval10Allocation5RelocESaIS3_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN3MIR4eval10Allocation5RelocESaIS3_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN3MIR4eval10Allocation5RelocESaIS3_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


; 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.MIR::eval::AllocationPtr" = type { %"class.MIR::eval::RefCountPtr" }
%"class.MIR::eval::RefCountPtr" = type { ptr }
%"class.HIR::TypeRef" = type { ptr }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3HIR7TypeRefD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3MIR4eval13AllocationPtrC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3MIR4eval10AllocationC2EmRKN3HIR7TypeRefE(ptr noundef nonnull align 8 dereferenceable(64), i64 noundef, ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3MIR4eval13AllocationPtr11allocate_roEPKvm(ptr dead_on_unwind noalias nonnull writable sret(%"class.MIR::eval::AllocationPtr") align 8 %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.HIR::TypeRef", align 8
  %5 = add i64 %2, 64
  %6 = add i64 %2, 7
  %7 = lshr i64 %6, 3
  %8 = add i64 %5, %7
  %9 = tail call noalias ptr @malloc(i64 noundef %8) #6
  tail call void @_ZN3MIR4eval13AllocationPtrC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  invoke void @_ZN3HIR7TypeRefC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %10 unwind label %16

10:                                               ; preds = %3
  invoke void @_ZN3MIR4eval10AllocationC2EmRKN3HIR7TypeRefE(ptr noundef nonnull align 8 dereferenceable(64) %9, i64 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %11 unwind label %18

11:                                               ; preds = %10
  store ptr %9, ptr %0, align 8, !tbaa !5
  call void @_ZN3HIR7TypeRefD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  %12 = call noundef ptr @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  invoke void @_ZN3MIR4eval6IValue11write_bytesEmPKvm(ptr noundef nonnull align 8 dereferenceable(8) %12, i64 noundef 0, ptr noundef %1, i64 noundef %2)
          to label %13 unwind label %21

13:                                               ; preds = %11
  %14 = call noundef ptr @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  store i8 1, ptr %15, align 8, !tbaa !10
  ret void

16:                                               ; preds = %3
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %20

18:                                               ; preds = %10
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3HIR7TypeRefD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  br label %20

20:                                               ; preds = %18, %16
  %.pn = phi { ptr, i32 } [ %19, %18 ], [ %17, %16 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %23

21:                                               ; preds = %11
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %23

23:                                               ; preds = %21, %20
  %.pn11 = phi { ptr, i32 } [ %22, %21 ], [ %.pn, %20 ]
  call void @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #7
  resume { ptr, i32 } %.pn11
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3HIR7TypeRefC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3MIR4eval11RefCountPtrINS0_10AllocationEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3MIR4eval6IValue11write_bytesEmPKvm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #5 align 2

attributes #0 = { inlinehint 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 = { mustprogress 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { inlinehint 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 #5 = { 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 #6 = { nounwind allocsize(0) }
attributes #7 = { 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 0}
!6 = !{!"_ZTSN3MIR4eval11RefCountPtrINS0_10AllocationEEE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !14, i64 16}
!11 = !{!"_ZTSN3MIR4eval10AllocationE", !12, i64 0, !13, i64 8, !13, i64 12, !14, i64 16, !15, i64 24, !16, i64 32, !8, i64 56}
!12 = !{!"_ZTSN3MIR4eval6IValueE"}
!13 = !{!"int", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!"_ZTSN3HIR7TypeRefE", !7, i64 0}
!16 = !{!"_ZTSSt6vectorIN3MIR4eval10Allocation5RelocESaIS3_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIN3MIR4eval10Allocation5RelocESaIS3_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN3MIR4eval10Allocation5RelocESaIS3_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN3MIR4eval10Allocation5RelocESaIS3_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}


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