; LLVM IR from ggml-org/ggml :: tests (test-customop)

; 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"

@g_custom1_count = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [69 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 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: nounwind uwtable
define dso_local void @custom1(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %5
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 38, ptr noundef @.str.1, ptr noundef @.str.2) #4
  unreachable

23:                                               ; preds = %5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call zeroext i1 @ggml_are_same_shape(ptr noundef %24, ptr noundef %25)
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 39, ptr noundef @.str.1, ptr noundef @.str.3) #4
  unreachable

28:                                               ; preds = %23
  store i32 1, ptr %11, align 4, !tbaa !9
  %29 = load i32, ptr %11, align 4
  %30 = atomicrmw add ptr @g_custom1_count, i32 %29 seq_cst, align 4
  store i32 %30, ptr %12, align 4
  %31 = load i32, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call ptr @ggml_get_data_f32(ptr noundef %32)
  store ptr %33, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call ptr @ggml_get_data_f32(ptr noundef %34)
  store ptr %35, ptr %14, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call zeroext i1 @ggml_is_contiguous(ptr noundef %36)
  br i1 %37, label %39, label %38

38:                                               ; preds = %28
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 47, ptr noundef @.str.1, ptr noundef @.str.4) #4
  unreachable

39:                                               ; preds = %28
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call zeroext i1 @ggml_is_contiguous(ptr noundef %40)
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 48, ptr noundef @.str.1, ptr noundef @.str.5) #4
  unreachable

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = call i64 @ggml_nelements(ptr noundef %44)
  %46 = trunc i64 %45 to i32
  store i32 %46, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = add nsw i32 %47, %48
  %50 = sub nsw i32 %49, 1
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = sdiv i32 %50, %51
  store i32 %52, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %53 = load i32, ptr %16, align 4, !tbaa !9
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = mul nsw i32 %53, %54
  store i32 %55, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %56 = load i32, ptr %17, align 4, !tbaa !9
  %57 = load i32, ptr %16, align 4, !tbaa !9
  %58 = add nsw i32 %56, %57
  %59 = load i32, ptr %15, align 4, !tbaa !9
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %61, label %65

61:                                               ; preds = %43
  %62 = load i32, ptr %17, align 4, !tbaa !9
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = add nsw i32 %62, %63
  br label %67

65:                                               ; preds = %43
  %66 = load i32, ptr %15, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %65, %61
  %68 = phi i32 [ %64, %61 ], [ %66, %65 ]
  store i32 %68, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %69 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %69, ptr %19, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %86, %67
  %71 = load i32, ptr %19, align 4, !tbaa !9
  %72 = load i32, ptr %18, align 4, !tbaa !9
  %73 = icmp slt i32 %71, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %89

75:                                               ; preds = %70
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  %77 = load i32, ptr %19, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %76, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !11
  %81 = fmul float %80, 2.000000e+00
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load i32, ptr %19, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds float, ptr %82, i64 %84
  store float %81, ptr %85, align 4, !tbaa !11
  br label %86

86:                                               ; preds = %75
  %87 = load i32, ptr %19, align 4, !tbaa !9
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %19, align 4, !tbaa !9
  br label %70, !llvm.loop !13

89:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  ret void
}

; Function Attrs: noreturn
declare void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) #2

declare zeroext i1 @ggml_are_same_shape(ptr noundef, ptr noundef) #3

declare ptr @ggml_get_data_f32(ptr noundef) #3

declare zeroext i1 @ggml_is_contiguous(ptr noundef) #3

declare i64 @ggml_nelements(ptr noundef) #3

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 = { noreturn "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 = { "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 = { noreturn }
attributes #5 = { 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 = distinct !{!13, !14}
!14 = !{!"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"

@g_custom1_count = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [69 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @custom1(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef readnone %4) local_unnamed_addr #0 {
  %6 = icmp eq ptr %4, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %5
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 38, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2) #4
  unreachable

8:                                                ; preds = %5
  %9 = tail call zeroext i1 @ggml_are_same_shape(ptr noundef %0, ptr noundef %1) #5
  br i1 %9, label %11, label %10

10:                                               ; preds = %8
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 39, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.3) #4
  unreachable

11:                                               ; preds = %8
  %12 = atomicrmw add ptr @g_custom1_count, i32 1 seq_cst, align 4
  %13 = tail call ptr @ggml_get_data_f32(ptr noundef %1) #5
  %14 = ptrtoint ptr %13 to i64
  %15 = tail call ptr @ggml_get_data_f32(ptr noundef %0) #5
  %16 = ptrtoint ptr %15 to i64
  %17 = tail call zeroext i1 @ggml_is_contiguous(ptr noundef %0) #5
  br i1 %17, label %19, label %18

18:                                               ; preds = %11
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 47, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.4) #4
  unreachable

19:                                               ; preds = %11
  %20 = tail call zeroext i1 @ggml_is_contiguous(ptr noundef %1) #5
  br i1 %20, label %22, label %21

21:                                               ; preds = %19
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 48, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.5) #4
  unreachable

22:                                               ; preds = %19
  %23 = tail call i64 @ggml_nelements(ptr noundef %0) #5
  %24 = trunc i64 %23 to i32
  %25 = add i32 %3, -1
  %26 = add i32 %25, %24
  %27 = sdiv i32 %26, %3
  %28 = mul nsw i32 %27, %2
  %29 = add nsw i32 %28, %27
  %30 = tail call i32 @llvm.smin.i32(i32 %29, i32 %24)
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %22
  %32 = sext i32 %28 to i64
  %wide.trip.count = sext i32 %30 to i64
  %33 = sub nsw i64 %wide.trip.count, %32
  %min.iters.check = icmp ult i64 %33, 8
  %34 = sub i64 %16, %14
  %diff.check = icmp ult i64 %34, 32
  %or.cond = select i1 %min.iters.check, i1 true, i1 %diff.check
  br i1 %or.cond, label %.lr.ph.preheader31, label %vector.ph

.lr.ph.preheader31:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ %32, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %35 = sub nsw i64 %wide.trip.count, %indvars.iv.ph
  %xtraiter = and i64 %35, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader31, %.lr.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.lr.ph.prol ], [ %indvars.iv.ph, %.lr.ph.preheader31 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader31 ]
  %36 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.prol
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = fmul float %37, 2.000000e+00
  %39 = getelementptr inbounds float, ptr %15, i64 %indvars.iv.prol
  store float %38, ptr %39, align 4, !tbaa !5
  %indvars.iv.next.prol = add nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !9

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader31
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader31 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %40 = sub nsw i64 %indvars.iv.ph, %wide.trip.count
  %41 = icmp ugt i64 %40, -4
  br i1 %41, label %._crit_edge, label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %33, -8
  %ind.end = add nsw i64 %n.vec, %32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %index, %32
  %42 = getelementptr inbounds float, ptr %13, i64 %offset.idx
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  %wide.load = load <4 x float>, ptr %42, align 4, !tbaa !5
  %wide.load30 = load <4 x float>, ptr %43, align 4, !tbaa !5
  %44 = fmul <4 x float> %wide.load, <float 2.000000e+00, float 2.000000e+00, float 2.000000e+00, float 2.000000e+00>
  %45 = fmul <4 x float> %wide.load30, <float 2.000000e+00, float 2.000000e+00, float 2.000000e+00, float 2.000000e+00>
  %46 = getelementptr inbounds float, ptr %15, i64 %offset.idx
  %47 = getelementptr inbounds i8, ptr %46, i64 16
  store <4 x float> %44, ptr %46, align 4, !tbaa !5
  store <4 x float> %45, ptr %47, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %48 = icmp eq i64 %index.next, %n.vec
  br i1 %48, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %33, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader31

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %22
  ret void

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %49 = getelementptr inbounds float, ptr %13, i64 %indvars.iv
  %50 = load float, ptr %49, align 4, !tbaa !5
  %51 = fmul float %50, 2.000000e+00
  %52 = getelementptr inbounds float, ptr %15, i64 %indvars.iv
  store float %51, ptr %52, align 4, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %53 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.next
  %54 = load float, ptr %53, align 4, !tbaa !5
  %55 = fmul float %54, 2.000000e+00
  %56 = getelementptr inbounds float, ptr %15, i64 %indvars.iv.next
  store float %55, ptr %56, align 4, !tbaa !5
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %57 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.next.1
  %58 = load float, ptr %57, align 4, !tbaa !5
  %59 = fmul float %58, 2.000000e+00
  %60 = getelementptr inbounds float, ptr %15, i64 %indvars.iv.next.1
  store float %59, ptr %60, align 4, !tbaa !5
  %indvars.iv.next.2 = add nsw i64 %indvars.iv, 3
  %61 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.next.2
  %62 = load float, ptr %61, align 4, !tbaa !5
  %63 = fmul float %62, 2.000000e+00
  %64 = getelementptr inbounds float, ptr %15, i64 %indvars.iv.next.2
  store float %63, ptr %64, align 4, !tbaa !5
  %indvars.iv.next.3 = add nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !15
}

; Function Attrs: noreturn
declare void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

declare zeroext i1 @ggml_are_same_shape(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @ggml_get_data_f32(ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ggml_is_contiguous(ptr noundef) local_unnamed_addr #2

declare i64 @ggml_nelements(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3

attributes #0 = { 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 = { noreturn "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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !13}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass