; 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
declare hidden i64 @ggml_calc_pool_output_size(i64 noundef, i32 noundef, i32 noundef, float noundef) #1

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

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, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !10, i64 80}
!16 = !{!"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, !14, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}


; 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
declare hidden i64 @ggml_calc_pool_output_size(i64 noundef, i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1

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

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 = !{!"long", !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, !10, i64 80}
!12 = !{!"ggml_tensor", !10, i64 0, !13, i64 8, !7, i64 16, !7, i64 48, !10, i64 80, !7, i64 84, !10, i64 148, !7, i64 152, !13, i64 232, !6, i64 240, !13, i64 248, !7, i64 256, !13, i64 320, !7, i64 328}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!13, !13, i64 0}


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