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

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

@.str = external hidden unnamed_addr constant [68 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 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 @check_tensor(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 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 i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca float, align 4
  %16 = alloca float, 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 i32 %4, ptr %10, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ggml_tensor, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ggml_tensor, ptr %23, i32 0, i32 2
  %25 = getelementptr inbounds [4 x i64], ptr %24, i64 0, i64 0
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = icmp eq i64 %26, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %22
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 18, ptr noundef @.str.1, ptr noundef @.str.3) #4
  unreachable

31:                                               ; preds = %22
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ggml_tensor, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds [4 x i64], ptr %33, i64 0, i64 1
  %35 = load i64, ptr %34, align 8, !tbaa !14
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = icmp eq i64 %35, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %31
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ggml_tensor, ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds [4 x i64], ptr %42, i64 0, i64 2
  %44 = load i64, ptr %43, align 8, !tbaa !14
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = icmp eq i64 %44, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %114, %49
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %117

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %110, %55
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %113

61:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %106, %61
  %63 = load i32, ptr %14, align 4, !tbaa !9
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %109

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load i32, ptr %11, align 4, !tbaa !9
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = mul nsw i32 %69, %70
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = mul nsw i32 %71, %72
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds float, ptr %68, i64 %74
  %76 = load i32, ptr %13, align 4, !tbaa !9
  %77 = load i32, ptr %8, align 4, !tbaa !9
  %78 = mul nsw i32 %76, %77
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds float, ptr %75, i64 %79
  %81 = load i32, ptr %14, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds float, ptr %80, i64 %82
  %84 = load float, ptr %83, align 4, !tbaa !15
  store float %84, ptr %15, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = call ptr @ggml_get_data_f32(ptr noundef %85)
  %87 = load i32, ptr %11, align 4, !tbaa !9
  %88 = load i32, ptr %9, align 4, !tbaa !9
  %89 = mul nsw i32 %87, %88
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = mul nsw i32 %89, %90
  %92 = load i32, ptr %13, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = mul nsw i32 %92, %93
  %95 = add nsw i32 %91, %94
  %96 = load i32, ptr %14, align 4, !tbaa !9
  %97 = add nsw i32 %95, %96
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds float, ptr %86, i64 %98
  %100 = load float, ptr %99, align 4, !tbaa !15
  store float %100, ptr %16, align 4, !tbaa !15
  %101 = load float, ptr %15, align 4, !tbaa !15
  %102 = load float, ptr %16, align 4, !tbaa !15
  %103 = fcmp oeq float %101, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %67
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 26, ptr noundef @.str.1, ptr noundef @.str.6) #4
  unreachable

105:                                              ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %14, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %14, align 4, !tbaa !9
  br label %62, !llvm.loop !17

109:                                              ; preds = %66
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %13, align 4, !tbaa !9
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %13, align 4, !tbaa !9
  br label %56, !llvm.loop !19

113:                                              ; preds = %60
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %11, align 4, !tbaa !9
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %11, align 4, !tbaa !9
  br label %50, !llvm.loop !20

117:                                              ; preds = %54
  ret void
}

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

declare ptr @ggml_get_data_f32(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, !10, i64 0}
!12 = !{!"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, !13, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}


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

@.str = external hidden unnamed_addr constant [68 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @check_tensor(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %9, label %8

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

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !12
  %12 = sext i32 %2 to i64
  %13 = icmp eq i64 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 18, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.3) #3
  unreachable

15:                                               ; preds = %9
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = load i64, ptr %16, align 8, !tbaa !12
  %18 = sext i32 %3 to i64
  %19 = icmp eq i64 %17, %18
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %15
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load i64, ptr %22, align 8, !tbaa !12
  %24 = sext i32 %4 to i64
  %25 = icmp eq i64 %23, %24
  br i1 %25, label %.preheader36, label %44

.preheader36:                                     ; preds = %21
  %26 = icmp sgt i32 %4, 0
  br i1 %26, label %.preheader35.lr.ph, label %._crit_edge

.preheader35.lr.ph:                               ; preds = %.preheader36
  %factor.op.mul38 = mul i32 %3, %2
  %27 = icmp sgt i32 %3, 0
  %28 = icmp sgt i32 %2, 0
  %or.cond = and i1 %27, %28
  br i1 %or.cond, label %.preheader35.us.us.preheader, label %._crit_edge

.preheader35.us.us.preheader:                     ; preds = %.preheader35.lr.ph
  %wide.trip.count57 = zext nneg i32 %4 to i64
  %wide.trip.count52 = zext nneg i32 %3 to i64
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.preheader35.us.us

.preheader35.us.us:                               ; preds = %.preheader35.us.us.preheader, %._crit_edge40.split.us.us.us
  %indvars.iv54 = phi i64 [ 0, %.preheader35.us.us.preheader ], [ %indvars.iv.next55, %._crit_edge40.split.us.us.us ]
  %29 = trunc nuw nsw i64 %indvars.iv54 to i32
  %factor.op.mul.reass.us.us = mul i32 %factor.op.mul38, %29
  %30 = sext i32 %factor.op.mul.reass.us.us to i64
  %31 = getelementptr inbounds float, ptr %1, i64 %30
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader35.us.us
  %indvars.iv49 = phi i64 [ %indvars.iv.next50, %._crit_edge.us.us.us ], [ 0, %.preheader35.us.us ]
  %32 = mul nuw nsw i64 %indvars.iv49, %11
  %33 = getelementptr inbounds float, ptr %31, i64 %32
  br label %35

34:                                               ; preds = %35
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us.us.us, label %35, !llvm.loop !13

35:                                               ; preds = %34, %.preheader.us.us.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %34 ], [ 0, %.preheader.us.us.us ]
  %36 = getelementptr inbounds float, ptr %33, i64 %indvars.iv
  %37 = load float, ptr %36, align 4, !tbaa !15
  %38 = tail call ptr @ggml_get_data_f32(ptr noundef nonnull %0) #4
  %39 = getelementptr float, ptr %38, i64 %32
  %40 = getelementptr float, ptr %39, i64 %30
  %41 = getelementptr float, ptr %40, i64 %indvars.iv
  %42 = load float, ptr %41, align 4, !tbaa !15
  %43 = fcmp oeq float %37, %42
  br i1 %43, label %34, label %.split.us

._crit_edge.us.us.us:                             ; preds = %34
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond53.not = icmp eq i64 %indvars.iv.next50, %wide.trip.count52
  br i1 %exitcond53.not, label %._crit_edge40.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !17

._crit_edge40.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %exitcond58.not = icmp eq i64 %indvars.iv.next55, %wide.trip.count57
  br i1 %exitcond58.not, label %._crit_edge, label %.preheader35.us.us, !llvm.loop !18

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

._crit_edge:                                      ; preds = %._crit_edge40.split.us.us.us, %.preheader35.lr.ph, %.preheader36
  ret void

.split.us:                                        ; preds = %35
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 26, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.6) #3
  unreachable
}

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

declare ptr @ggml_get_data_f32(ptr noundef) local_unnamed_addr #2

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 = { noreturn nounwind }
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_tensor", !7, i64 0, !10, i64 8, !8, i64 16, !8, i64 48, !7, i64 80, !8, i64 84, !7, i64 148, !8, i64 152, !10, i64 232, !11, i64 240, !10, i64 248, !8, i64 256, !10, i64 320, !8, i64 328}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !8, i64 0}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass