; 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_custom_op_params = type { ptr, i32, ptr }
%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] }

@.str.12 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.153 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ggml_view_tensor(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ggml_custom_inplace(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca %struct.ggml_custom_op_params, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !9
  store ptr %6, ptr %14, align 8, !tbaa !5
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = icmp slt i32 %18, 9
  br i1 %19, label %21, label %20

20:                                               ; preds = %7
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 5033, ptr noundef @.str.13, ptr noundef @.str.153) #3
  unreachable

21:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = call ptr @ggml_view_tensor(ptr noundef %22, ptr noundef %23)
  store ptr %24, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #4
  %25 = getelementptr inbounds %struct.ggml_custom_op_params, ptr %16, i32 0, i32 0
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %26, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.ggml_custom_op_params, ptr %16, i32 0, i32 1
  %28 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %28, ptr %27, align 8, !tbaa !13
  %29 = getelementptr inbounds %struct.ggml_custom_op_params, ptr %16, i32 0, i32 2
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %30, ptr %29, align 8, !tbaa !14
  %31 = load ptr, ptr %15, align 8, !tbaa !5
  call void @ggml_set_op_params(ptr noundef %31, ptr noundef %16, i64 noundef 24)
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ggml_tensor, ptr %32, i32 0, i32 4
  store i32 78, ptr %33, align 8, !tbaa !15
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %15, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ggml_tensor, ptr %35, i32 0, i32 7
  %37 = getelementptr inbounds [10 x ptr], ptr %36, i64 0, i64 0
  store ptr %34, ptr %37, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %55, %21
  %39 = load i32, ptr %17, align 4, !tbaa !9
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %58

43:                                               ; preds = %38
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load i32, ptr %17, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds ptr, ptr %44, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load ptr, ptr %15, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ggml_tensor, ptr %49, i32 0, i32 7
  %51 = load i32, ptr %17, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [10 x ptr], ptr %50, i64 0, i64 %53
  store ptr %48, ptr %54, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %43
  %56 = load i32, ptr %17, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %17, align 4, !tbaa !9
  br label %38, !llvm.loop !18

58:                                               ; preds = %42
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  ret ptr %59
}

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { noreturn }
attributes #4 = { 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, !6, i64 0}
!12 = !{!"ggml_custom_op_params", !6, i64 0, !10, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !6, i64 16}
!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, !17, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!17 = !{!"long", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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_custom_op_params = type { ptr, i32, ptr }

@.str.12 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.153 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ggml_view_tensor(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @ggml_custom_inplace(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6) local_unnamed_addr #2 {
  %8 = alloca %struct.ggml_custom_op_params, align 8
  %9 = icmp slt i32 %3, 9
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 5033, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.153) #3
  unreachable

11:                                               ; preds = %7
  %12 = tail call ptr @ggml_view_tensor(ptr noundef %0, ptr noundef %1)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #4
  store ptr %4, ptr %8, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %5, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %6, ptr %14, align 8, !tbaa !12
  call void @ggml_set_op_params(ptr noundef %12, ptr noundef nonnull %8, i64 noundef 24)
  %15 = getelementptr inbounds i8, ptr %12, i64 80
  store i32 78, ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %12, i64 152
  store ptr %1, ptr %16, align 8, !tbaa !16
  %17 = icmp sgt i32 %3, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph.1, %.lr.ph.2, %.lr.ph.3, %.lr.ph.4, %.lr.ph.5, %.lr.ph.6, %.lr.ph.7, %11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #4
  ret ptr %12

.lr.ph:                                           ; preds = %11
  %18 = load ptr, ptr %2, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %12, i64 160
  store ptr %18, ptr %19, align 8, !tbaa !16
  %exitcond.not = icmp eq i32 %3, 1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.1, !llvm.loop !17

.lr.ph.1:                                         ; preds = %.lr.ph
  %20 = getelementptr inbounds i8, ptr %2, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %12, i64 168
  store ptr %21, ptr %22, align 8, !tbaa !16
  %exitcond.not.1 = icmp eq i32 %3, 2
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph.2, !llvm.loop !17

.lr.ph.2:                                         ; preds = %.lr.ph.1
  %23 = getelementptr inbounds i8, ptr %2, i64 16
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %12, i64 176
  store ptr %24, ptr %25, align 8, !tbaa !16
  %exitcond.not.2 = icmp eq i32 %3, 3
  br i1 %exitcond.not.2, label %._crit_edge, label %.lr.ph.3, !llvm.loop !17

.lr.ph.3:                                         ; preds = %.lr.ph.2
  %26 = getelementptr inbounds i8, ptr %2, i64 24
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %12, i64 184
  store ptr %27, ptr %28, align 8, !tbaa !16
  %exitcond.not.3 = icmp eq i32 %3, 4
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph.4, !llvm.loop !17

.lr.ph.4:                                         ; preds = %.lr.ph.3
  %29 = getelementptr inbounds i8, ptr %2, i64 32
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %12, i64 192
  store ptr %30, ptr %31, align 8, !tbaa !16
  %exitcond.not.4 = icmp eq i32 %3, 5
  br i1 %exitcond.not.4, label %._crit_edge, label %.lr.ph.5, !llvm.loop !17

.lr.ph.5:                                         ; preds = %.lr.ph.4
  %32 = getelementptr inbounds i8, ptr %2, i64 40
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %12, i64 200
  store ptr %33, ptr %34, align 8, !tbaa !16
  %exitcond.not.5 = icmp eq i32 %3, 6
  br i1 %exitcond.not.5, label %._crit_edge, label %.lr.ph.6, !llvm.loop !17

.lr.ph.6:                                         ; preds = %.lr.ph.5
  %35 = getelementptr inbounds i8, ptr %2, i64 48
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %12, i64 208
  store ptr %36, ptr %37, align 8, !tbaa !16
  %exitcond.not.6 = icmp eq i32 %3, 7
  br i1 %exitcond.not.6, label %._crit_edge, label %.lr.ph.7, !llvm.loop !17

.lr.ph.7:                                         ; preds = %.lr.ph.6
  %38 = getelementptr inbounds i8, ptr %2, i64 56
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %12, i64 216
  store ptr %39, ptr %40, align 8, !tbaa !16
  br label %._crit_edge
}

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { noreturn }
attributes #4 = { 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, !7, i64 0}
!6 = !{!"ggml_custom_op_params", !7, i64 0, !10, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 16}
!13 = !{!14, !10, i64 80}
!14 = !{!"ggml_tensor", !10, i64 0, !7, i64 8, !8, i64 16, !8, i64 48, !10, i64 80, !8, i64 84, !10, i64 148, !8, i64 152, !7, i64 232, !15, i64 240, !7, i64 248, !8, i64 256, !7, i64 320, !8, i64 328}
!15 = !{!"long", !8, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass