; LLVM IR from ggml-org/ggml :: src/ggml-rpc (ggml-rpc)

; 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.ggml_init_params = type { i64, ptr, i8 }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.6" }
%"struct.std::_Head_base.6" = type { ptr }
%struct.rpc_msg_copy_tensor_req = type { %struct.rpc_tensor, %struct.rpc_tensor }
%struct.rpc_tensor = type <{ i64, i32, i64, [4 x i32], [4 x i32], i32, [16 x i32], i32, [10 x i64], i64, i64, i64, [64 x i8], [4 x i8] }>
%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] }
%struct.rpc_msg_copy_tensor_rsp = type { i8 }

@.str.3 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [34 x i8], align 1
@__func__._ZN10rpc_server11copy_tensorERK23rpc_msg_copy_tensor_reqR23rpc_msg_copy_tensor_rsp = external hidden unnamed_addr constant [12 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

; 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) #1

declare i64 @ggml_tensor_overhead() #2

declare ptr @ggml_init(ptr noundef byval(%struct.ggml_init_params) align 8) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneI12ggml_context20ggml_context_deleterEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8), ptr) #4

; Function Attrs: noreturn
declare void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) #5

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN10rpc_server18deserialize_tensorEP12ggml_contextPK10rpc_tensor(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef, ptr noundef) #6 align 2

declare void @ggml_log_internal(i32 noundef, ptr noundef, ...) #2

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

declare ptr @ggml_backend_buffer_get_base(ptr noundef) #2

declare i64 @ggml_nbytes(ptr noundef) #2

declare i64 @ggml_backend_buffer_get_size(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN10rpc_server11copy_tensorERK23rpc_msg_copy_tensor_reqR23rpc_msg_copy_tensor_rsp(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 1 dereferenceable(592) %1, ptr noundef nonnull align 1 dereferenceable(1) %2) #6 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.ggml_init_params, align 8
  %9 = alloca %"class.std::unique_ptr", align 8
  %10 = alloca %struct.ggml_init_params, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #7
  %22 = getelementptr inbounds %struct.ggml_init_params, ptr %8, i32 0, i32 0
  %23 = call i64 @ggml_tensor_overhead()
  %24 = mul i64 2, %23
  store i64 %24, ptr %22, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.ggml_init_params, ptr %8, i32 0, i32 1
  store ptr null, ptr %25, align 8, !tbaa !13
  %26 = getelementptr inbounds %struct.ggml_init_params, ptr %8, i32 0, i32 2
  store i8 1, ptr %26, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %8, i64 24, i1 false), !tbaa.struct !15
  %27 = call ptr @ggml_init(ptr noundef byval(%struct.ggml_init_params) align 8 %10)
  call void @_ZNSt10unique_ptrI12ggml_context20ggml_context_deleterEC2IS1_vEEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef %27) #7
  %28 = call noundef zeroext i1 @_ZStneI12ggml_context20ggml_context_deleterEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr null) #7
  br i1 %28, label %35, label %29

29:                                               ; preds = %3
  invoke void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.3, i32 noundef 1226, ptr noundef @.str.4, ptr noundef @.str.5) #8
          to label %30 unwind label %31

30:                                               ; preds = %29
  unreachable

31:                                               ; preds = %29
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %11, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %12, align 4
  br label %116

35:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %36 = call noundef ptr @_ZNKSt10unique_ptrI12ggml_context20ggml_context_deleterE3getEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  store ptr %36, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %37 = load ptr, ptr %13, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.rpc_msg_copy_tensor_req, ptr %38, i32 0, i32 0
  %40 = invoke noundef ptr @_ZN10rpc_server18deserialize_tensorEP12ggml_contextPK10rpc_tensor(ptr noundef nonnull align 8 dereferenceable(72) %21, ptr noundef %37, ptr noundef %39)
          to label %41 unwind label %54

41:                                               ; preds = %35
  store ptr %40, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.rpc_msg_copy_tensor_req, ptr %43, i32 0, i32 1
  %45 = invoke noundef ptr @_ZN10rpc_server18deserialize_tensorEP12ggml_contextPK10rpc_tensor(ptr noundef nonnull align 8 dereferenceable(72) %21, ptr noundef %42, ptr noundef %44)
          to label %46 unwind label %58

46:                                               ; preds = %41
  store ptr %45, ptr %15, align 8, !tbaa !5
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = icmp eq ptr %47, null
  br i1 %48, label %52, label %49

49:                                               ; preds = %46
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %62

52:                                               ; preds = %49, %46
  invoke void (i32, ptr, ...) @ggml_log_internal(i32 noundef 4, ptr noundef @.str.22, ptr noundef @__func__._ZN10rpc_server11copy_tensorERK23rpc_msg_copy_tensor_reqR23rpc_msg_copy_tensor_rsp)
          to label %53 unwind label %58

53:                                               ; preds = %52
  store i1 false, ptr %4, align 1
  store i32 1, ptr %16, align 4
  br label %112

54:                                               ; preds = %35
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %11, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %12, align 4
  br label %115

58:                                               ; preds = %52, %41
  %59 = landingpad { ptr, i32 }
          cleanup
  %60 = extractvalue { ptr, i32 } %59, 0
  store ptr %60, ptr %11, align 8
  %61 = extractvalue { ptr, i32 } %59, 1
  store i32 %61, ptr %12, align 4
  br label %114

62:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %63 = load ptr, ptr %14, align 8, !tbaa !5
  %64 = invoke i64 @ggml_nbytes(ptr noundef %63)
          to label %65 unwind label %89

65:                                               ; preds = %62
  store i64 %64, ptr %17, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.ggml_tensor, ptr %66, i32 0, i32 10
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = ptrtoint ptr %68 to i64
  store i64 %69, ptr %18, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %70 = load ptr, ptr %15, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ggml_tensor, ptr %70, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !23
  %73 = invoke ptr @ggml_backend_buffer_get_base(ptr noundef %72)
          to label %74 unwind label %93

74:                                               ; preds = %65
  %75 = ptrtoint ptr %73 to i64
  store i64 %75, ptr %19, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ggml_tensor, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !23
  %79 = invoke i64 @ggml_backend_buffer_get_size(ptr noundef %78)
          to label %80 unwind label %97

80:                                               ; preds = %74
  store i64 %79, ptr %20, align 8, !tbaa !16
  %81 = load i64, ptr %18, align 8, !tbaa !16
  %82 = load i64, ptr %17, align 8, !tbaa !16
  %83 = add i64 %81, %82
  %84 = load i64, ptr %19, align 8, !tbaa !16
  %85 = load i64, ptr %20, align 8, !tbaa !16
  %86 = add i64 %84, %85
  %87 = icmp ugt i64 %83, %86
  br i1 %87, label %88, label %101

88:                                               ; preds = %80
  store i1 false, ptr %4, align 1
  store i32 1, ptr %16, align 4
  br label %109

89:                                               ; preds = %62
  %90 = landingpad { ptr, i32 }
          cleanup
  %91 = extractvalue { ptr, i32 } %90, 0
  store ptr %91, ptr %11, align 8
  %92 = extractvalue { ptr, i32 } %90, 1
  store i32 %92, ptr %12, align 4
  br label %111

93:                                               ; preds = %65
  %94 = landingpad { ptr, i32 }
          cleanup
  %95 = extractvalue { ptr, i32 } %94, 0
  store ptr %95, ptr %11, align 8
  %96 = extractvalue { ptr, i32 } %94, 1
  store i32 %96, ptr %12, align 4
  br label %110

97:                                               ; preds = %101, %74
  %98 = landingpad { ptr, i32 }
          cleanup
  %99 = extractvalue { ptr, i32 } %98, 0
  store ptr %99, ptr %11, align 8
  %100 = extractvalue { ptr, i32 } %98, 1
  store i32 %100, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  br label %110

101:                                              ; preds = %80
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  %104 = invoke zeroext i1 @ggml_backend_buffer_copy_tensor(ptr noundef %102, ptr noundef %103)
          to label %105 unwind label %97

105:                                              ; preds = %101
  %106 = zext i1 %104 to i8
  %107 = load ptr, ptr %7, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.rpc_msg_copy_tensor_rsp, ptr %107, i32 0, i32 0
  store i8 %106, ptr %108, align 1, !tbaa !24
  store i1 true, ptr %4, align 1
  store i32 1, ptr %16, align 4
  br label %109

109:                                              ; preds = %105, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %112

110:                                              ; preds = %97, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %111

111:                                              ; preds = %110, %89
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %114

112:                                              ; preds = %109, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @_ZNSt10unique_ptrI12ggml_context20ggml_context_deleterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #7
  %113 = load i1, ptr %4, align 1
  ret i1 %113

114:                                              ; preds = %111, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %115

115:                                              ; preds = %114, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %116

116:                                              ; preds = %115, %31
  call void @_ZNSt10unique_ptrI12ggml_context20ggml_context_deleterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #7
  br label %117

117:                                              ; preds = %116
  %118 = load ptr, ptr %11, align 8
  %119 = load i32, ptr %12, align 4
  %120 = insertvalue { ptr, i32 } poison, ptr %118, 0
  %121 = insertvalue { ptr, i32 } %120, i32 %119, 1
  resume { ptr, i32 } %121
}

declare zeroext i1 @ggml_backend_buffer_copy_tensor(ptr noundef, ptr noundef) #2

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

!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, !11, i64 0}
!10 = !{!"_ZTS16ggml_init_params", !11, i64 0, !6, i64 8, !12, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !12, i64 16}
!15 = !{i64 0, i64 8, !16, i64 8, i64 8, !5, i64 16, i64 1, !17}
!16 = !{!11, !11, i64 0}
!17 = !{!12, !12, i64 0}
!18 = !{!19, !6, i64 248}
!19 = !{!"_ZTS11ggml_tensor", !20, i64 0, !6, i64 8, !7, i64 16, !7, i64 48, !21, i64 80, !7, i64 84, !22, i64 148, !7, i64 152, !6, i64 232, !11, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!20 = !{!"_ZTS9ggml_type", !7, i64 0}
!21 = !{!"_ZTS7ggml_op", !7, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!19, !6, i64 8}
!24 = !{!25, !7, i64 0}
!25 = !{!"_ZTS23rpc_msg_copy_tensor_rsp", !7, 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"

%struct.ggml_init_params = type { i64, ptr, i8 }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.6" }
%"struct.std::_Head_base.6" = type { ptr }

@.str.3 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [34 x i8], align 1
@__func__._ZN10rpc_server11copy_tensorERK23rpc_msg_copy_tensor_reqR23rpc_msg_copy_tensor_rsp = external hidden unnamed_addr constant [12 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

declare i64 @ggml_tensor_overhead() local_unnamed_addr #1

declare ptr @ggml_init(ptr noundef byval(%struct.ggml_init_params) align 8) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneI12ggml_context20ggml_context_deleterEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8), ptr) local_unnamed_addr #3

; Function Attrs: noreturn
declare void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #4

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

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

declare void @ggml_log_internal(i32 noundef, ptr noundef, ...) local_unnamed_addr #1

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

declare ptr @ggml_backend_buffer_get_base(ptr noundef) local_unnamed_addr #1

declare i64 @ggml_nbytes(ptr noundef) local_unnamed_addr #1

declare i64 @ggml_backend_buffer_get_size(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN10rpc_server11copy_tensorERK23rpc_msg_copy_tensor_reqR23rpc_msg_copy_tensor_rsp(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 1 dereferenceable(592) %1, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(1) %2) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::unique_ptr", align 8
  %5 = alloca %struct.ggml_init_params, align 8
  %6 = tail call i64 @ggml_tensor_overhead()
  %7 = shl i64 %6, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store i64 %7, ptr %5, align 8, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store ptr null, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !9
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 16
  store i8 1, ptr %.sroa.6.0..sroa_idx, align 8, !tbaa !11
  %8 = tail call ptr @ggml_init(ptr noundef nonnull byval(%struct.ggml_init_params) align 8 %5)
  call void @_ZNSt10unique_ptrI12ggml_context20ggml_context_deleterEC2IS1_vEEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef %8) #6
  %9 = call noundef zeroext i1 @_ZStneI12ggml_context20ggml_context_deleterEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr null) #6
  br i1 %9, label %14, label %10

10:                                               ; preds = %3
  invoke void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.3, i32 noundef 1226, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5) #7
          to label %11 unwind label %12

11:                                               ; preds = %10
  unreachable

12:                                               ; preds = %10
  %13 = landingpad { ptr, i32 }
          cleanup
  br label %55

14:                                               ; preds = %3
  %15 = call noundef ptr @_ZNKSt10unique_ptrI12ggml_context20ggml_context_deleterE3getEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  %16 = invoke noundef ptr @_ZN10rpc_server18deserialize_tensorEP12ggml_contextPK10rpc_tensor(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %15, ptr noundef nonnull %1)
          to label %17 unwind label %24

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %1, i64 296
  %19 = invoke noundef ptr @_ZN10rpc_server18deserialize_tensorEP12ggml_contextPK10rpc_tensor(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %15, ptr noundef nonnull %18)
          to label %20 unwind label %26

20:                                               ; preds = %17
  %21 = icmp eq ptr %16, null
  %22 = icmp eq ptr %19, null
  %or.cond = or i1 %21, %22
  br i1 %or.cond, label %23, label %28

23:                                               ; preds = %20
  invoke void (i32, ptr, ...) @ggml_log_internal(i32 noundef 4, ptr noundef nonnull @.str.22, ptr noundef nonnull @__func__._ZN10rpc_server11copy_tensorERK23rpc_msg_copy_tensor_reqR23rpc_msg_copy_tensor_rsp)
          to label %54 unwind label %26

24:                                               ; preds = %14
  %25 = landingpad { ptr, i32 }
          cleanup
  br label %55

26:                                               ; preds = %23, %17
  %27 = landingpad { ptr, i32 }
          cleanup
  br label %55

28:                                               ; preds = %20
  %29 = invoke i64 @ggml_nbytes(ptr noundef nonnull %16)
          to label %30 unwind label %44

30:                                               ; preds = %28
  %31 = getelementptr inbounds i8, ptr %19, i64 248
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = ptrtoint ptr %32 to i64
  %34 = getelementptr inbounds i8, ptr %19, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  %36 = invoke ptr @ggml_backend_buffer_get_base(ptr noundef %35)
          to label %37 unwind label %46

37:                                               ; preds = %30
  %38 = load ptr, ptr %34, align 8, !tbaa !18
  %39 = invoke i64 @ggml_backend_buffer_get_size(ptr noundef %38)
          to label %40 unwind label %48

40:                                               ; preds = %37
  %41 = ptrtoint ptr %36 to i64
  %42 = add i64 %29, %33
  %43 = add i64 %39, %41
  %.not = icmp ugt i64 %42, %43
  br i1 %.not, label %54, label %50

44:                                               ; preds = %28
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %55

46:                                               ; preds = %30
  %47 = landingpad { ptr, i32 }
          cleanup
  br label %55

48:                                               ; preds = %50, %37
  %49 = landingpad { ptr, i32 }
          cleanup
  br label %55

50:                                               ; preds = %40
  %51 = invoke zeroext i1 @ggml_backend_buffer_copy_tensor(ptr noundef nonnull %16, ptr noundef nonnull %19)
          to label %52 unwind label %48

52:                                               ; preds = %50
  %53 = zext i1 %51 to i8
  store i8 %53, ptr %2, align 1, !tbaa !19
  br label %54

54:                                               ; preds = %52, %40, %23
  %.1 = phi i1 [ false, %23 ], [ false, %40 ], [ true, %52 ]
  call void @_ZNSt10unique_ptrI12ggml_context20ggml_context_deleterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  ret i1 %.1

55:                                               ; preds = %24, %44, %48, %46, %26, %12
  %.pn32.pn.pn = phi { ptr, i32 } [ %13, %12 ], [ %25, %24 ], [ %27, %26 ], [ %45, %44 ], [ %49, %48 ], [ %47, %46 ]
  call void @_ZNSt10unique_ptrI12ggml_context20ggml_context_deleterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  resume { ptr, i32 } %.pn32.pn.pn
}

declare zeroext i1 @ggml_backend_buffer_copy_tensor(ptr noundef, ptr noundef) local_unnamed_addr #1

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

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 248}
!14 = !{!"_ZTS11ggml_tensor", !15, i64 0, !10, i64 8, !7, i64 16, !7, i64 48, !16, i64 80, !7, i64 84, !17, i64 148, !7, i64 152, !10, i64 232, !6, i64 240, !10, i64 248, !7, i64 256, !10, i64 320, !7, i64 328}
!15 = !{!"_ZTS9ggml_type", !7, i64 0}
!16 = !{!"_ZTS7ggml_op", !7, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!14, !10, i64 8}
!19 = !{!20, !7, i64 0}
!20 = !{!"_ZTS23rpc_msg_copy_tensor_rsp", !7, i64 0}


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