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

; Function Attrs: nounwind uwtable
declare hidden i64 @ggml_calc_pool_output_size(i64 noundef, i32 noundef, i32 noundef, float noundef) #1

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 = !{!"long", !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, !12, 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
define dso_local noundef ptr @ggml_pool_1d(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = alloca [4 x i64], align 16
  %8 = alloca [4 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #2
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = sitofp i32 %5 to float
  %12 = tail call i64 @ggml_calc_pool_output_size(i64 noundef %10, i32 noundef %3, i32 noundef %4, float noundef %11)
  store i64 %12, ptr %7, align 16, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %7, i64 8
  %14 = getelementptr inbounds i8, ptr %1, i64 24
  %15 = load <2 x i64>, ptr %14, align 8, !tbaa !5
  store <2 x i64> %15, ptr %13, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %7, i64 24
  %17 = getelementptr inbounds i8, ptr %1, i64 40
  %18 = load i64, ptr %17, align 8, !tbaa !5
  store i64 %18, ptr %16, align 8, !tbaa !5
  %19 = call ptr @ggml_new_tensor(ptr noundef %0, i32 noundef 0, i32 noundef 4, ptr noundef nonnull %7)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #2
  store i32 %2, ptr %8, align 16, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %3, ptr %20, align 4, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %4, ptr %21, align 8, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %8, i64 12
  store i32 %5, ptr %22, align 4, !tbaa !9
  call void @ggml_set_op_params(ptr noundef %19, ptr noundef nonnull %8, i64 noundef 16)
  %23 = getelementptr inbounds i8, ptr %19, i64 80
  store i32 53, ptr %23, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %19, i64 152
  store ptr %1, ptr %24, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #2
  ret ptr %19
}

; Function Attrs: nounwind uwtable
declare hidden i64 @ggml_calc_pool_output_size(i64 noundef, i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1

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