; LLVM IR from ggml-org/ggml :: examples/gpt-2 (main-alloc)

; 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.std::vector.25" = type { %"struct.std::_Vector_base.26" }
%"struct.std::_Vector_base.26" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.ggml_cplan = type { i64, ptr, i32, ptr, ptr, ptr }
%struct.gpt2_model = type { %struct.gpt2_hparams, ptr, ptr, ptr, ptr, ptr, %"class.std::vector.4", ptr, ptr, ptr, %"class.std::map" }
%struct.gpt2_hparams = type { i32, i32, i32, i32, i32, i32, float }
%"class.std::vector.4" = type { %"struct.std::_Vector_base.5" }
%"struct.std::_Vector_base.5" = type { %"struct.std::_Vector_base<gpt2_layer, std::allocator<gpt2_layer>>::_Vector_impl" }
%"struct.std::_Vector_base<gpt2_layer, std::allocator<gpt2_layer>>::_Vector_impl" = type { %"struct.std::_Vector_base<gpt2_layer, std::allocator<gpt2_layer>>::_Vector_impl_data" }
%"struct.std::_Vector_base<gpt2_layer, std::allocator<gpt2_layer>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%struct.ggml_tensor = type { i32, ptr, [4 x i64], [4 x i64], i32, [16 x i32], i32, [10 x ptr], ptr, i64, ptr, [64 x i8], ptr, [8 x i8] }

@__dso_handle = external hidden global i8
@.str.39 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [7 x i8], align 1
@_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer = external hidden global %"class.std::vector.25", align 8
@_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer = external hidden global i64, align 8

; 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

; Function Attrs: nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z10gpt2_graphRK10gpt2_modelii(ptr noundef nonnull align 8 dereferenceable(168), i32 noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #1

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #1

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

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

declare i64 @ggml_element_size(ptr noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEE(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %5) #3 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca %struct.ggml_cplan, align 8
  %21 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #1
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #1
  %24 = trunc i64 %23 to i32
  store i32 %24, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #1
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.gpt2_model, ptr %25, i32 0, i32 0
  store ptr %26, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #1
  %27 = load ptr, ptr %14, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.gpt2_hparams, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 4, !tbaa !11
  store i32 %29, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #1
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %32) #1
  %34 = trunc i64 %33 to i32
  %35 = call noundef ptr @_Z10gpt2_graphRK10gpt2_modelii(ptr noundef nonnull align 8 dereferenceable(168) %30, i32 noundef %31, i32 noundef %34)
  store ptr %35, ptr %16, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %16, align 8, !tbaa !5
  %38 = call zeroext i1 @ggml_gallocr_alloc_graph(ptr noundef %36, ptr noundef %37)
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #1
  %39 = load ptr, ptr %16, align 8, !tbaa !5
  %40 = call ptr @ggml_graph_get_tensor(ptr noundef %39, ptr noundef @.str.39)
  store ptr %40, ptr %17, align 8, !tbaa !5
  %41 = load ptr, ptr %17, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ggml_tensor, ptr %41, i32 0, i32 10
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = call noundef ptr @_ZNKSt6vectorIiSaIiEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %44) #1
  %46 = load i32, ptr %13, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = load ptr, ptr %17, align 8, !tbaa !5
  %49 = call i64 @ggml_element_size(ptr noundef %48)
  %50 = mul i64 %47, %49
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %43, ptr align 4 %45, i64 %50, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #1
  %51 = load ptr, ptr %16, align 8, !tbaa !5
  %52 = call ptr @ggml_graph_get_tensor(ptr noundef %51, ptr noundef @.str.40)
  store ptr %52, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #1
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %68, %6
  %54 = load i32, ptr %19, align 4, !tbaa !9
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #1
  br label %71

58:                                               ; preds = %53
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = load i32, ptr %19, align 4, !tbaa !9
  %61 = add nsw i32 %59, %60
  %62 = load ptr, ptr %18, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ggml_tensor, ptr %62, i32 0, i32 10
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = load i32, ptr %19, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i32, ptr %64, i64 %66
  store i32 %61, ptr %67, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %58
  %69 = load i32, ptr %19, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %19, align 4, !tbaa !9
  br label %53, !llvm.loop !19

71:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 48, ptr %20) #1
  %72 = load ptr, ptr %16, align 8, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !9
  call void @ggml_graph_plan(ptr dead_on_unwind writable sret(%struct.ggml_cplan) align 8 %20, ptr noundef %72, i32 noundef %73, ptr noundef null)
  %74 = load atomic i8, ptr @_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer acquire, align 8
  %75 = icmp eq i8 %74, 0
  br i1 %75, label %76, label %81, !prof !21

76:                                               ; preds = %71
  %77 = call i32 @__cxa_guard_acquire(ptr @_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #1
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %76
  call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #1
  %80 = call i32 @__cxa_atexit(ptr @_ZNSt6vectorIhSaIhEED2Ev, ptr @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer, ptr @__dso_handle) #1
  call void @__cxa_guard_release(ptr @_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #1
  br label %81

81:                                               ; preds = %79, %76, %71
  %82 = getelementptr inbounds %struct.ggml_cplan, ptr %20, i32 0, i32 0
  %83 = load i64, ptr %82, align 8, !tbaa !22
  call void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer, i64 noundef %83)
  %84 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #1
  %85 = getelementptr inbounds %struct.ggml_cplan, ptr %20, i32 0, i32 1
  store ptr %84, ptr %85, align 8, !tbaa !24
  %86 = load ptr, ptr %16, align 8, !tbaa !5
  %87 = call i32 @ggml_graph_compute(ptr noundef %86, ptr noundef %20)
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #1
  %88 = load ptr, ptr %16, align 8, !tbaa !5
  %89 = call ptr @ggml_graph_get_tensor(ptr noundef %88, ptr noundef @.str.41)
  store ptr %89, ptr %21, align 8, !tbaa !5
  %90 = load ptr, ptr %12, align 8, !tbaa !5
  %91 = load i32, ptr %15, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %90, i64 noundef %92)
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = call noundef ptr @_ZNSt6vectorIfSaIfEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %93) #1
  %95 = load ptr, ptr %21, align 8, !tbaa !5
  %96 = call ptr @ggml_get_data(ptr noundef %95)
  %97 = load i32, ptr %15, align 4, !tbaa !9
  %98 = load i32, ptr %13, align 4, !tbaa !9
  %99 = sub nsw i32 %98, 1
  %100 = mul nsw i32 %97, %99
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds float, ptr %96, i64 %101
  %103 = load i32, ptr %15, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = mul i64 4, %104
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %94, ptr align 4 %102, i64 %105, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #1
  call void @llvm.lifetime.end.p0(i64 48, ptr %20) #1
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #1
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #1
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #1
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #1
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #1
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #1
  ret i1 true
}

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

declare zeroext i1 @ggml_gallocr_alloc_graph(ptr noundef, ptr noundef) #5

declare ptr @ggml_graph_get_tensor(ptr noundef, ptr noundef) #5

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

declare void @ggml_graph_plan(ptr dead_on_unwind writable sret(%struct.ggml_cplan) align 8, ptr noundef, i32 noundef, ptr noundef) #5

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

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

declare i32 @ggml_graph_compute(ptr noundef, ptr noundef) #5

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

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

declare ptr @ggml_get_data(ptr noundef) #5

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

!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, !10, i64 0}
!12 = !{!"_ZTS12gpt2_hparams", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !6, i64 248}
!15 = !{!"_ZTS11ggml_tensor", !16, i64 0, !6, i64 8, !7, i64 16, !7, i64 48, !17, i64 80, !7, i64 84, !10, i64 148, !7, i64 152, !6, i64 232, !18, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!16 = !{!"_ZTS9ggml_type", !7, i64 0}
!17 = !{!"_ZTS7ggml_op", !7, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"branch_weights", i32 1, i32 1048575}
!22 = !{!23, !18, i64 0}
!23 = !{!"_ZTS10ggml_cplan", !18, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!24 = !{!23, !6, i64 8}


; 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.std::vector.25" = type { %"struct.std::_Vector_base.26" }
%"struct.std::_Vector_base.26" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.ggml_cplan = type { i64, ptr, i32, ptr, ptr, ptr }

@__dso_handle = external hidden global i8
@.str.39 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [7 x i8], align 1
@_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer = external hidden global %"class.std::vector.25", align 8
@_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer = external hidden global i64, align 8

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

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

; Function Attrs: nofree nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z10gpt2_graphRK10gpt2_modelii(ptr noundef nonnull align 8 dereferenceable(168), i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #1

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

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

declare i64 @ggml_element_size(ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEE(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %5) local_unnamed_addr #3 {
  %7 = alloca %struct.ggml_cplan, align 8
  %8 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  %9 = trunc i64 %8 to i32
  %10 = load i32, ptr %0, align 8, !tbaa !5
  %11 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  %12 = trunc i64 %11 to i32
  %13 = tail call noundef ptr @_Z10gpt2_graphRK10gpt2_modelii(ptr noundef nonnull align 8 dereferenceable(168) %0, i32 noundef %3, i32 noundef %12)
  %14 = tail call zeroext i1 @ggml_gallocr_alloc_graph(ptr noundef %1, ptr noundef %13)
  %15 = tail call ptr @ggml_graph_get_tensor(ptr noundef %13, ptr noundef nonnull @.str.39)
  %16 = getelementptr inbounds i8, ptr %15, i64 248
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = tail call noundef ptr @_ZNKSt6vectorIiSaIiEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  %sext = shl i64 %8, 32
  %19 = ashr exact i64 %sext, 32
  %20 = tail call i64 @ggml_element_size(ptr noundef %15)
  %21 = mul i64 %20, %19
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %17, ptr align 4 %18, i64 %21, i1 false)
  %22 = tail call ptr @ggml_graph_get_tensor(ptr noundef %13, ptr noundef nonnull @.str.40)
  %23 = icmp sgt i32 %9, 0
  br i1 %23, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6
  %24 = getelementptr inbounds i8, ptr %22, i64 248
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %wide.trip.count = and i64 %8, 2147483647
  %min.iters.check = icmp ult i64 %wide.trip.count, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.mod.vf = and i64 %8, 7
  %n.vec = sub nsw i64 %wide.trip.count, %n.mod.vf
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %3, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %26 = getelementptr inbounds i32, ptr %25, i64 %index
  %27 = add <4 x i32> %vec.ind, %broadcast.splat
  %28 = add <4 x i32> %step.add, %broadcast.splat
  %29 = getelementptr inbounds i8, ptr %26, i64 16
  store <4 x i32> %27, ptr %26, align 4, !tbaa !17
  store <4 x i32> %28, ptr %29, align 4, !tbaa !17
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %30 = icmp eq i64 %index.next, %n.vec
  br i1 %30, label %middle.block, label %vector.body, !llvm.loop !18

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.mod.vf, 0
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %6
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %7) #6
  call void @ggml_graph_plan(ptr dead_on_unwind nonnull writable sret(%struct.ggml_cplan) align 8 %7, ptr noundef %13, i32 noundef %2, ptr noundef null)
  %31 = load atomic i8, ptr @_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer acquire, align 8
  %32 = icmp eq i8 %31, 0
  br i1 %32, label %36, label %40, !prof !22

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %33 = getelementptr inbounds i32, ptr %25, i64 %indvars.iv
  %34 = trunc i64 %indvars.iv to i32
  %35 = add i32 %34, %3
  store i32 %35, ptr %33, align 4, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !23

36:                                               ; preds = %._crit_edge
  %37 = call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #6
  %.not = icmp eq i32 %37, 0
  br i1 %.not, label %40, label %38

38:                                               ; preds = %36
  call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #6
  %39 = call i32 @__cxa_atexit(ptr nonnull @_ZNSt6vectorIhSaIhEED2Ev, ptr nonnull @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer, ptr nonnull @__dso_handle) #6
  call void @__cxa_guard_release(ptr nonnull @_ZGVZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #6
  br label %40

40:                                               ; preds = %38, %36, %._crit_edge
  %41 = load i64, ptr %7, align 8, !tbaa !24
  call void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer, i64 noundef %41)
  %42 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZZ9gpt2_evalRK10gpt2_modelP12ggml_gallocriiRKSt6vectorIiSaIiEERS4_IfSaIfEEE11work_buffer) #6
  %43 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %42, ptr %43, align 8, !tbaa !26
  %44 = call i32 @ggml_graph_compute(ptr noundef %13, ptr noundef nonnull %7)
  %45 = call ptr @ggml_graph_get_tensor(ptr noundef %13, ptr noundef nonnull @.str.41)
  %46 = sext i32 %10 to i64
  call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %46)
  %47 = call noundef ptr @_ZNSt6vectorIfSaIfEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  %48 = call ptr @ggml_get_data(ptr noundef %45)
  %49 = add nsw i32 %9, -1
  %50 = mul nsw i32 %49, %10
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds float, ptr %48, i64 %51
  %53 = shl nsw i64 %46, 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %47, ptr align 4 %52, i64 %53, i1 false)
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %7) #6
  ret i1 true
}

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

declare zeroext i1 @ggml_gallocr_alloc_graph(ptr noundef, ptr noundef) local_unnamed_addr #5

declare ptr @ggml_graph_get_tensor(ptr noundef, ptr noundef) local_unnamed_addr #5

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

declare void @ggml_graph_plan(ptr dead_on_unwind writable sret(%struct.ggml_cplan) align 8, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

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

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

declare i32 @ggml_graph_compute(ptr noundef, ptr noundef) local_unnamed_addr #5

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

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

declare ptr @ggml_get_data(ptr noundef) local_unnamed_addr #5

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

!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 = !{!"_ZTS12gpt2_hparams", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!12, !14, i64 248}
!12 = !{!"_ZTS11ggml_tensor", !13, i64 0, !14, i64 8, !8, i64 16, !8, i64 48, !15, i64 80, !8, i64 84, !7, i64 148, !8, i64 152, !14, i64 232, !16, i64 240, !14, i64 248, !8, i64 256, !14, i64 320, !8, i64 328}
!13 = !{!"_ZTS9ggml_type", !8, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTS7ggml_op", !8, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19, !20, !21}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.isvectorized", i32 1}
!21 = !{!"llvm.loop.unroll.runtime.disable"}
!22 = !{!"branch_weights", i32 1, i32 1048575}
!23 = distinct !{!23, !19, !21, !20}
!24 = !{!25, !16, i64 0}
!25 = !{!"_ZTS10ggml_cplan", !16, i64 0, !14, i64 8, !7, i64 16, !14, i64 24, !14, i64 32, !14, i64 40}
!26 = !{!25, !14, i64 8}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass