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

; 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_hash_set = type { i64, ptr, ptr }
%struct.ggml_backend_graph_copy = type { ptr, ptr, ptr, ptr }
%struct.ggml_init_params = type { i64, ptr, i8 }
%struct.ggml_cgraph = type { i32, i32, i32, ptr, ptr, ptr, ptr, %struct.ggml_hash_set, i32 }

@.str.38 = external hidden unnamed_addr constant [47 x i8], align 1
@__func__.ggml_backend_graph_copy = external hidden unnamed_addr constant [24 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [46 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

; 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 void @ggml_log_internal(i32 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

declare void @ggml_hash_set_new(ptr dead_on_unwind writable sret(%struct.ggml_hash_set) align 8, i64 noundef) #2

declare i64 @ggml_graph_overhead_custom(i64 noundef, i1 noundef zeroext) #2

declare void @ggml_free(ptr noundef) #2

declare void @ggml_hash_set_free(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @ggml_backend_graph_copy(ptr dead_on_unwind noalias writable sret(%struct.ggml_backend_graph_copy) align 8 %0, ptr noundef %1, ptr noundef %2) #5 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.ggml_hash_set, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.ggml_init_params, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.ggml_init_params, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.ggml_init_params, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca %struct.ggml_hash_set, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #7
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ggml_cgraph, ptr %25, i32 0, i32 7
  %27 = getelementptr inbounds %struct.ggml_hash_set, ptr %26, i32 0, i32 0
  %28 = load i64, ptr %27, align 8, !tbaa !9
  call void @ggml_hash_set_new(ptr dead_on_unwind writable sret(%struct.ggml_hash_set) align 8 %6, i64 noundef %28)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %29 = getelementptr inbounds %struct.ggml_hash_set, ptr %6, i32 0, i32 0
  %30 = load i64, ptr %29, align 8, !tbaa !15
  %31 = call noalias ptr @calloc(i64 noundef %30, i64 noundef 8) #8
  store ptr %31, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %32 = getelementptr inbounds %struct.ggml_hash_set, ptr %6, i32 0, i32 0
  %33 = load i64, ptr %32, align 8, !tbaa !15
  %34 = call noalias ptr @calloc(i64 noundef %33, i64 noundef 1) #8
  store ptr %34, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #7
  %35 = getelementptr inbounds %struct.ggml_init_params, ptr %9, i32 0, i32 0
  %36 = call i64 @ggml_tensor_overhead()
  %37 = getelementptr inbounds %struct.ggml_hash_set, ptr %6, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !15
  %39 = mul i64 %36, %38
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ggml_cgraph, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !16
  %43 = sext i32 %42 to i64
  %44 = call i64 @ggml_graph_overhead_custom(i64 noundef %43, i1 noundef zeroext false)
  %45 = add i64 %39, %44
  store i64 %45, ptr %35, align 8, !tbaa !17
  %46 = getelementptr inbounds %struct.ggml_init_params, ptr %9, i32 0, i32 1
  store ptr null, ptr %46, align 8, !tbaa !20
  %47 = getelementptr inbounds %struct.ggml_init_params, ptr %9, i32 0, i32 2
  store i8 1, ptr %47, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %9, i64 24, i1 false), !tbaa.struct !22
  %48 = call ptr @ggml_init(ptr noundef byval(%struct.ggml_init_params) align 8 %11)
  store ptr %48, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %9, i64 24, i1 false), !tbaa.struct !22
  %49 = call ptr @ggml_init(ptr noundef byval(%struct.ggml_init_params) align 8 %13)
  store ptr %49, ptr %12, align 8, !tbaa !5
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %55, label %52

52:                                               ; preds = %3
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %64

55:                                               ; preds = %52, %3
  call void (i32, ptr, ...) @ggml_log_internal(i32 noundef 4, ptr noundef @.str.38, ptr noundef @__func__.ggml_backend_graph_copy)
  call void @ggml_hash_set_free(ptr noundef %6)
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %56) #7
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %57) #7
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ggml_free(ptr noundef %58)
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ggml_free(ptr noundef %59)
  %60 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 0
  store ptr null, ptr %60, align 8, !tbaa !25
  %61 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 1
  store ptr null, ptr %61, align 8, !tbaa !27
  %62 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 2
  store ptr null, ptr %62, align 8, !tbaa !28
  %63 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 3
  store ptr null, ptr %63, align 8, !tbaa !29
  store i32 1, ptr %14, align 4
  br label %179

64:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !30
  br label %65

65:                                               ; preds = %85, %64
  %66 = load i32, ptr %15, align 4, !tbaa !30
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ggml_cgraph, ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !31
  %70 = icmp slt i32 %66, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %65
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %88

72:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ggml_cgraph, ptr %73, i32 0, i32 3
  %75 = load ptr, ptr %74, align 8, !tbaa !32
  %76 = load i32, ptr %15, align 4, !tbaa !30
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds ptr, ptr %75, i64 %77
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  store ptr %79, ptr %16, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 8 %6, i64 24, i1 false), !tbaa.struct !33
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = load ptr, ptr %16, align 8, !tbaa !5
  %84 = call noundef ptr @_ZL21graph_copy_dup_tensor13ggml_hash_setPP11ggml_tensorP12ggml_contextS4_S1_(ptr noundef byval(%struct.ggml_hash_set) align 8 %17, ptr noundef %80, ptr noundef %81, ptr noundef %82, ptr noundef %83)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %85

85:                                               ; preds = %72
  %86 = load i32, ptr %15, align 4, !tbaa !30
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %15, align 4, !tbaa !30
  br label %65, !llvm.loop !34

88:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = call ptr @ggml_backend_alloc_ctx_tensors(ptr noundef %89, ptr noundef %90)
  store ptr %91, ptr %18, align 8, !tbaa !5
  %92 = load ptr, ptr %18, align 8, !tbaa !5
  %93 = icmp eq ptr %92, null
  br i1 %93, label %94, label %103

94:                                               ; preds = %88
  call void (i32, ptr, ...) @ggml_log_internal(i32 noundef 4, ptr noundef @.str.39, ptr noundef @__func__.ggml_backend_graph_copy)
  call void @ggml_hash_set_free(ptr noundef %6)
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %95) #7
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %96) #7
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ggml_free(ptr noundef %97)
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ggml_free(ptr noundef %98)
  %99 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 0
  store ptr null, ptr %99, align 8, !tbaa !25
  %100 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 1
  store ptr null, ptr %100, align 8, !tbaa !27
  %101 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 2
  store ptr null, ptr %101, align 8, !tbaa !28
  %102 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 3
  store ptr null, ptr %102, align 8, !tbaa !29
  store i32 1, ptr %14, align 4
  br label %178

103:                                              ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 0, ptr %19, align 4, !tbaa !30
  br label %104

104:                                              ; preds = %122, %103
  %105 = load i32, ptr %19, align 4, !tbaa !30
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.ggml_cgraph, ptr %106, i32 0, i32 1
  %108 = load i32, ptr %107, align 4, !tbaa !31
  %109 = icmp slt i32 %105, %108
  br i1 %109, label %111, label %110

110:                                              ; preds = %104
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %125

111:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.ggml_cgraph, ptr %112, i32 0, i32 3
  %114 = load ptr, ptr %113, align 8, !tbaa !32
  %115 = load i32, ptr %19, align 4, !tbaa !30
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds ptr, ptr %114, i64 %116
  %118 = load ptr, ptr %117, align 8, !tbaa !5
  store ptr %118, ptr %20, align 8, !tbaa !5
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = load ptr, ptr %20, align 8, !tbaa !5
  call void @_ZL22graph_copy_init_tensorP13ggml_hash_setPP11ggml_tensorPbS2_(ptr noundef %6, ptr noundef %119, ptr noundef %120, ptr noundef %121)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  br label %122

122:                                              ; preds = %111
  %123 = load i32, ptr %19, align 4, !tbaa !30
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %19, align 4, !tbaa !30
  br label %104, !llvm.loop !36

125:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %126 = load ptr, ptr %10, align 8, !tbaa !5
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.ggml_cgraph, ptr %127, i32 0, i32 0
  %129 = load i32, ptr %128, align 8, !tbaa !16
  %130 = sext i32 %129 to i64
  %131 = call ptr @ggml_new_graph_custom(ptr noundef %126, i64 noundef %130, i1 noundef zeroext false)
  store ptr %131, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 0, ptr %22, align 4, !tbaa !30
  br label %132

132:                                              ; preds = %159, %125
  %133 = load i32, ptr %22, align 4, !tbaa !30
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.ggml_cgraph, ptr %134, i32 0, i32 1
  %136 = load i32, ptr %135, align 4, !tbaa !31
  %137 = icmp slt i32 %133, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %132
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %162

139:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %140 = load ptr, ptr %5, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.ggml_cgraph, ptr %140, i32 0, i32 3
  %142 = load ptr, ptr %141, align 8, !tbaa !32
  %143 = load i32, ptr %22, align 4, !tbaa !30
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds ptr, ptr %142, i64 %144
  %146 = load ptr, ptr %145, align 8, !tbaa !5
  store ptr %146, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  %147 = load ptr, ptr %7, align 8, !tbaa !5
  %148 = load ptr, ptr %23, align 8, !tbaa !5
  %149 = call noundef i64 @_ZL14ggml_hash_findPK13ggml_hash_setPK11ggml_tensor(ptr noundef %6, ptr noundef %148)
  %150 = getelementptr inbounds ptr, ptr %147, i64 %149
  %151 = load ptr, ptr %150, align 8, !tbaa !5
  store ptr %151, ptr %24, align 8, !tbaa !5
  %152 = load ptr, ptr %24, align 8, !tbaa !5
  %153 = load ptr, ptr %21, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.ggml_cgraph, ptr %153, i32 0, i32 3
  %155 = load ptr, ptr %154, align 8, !tbaa !32
  %156 = load i32, ptr %22, align 4, !tbaa !30
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds ptr, ptr %155, i64 %157
  store ptr %152, ptr %158, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  br label %159

159:                                              ; preds = %139
  %160 = load i32, ptr %22, align 4, !tbaa !30
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %22, align 4, !tbaa !30
  br label %132, !llvm.loop !37

162:                                              ; preds = %138
  %163 = load ptr, ptr %5, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.ggml_cgraph, ptr %163, i32 0, i32 1
  %165 = load i32, ptr %164, align 4, !tbaa !31
  %166 = load ptr, ptr %21, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.ggml_cgraph, ptr %166, i32 0, i32 1
  store i32 %165, ptr %167, align 4, !tbaa !31
  call void @ggml_hash_set_free(ptr noundef %6)
  %168 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %168) #7
  %169 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %169) #7
  %170 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 0
  %171 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %171, ptr %170, align 8, !tbaa !25
  %172 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 1
  %173 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %173, ptr %172, align 8, !tbaa !27
  %174 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 2
  %175 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %175, ptr %174, align 8, !tbaa !28
  %176 = getelementptr inbounds %struct.ggml_backend_graph_copy, ptr %0, i32 0, i32 3
  %177 = load ptr, ptr %21, align 8, !tbaa !5
  store ptr %177, ptr %176, align 8, !tbaa !29
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %178

178:                                              ; preds = %162, %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %179

179:                                              ; preds = %178, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #7
  ret void
}

declare i64 @ggml_tensor_overhead() #2

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL21graph_copy_dup_tensor13ggml_hash_setPP11ggml_tensorP12ggml_contextS4_S1_(ptr noundef byval(%struct.ggml_hash_set) align 8, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

declare ptr @ggml_backend_alloc_ctx_tensors(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL22graph_copy_init_tensorP13ggml_hash_setPP11ggml_tensorPbS2_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

declare ptr @ggml_new_graph_custom(ptr noundef, i64 noundef, i1 noundef zeroext) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL14ggml_hash_findPK13ggml_hash_setPK11ggml_tensor(ptr noundef, ptr noundef) #6

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 = { nounwind "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 allocsize(0,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 #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 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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, !13, i64 48}
!10 = !{!"_ZTS11ggml_cgraph", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !14, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS13ggml_hash_set", !13, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTS22ggml_cgraph_eval_order", !7, i64 0}
!15 = !{!12, !13, i64 0}
!16 = !{!10, !11, i64 0}
!17 = !{!18, !13, i64 0}
!18 = !{!"_ZTS16ggml_init_params", !13, i64 0, !6, i64 8, !19, i64 16}
!19 = !{!"bool", !7, i64 0}
!20 = !{!18, !6, i64 8}
!21 = !{!18, !19, i64 16}
!22 = !{i64 0, i64 8, !23, i64 8, i64 8, !5, i64 16, i64 1, !24}
!23 = !{!13, !13, i64 0}
!24 = !{!19, !19, i64 0}
!25 = !{!26, !6, i64 0}
!26 = !{!"_ZTS23ggml_backend_graph_copy", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!27 = !{!26, !6, i64 8}
!28 = !{!26, !6, i64 16}
!29 = !{!26, !6, i64 24}
!30 = !{!11, !11, i64 0}
!31 = !{!10, !11, i64 4}
!32 = !{!10, !6, i64 16}
!33 = !{i64 0, i64 8, !23, i64 8, i64 8, !5, i64 16, i64 8, !5}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = distinct !{!36, !35}
!37 = distinct !{!37, !35}


; 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_hash_set = type { i64, ptr, ptr }
%struct.ggml_backend_graph_copy = type { ptr, ptr, ptr, ptr }
%struct.ggml_init_params = type { i64, ptr, i8 }

@.str.38 = external hidden unnamed_addr constant [47 x i8], align 1
@__func__.ggml_backend_graph_copy = external hidden unnamed_addr constant [24 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [46 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

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

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

declare void @ggml_hash_set_new(ptr dead_on_unwind writable sret(%struct.ggml_hash_set) align 8, i64 noundef) local_unnamed_addr #1

declare i64 @ggml_graph_overhead_custom(i64 noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @ggml_free(ptr noundef) local_unnamed_addr #1

declare void @ggml_hash_set_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @ggml_backend_graph_copy(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.ggml_backend_graph_copy) align 8 %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #4 {
  %4 = alloca %struct.ggml_hash_set, align 8
  %5 = alloca %struct.ggml_init_params, align 8
  %6 = alloca %struct.ggml_init_params, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #7
  %7 = getelementptr inbounds i8, ptr %2, i64 48
  %8 = load i64, ptr %7, align 8, !tbaa !5
  call void @ggml_hash_set_new(ptr dead_on_unwind nonnull writable sret(%struct.ggml_hash_set) align 8 %4, i64 noundef %8)
  %9 = load i64, ptr %4, align 8, !tbaa !14
  %10 = call noalias ptr @calloc(i64 noundef %9, i64 noundef 8) #8
  %11 = call noalias ptr @calloc(i64 noundef %9, i64 noundef 1) #8
  %12 = call i64 @ggml_tensor_overhead()
  %13 = load i64, ptr %4, align 8, !tbaa !14
  %14 = mul i64 %13, %12
  %15 = load i32, ptr %2, align 8, !tbaa !15
  %16 = sext i32 %15 to i64
  %17 = call i64 @ggml_graph_overhead_custom(i64 noundef %16, i1 noundef zeroext false)
  %18 = add i64 %17, %14
  store i64 %18, ptr %5, align 8, !tbaa !16
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store ptr null, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !17
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 16
  store i8 1, ptr %.sroa.6.0..sroa_idx, align 8, !tbaa !18
  %19 = call ptr @ggml_init(ptr noundef nonnull byval(%struct.ggml_init_params) align 8 %5)
  store i64 %18, ptr %6, align 8, !tbaa !16
  %.sroa.5.0..sroa_idx32 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr null, ptr %.sroa.5.0..sroa_idx32, align 8, !tbaa !17
  %.sroa.6.0..sroa_idx34 = getelementptr inbounds i8, ptr %6, i64 16
  store i8 1, ptr %.sroa.6.0..sroa_idx34, align 8, !tbaa !18
  %20 = call ptr @ggml_init(ptr noundef nonnull byval(%struct.ggml_init_params) align 8 %6)
  %21 = icmp eq ptr %19, null
  %22 = icmp eq ptr %20, null
  %or.cond = select i1 %21, i1 true, i1 %22
  br i1 %or.cond, label %27, label %.preheader64

.preheader64:                                     ; preds = %3
  %23 = getelementptr inbounds i8, ptr %2, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !20
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader64
  %26 = getelementptr inbounds i8, ptr %2, i64 16
  br label %33

27:                                               ; preds = %3
  call void (i32, ptr, ...) @ggml_log_internal(i32 noundef 4, ptr noundef nonnull @.str.38, ptr noundef nonnull @__func__.ggml_backend_graph_copy)
  call void @ggml_hash_set_free(ptr noundef nonnull %4)
  call void @free(ptr noundef %10) #7
  call void @free(ptr noundef %11) #7
  call void @ggml_free(ptr noundef %19)
  call void @ggml_free(ptr noundef %20)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 0, i64 32, i1 false)
  br label %72

._crit_edge:                                      ; preds = %33, %.preheader64
  %28 = call ptr @ggml_backend_alloc_ctx_tensors(ptr noundef %19, ptr noundef %1)
  %29 = icmp eq ptr %28, null
  br i1 %29, label %41, label %.preheader

.preheader:                                       ; preds = %._crit_edge
  %30 = load i32, ptr %23, align 4, !tbaa !20
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph68, label %._crit_edge69

.lr.ph68:                                         ; preds = %.preheader
  %32 = getelementptr inbounds i8, ptr %2, i64 16
  br label %49

33:                                               ; preds = %.lr.ph, %33
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %33 ]
  %34 = load ptr, ptr %26, align 8, !tbaa !21
  %35 = getelementptr inbounds ptr, ptr %34, i64 %indvars.iv
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = call noundef ptr @_ZL21graph_copy_dup_tensor13ggml_hash_setPP11ggml_tensorP12ggml_contextS4_S1_(ptr noundef nonnull byval(%struct.ggml_hash_set) align 8 %4, ptr noundef %10, ptr noundef %19, ptr noundef %20, ptr noundef %36)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = load i32, ptr %23, align 4, !tbaa !20
  %39 = sext i32 %38 to i64
  %40 = icmp slt i64 %indvars.iv.next, %39
  br i1 %40, label %33, label %._crit_edge, !llvm.loop !22

41:                                               ; preds = %._crit_edge
  call void (i32, ptr, ...) @ggml_log_internal(i32 noundef 4, ptr noundef nonnull @.str.39, ptr noundef nonnull @__func__.ggml_backend_graph_copy)
  call void @ggml_hash_set_free(ptr noundef nonnull %4)
  call void @free(ptr noundef %10) #7
  call void @free(ptr noundef %11) #7
  call void @ggml_free(ptr noundef %19)
  call void @ggml_free(ptr noundef %20)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 0, i64 32, i1 false)
  br label %72

._crit_edge69:                                    ; preds = %49, %.preheader
  %42 = load i32, ptr %2, align 8, !tbaa !15
  %43 = sext i32 %42 to i64
  %44 = call ptr @ggml_new_graph_custom(ptr noundef %19, i64 noundef %43, i1 noundef zeroext false)
  %45 = load i32, ptr %23, align 4, !tbaa !20
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %.lr.ph72, label %._crit_edge73

.lr.ph72:                                         ; preds = %._crit_edge69
  %47 = getelementptr inbounds i8, ptr %2, i64 16
  %48 = getelementptr inbounds i8, ptr %44, i64 16
  br label %60

49:                                               ; preds = %.lr.ph68, %49
  %indvars.iv76 = phi i64 [ 0, %.lr.ph68 ], [ %indvars.iv.next77, %49 ]
  %50 = load ptr, ptr %32, align 8, !tbaa !21
  %51 = getelementptr inbounds ptr, ptr %50, i64 %indvars.iv76
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  call void @_ZL22graph_copy_init_tensorP13ggml_hash_setPP11ggml_tensorPbS2_(ptr noundef nonnull %4, ptr noundef %10, ptr noundef %11, ptr noundef %52)
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %53 = load i32, ptr %23, align 4, !tbaa !20
  %54 = sext i32 %53 to i64
  %55 = icmp slt i64 %indvars.iv.next77, %54
  br i1 %55, label %49, label %._crit_edge69, !llvm.loop !24

._crit_edge73:                                    ; preds = %60, %._crit_edge69
  %.lcssa = phi i32 [ %45, %._crit_edge69 ], [ %69, %60 ]
  %56 = getelementptr inbounds i8, ptr %44, i64 4
  store i32 %.lcssa, ptr %56, align 4, !tbaa !20
  call void @ggml_hash_set_free(ptr noundef nonnull %4)
  call void @free(ptr noundef %10) #7
  call void @free(ptr noundef %11) #7
  store ptr %28, ptr %0, align 8, !tbaa !25
  %57 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %19, ptr %57, align 8, !tbaa !27
  %58 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %20, ptr %58, align 8, !tbaa !28
  %59 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %44, ptr %59, align 8, !tbaa !29
  br label %72

60:                                               ; preds = %.lr.ph72, %60
  %indvars.iv79 = phi i64 [ 0, %.lr.ph72 ], [ %indvars.iv.next80, %60 ]
  %61 = load ptr, ptr %47, align 8, !tbaa !21
  %62 = getelementptr inbounds ptr, ptr %61, i64 %indvars.iv79
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  %64 = call noundef i64 @_ZL14ggml_hash_findPK13ggml_hash_setPK11ggml_tensor(ptr noundef nonnull %4, ptr noundef %63)
  %65 = getelementptr inbounds ptr, ptr %10, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = load ptr, ptr %48, align 8, !tbaa !21
  %68 = getelementptr inbounds ptr, ptr %67, i64 %indvars.iv79
  store ptr %66, ptr %68, align 8, !tbaa !17
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %69 = load i32, ptr %23, align 4, !tbaa !20
  %70 = sext i32 %69 to i64
  %71 = icmp slt i64 %indvars.iv.next80, %70
  br i1 %71, label %60, label %._crit_edge73, !llvm.loop !30

72:                                               ; preds = %41, %._crit_edge73, %27
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #7
  ret void
}

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 uwtable
declare hidden noundef ptr @_ZL21graph_copy_dup_tensor13ggml_hash_setPP11ggml_tensorP12ggml_contextS4_S1_(ptr noundef byval(%struct.ggml_hash_set) align 8, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare ptr @ggml_backend_alloc_ctx_tensors(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL22graph_copy_init_tensorP13ggml_hash_setPP11ggml_tensorPbS2_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL14ggml_hash_findPK13ggml_hash_setPK11ggml_tensor(ptr noundef, ptr noundef) local_unnamed_addr #5

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

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 willreturn allockind("free") memory(argmem: readwrite, 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 #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 = { 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 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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, !12, i64 48}
!6 = !{!"_ZTS11ggml_cgraph", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !11, i64 48, !13, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS13ggml_hash_set", !12, i64 0, !10, i64 8, !10, i64 16}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_ZTS22ggml_cgraph_eval_order", !8, i64 0}
!14 = !{!11, !12, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"bool", !8, i64 0}
!20 = !{!6, !7, i64 4}
!21 = !{!6, !10, i64 16}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = !{!26, !10, i64 0}
!26 = !{!"_ZTS23ggml_backend_graph_copy", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!27 = !{!26, !10, i64 8}
!28 = !{!26, !10, i64 16}
!29 = !{!26, !10, i64 24}
!30 = distinct !{!30, !23}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass