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

; 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_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] }

; 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 uwtable
declare dso_local ptr @ggml_new_tensor(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @ggml_set_op_params(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @ggml_pool_2d_back(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, float noundef %8, float noundef %9) #1 {
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca ptr, align 8
  %22 = alloca [7 x i32], align 16
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store i32 %3, ptr %14, align 4, !tbaa !9
  store i32 %4, ptr %15, align 4, !tbaa !9
  store i32 %5, ptr %16, align 4, !tbaa !9
  store i32 %6, ptr %17, align 4, !tbaa !9
  store i32 %7, ptr %18, align 4, !tbaa !9
  store float %8, ptr %19, align 4, !tbaa !11
  store float %9, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #2
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = load ptr, ptr %13, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ggml_tensor, ptr %24, i32 0, i32 2
  %26 = getelementptr inbounds [4 x i64], ptr %25, i64 0, i64 0
  %27 = call ptr @ggml_new_tensor(ptr noundef %23, i32 noundef 0, i32 noundef 4, ptr noundef %26)
  store ptr %27, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 28, ptr %22) #2
  %28 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %28, ptr %22, align 4, !tbaa !9
  %29 = getelementptr inbounds i32, ptr %22, i64 1
  %30 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %30, ptr %29, align 4, !tbaa !9
  %31 = getelementptr inbounds i32, ptr %22, i64 2
  %32 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %32, ptr %31, align 4, !tbaa !9
  %33 = getelementptr inbounds i32, ptr %22, i64 3
  %34 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %34, ptr %33, align 4, !tbaa !9
  %35 = getelementptr inbounds i32, ptr %22, i64 4
  %36 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %36, ptr %35, align 4, !tbaa !9
  %37 = getelementptr inbounds i32, ptr %22, i64 5
  %38 = load float, ptr %19, align 4, !tbaa !11
  %39 = fptosi float %38 to i32
  store i32 %39, ptr %37, align 4, !tbaa !9
  %40 = getelementptr inbounds i32, ptr %22, i64 6
  %41 = load float, ptr %20, align 4, !tbaa !11
  %42 = fptosi float %41 to i32
  store i32 %42, ptr %40, align 4, !tbaa !9
  %43 = load ptr, ptr %21, align 8, !tbaa !5
  %44 = getelementptr inbounds [7 x i32], ptr %22, i64 0, i64 0
  call void @ggml_set_op_params(ptr noundef %43, ptr noundef %44, i64 noundef 28)
  %45 = load ptr, ptr %21, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ggml_tensor, ptr %45, i32 0, i32 4
  store i32 55, ptr %46, align 8, !tbaa !13
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = load ptr, ptr %21, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ggml_tensor, ptr %48, i32 0, i32 7
  %50 = getelementptr inbounds [10 x ptr], ptr %49, i64 0, i64 0
  store ptr %47, ptr %50, align 8, !tbaa !5
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  %52 = load ptr, ptr %21, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ggml_tensor, ptr %52, i32 0, i32 7
  %54 = getelementptr inbounds [10 x ptr], ptr %53, i64 0, i64 1
  store ptr %51, ptr %54, align 8, !tbaa !5
  %55 = load ptr, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 28, ptr %22) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #2
  ret ptr %55
}

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 80}
!14 = !{!"ggml_tensor", !10, i64 0, !6, i64 8, !7, i64 16, !7, i64 48, !10, i64 80, !7, i64 84, !10, i64 148, !7, i64 152, !6, i64 232, !15, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!15 = !{!"long", !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"

; 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: nounwind uwtable
declare dso_local ptr @ggml_new_tensor(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @ggml_set_op_params(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @ggml_pool_2d_back(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, float noundef %8, float noundef %9) local_unnamed_addr #1 {
  %11 = alloca [7 x i32], align 16
  %12 = getelementptr inbounds i8, ptr %2, i64 16
  %13 = tail call ptr @ggml_new_tensor(ptr noundef %0, i32 noundef 0, i32 noundef 4, ptr noundef nonnull %12)
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %11) #2
  store i32 %3, ptr %11, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %4, ptr %14, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 %5, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %11, i64 12
  store i32 %6, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %11, i64 16
  store i32 %7, ptr %17, align 16, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %11, i64 20
  %19 = insertelement <2 x float> poison, float %8, i64 0
  %20 = insertelement <2 x float> %19, float %9, i64 1
  %21 = fptosi <2 x float> %20 to <2 x i32>
  store <2 x i32> %21, ptr %18, align 4, !tbaa !5
  call void @ggml_set_op_params(ptr noundef %13, ptr noundef nonnull %11, i64 noundef 28)
  %22 = getelementptr inbounds i8, ptr %13, i64 80
  store i32 55, ptr %22, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %13, i64 152
  store ptr %1, ptr %23, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %13, i64 160
  store ptr %2, ptr %24, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %11) #2
  ret ptr %13
}

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 80}
!10 = !{!"ggml_tensor", !6, i64 0, !11, i64 8, !7, i64 16, !7, i64 48, !6, i64 80, !7, i64 84, !6, i64 148, !7, i64 152, !11, i64 232, !12, i64 240, !11, i64 248, !7, i64 256, !11, i64 320, !7, i64 328}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass