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

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

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

21:                                               ; preds = %3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ggml_tensor, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !13
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %21
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 4573, ptr noundef @.str.13, ptr noundef @.str.95) #3
  unreachable

27:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ggml_tensor, ptr %30, i32 0, i32 2
  %32 = getelementptr inbounds [4 x i64], ptr %31, i64 0, i64 1
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = srem i64 %33, %35
  %37 = sub nsw i64 %29, %36
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = srem i64 %37, %39
  %41 = trunc i64 %40 to i32
  store i32 %41, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ggml_tensor, ptr %44, i32 0, i32 2
  %46 = getelementptr inbounds [4 x i64], ptr %45, i64 0, i64 2
  %47 = load i64, ptr %46, align 8, !tbaa !11
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = srem i64 %47, %49
  %51 = sub nsw i64 %43, %50
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = srem i64 %51, %53
  %55 = trunc i64 %54 to i32
  store i32 %55, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ggml_tensor, ptr %58, i32 0, i32 2
  %60 = getelementptr inbounds [4 x i64], ptr %59, i64 0, i64 1
  %61 = load i64, ptr %60, align 8, !tbaa !11
  %62 = add nsw i64 %57, %61
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = sdiv i64 %62, %64
  %66 = trunc i64 %65 to i32
  store i32 %66, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ggml_tensor, ptr %69, i32 0, i32 2
  %71 = getelementptr inbounds [4 x i64], ptr %70, i64 0, i64 2
  %72 = load i64, ptr %71, align 8, !tbaa !11
  %73 = add nsw i64 %68, %72
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = sdiv i64 %73, %75
  %77 = trunc i64 %76 to i32
  store i32 %77, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = mul nsw i32 %78, %79
  store i32 %80, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #4
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.ggml_tensor, ptr %81, i32 0, i32 2
  %83 = getelementptr inbounds [4 x i64], ptr %82, i64 0, i64 0
  %84 = load i64, ptr %83, align 8, !tbaa !11
  store i64 %84, ptr %12, align 8, !tbaa !11
  %85 = getelementptr inbounds i64, ptr %12, i64 1
  %86 = load i32, ptr %6, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  store i64 %87, ptr %85, align 8, !tbaa !11
  %88 = getelementptr inbounds i64, ptr %12, i64 2
  %89 = load i32, ptr %6, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  store i64 %90, ptr %88, align 8, !tbaa !11
  %91 = getelementptr inbounds i64, ptr %12, i64 3
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = sext i32 %92 to i64
  store i64 %93, ptr %91, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds [4 x i64], ptr %12, i64 0, i64 0
  %96 = call ptr @ggml_new_tensor(ptr noundef %94, i32 noundef 0, i32 noundef 4, ptr noundef %95)
  store ptr %96, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #4
  %97 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %97, ptr %14, align 4, !tbaa !9
  %98 = getelementptr inbounds i32, ptr %14, i64 1
  %99 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %99, ptr %98, align 4, !tbaa !9
  %100 = getelementptr inbounds i32, ptr %14, i64 2
  %101 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %101, ptr %100, align 4, !tbaa !9
  %102 = load ptr, ptr %13, align 8, !tbaa !5
  %103 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  call void @ggml_set_op_params(ptr noundef %102, ptr noundef %103, i64 noundef 12)
  %104 = load ptr, ptr %13, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.ggml_tensor, ptr %104, i32 0, i32 4
  store i32 67, ptr %105, align 8, !tbaa !15
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = load ptr, ptr %13, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.ggml_tensor, ptr %107, i32 0, i32 7
  %109 = getelementptr inbounds [10 x ptr], ptr %108, i64 0, i64 0
  store ptr %106, ptr %109, align 8, !tbaa !5
  %110 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret ptr %110
}

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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 0}
!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}
!15 = !{!14, !10, i64 80}


; 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.12 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [25 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_new_tensor(ptr noundef, i32 noundef, i32 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_win_part(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca [4 x i64], align 16
  %5 = alloca [3 x i32], align 4
  %6 = getelementptr inbounds i8, ptr %1, i64 40
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i64 %7, 1
  br i1 %8, label %10, label %9

9:                                                ; preds = %3
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 4572, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.85) #3
  unreachable

10:                                               ; preds = %3
  %11 = load i32, ptr %1, align 8, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = sext i32 %2 to i64
  %17 = getelementptr inbounds i8, ptr %1, i64 24
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = srem i64 %18, %16
  %20 = sub nsw i64 %16, %19
  %21 = srem i64 %20, %16
  %22 = getelementptr inbounds i8, ptr %1, i64 32
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = srem i64 %23, %16
  %25 = sub nsw i64 %16, %24
  %26 = srem i64 %25, %16
  %27 = add nsw i64 %21, %18
  %28 = sdiv i64 %27, %16
  %29 = trunc i64 %28 to i32
  %30 = add nsw i64 %26, %23
  %31 = sdiv i64 %30, %16
  %32 = trunc i64 %31 to i32
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  %33 = load i64, ptr %15, align 8, !tbaa !5
  store i64 %33, ptr %4, align 16, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %16, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 %16, ptr %35, align 16, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %4, i64 24
  %37 = shl i64 %28, 32
  %sext31 = mul i64 %37, %31
  %38 = ashr exact i64 %sext31, 32
  store i64 %38, ptr %36, align 8, !tbaa !5
  %39 = call ptr @ggml_new_tensor(ptr noundef %0, i32 noundef 0, i32 noundef 4, ptr noundef nonnull %4)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  store i32 %29, ptr %5, align 4, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %32, ptr %40, align 4, !tbaa !13
  %41 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %2, ptr %41, align 4, !tbaa !13
  call void @ggml_set_op_params(ptr noundef %39, ptr noundef nonnull %5, i64 noundef 12)
  %42 = getelementptr inbounds i8, ptr %39, i64 80
  store i32 67, ptr %42, align 8, !tbaa !14
  %43 = getelementptr inbounds i8, ptr %39, i64 152
  store ptr %1, ptr %43, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  ret ptr %39
}

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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"ggml_tensor", !11, i64 0, !12, i64 8, !7, i64 16, !7, i64 48, !11, i64 80, !7, i64 84, !11, i64 148, !7, i64 152, !12, i64 232, !6, i64 240, !12, i64 248, !7, i64 256, !12, i64 320, !7, i64 328}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 80}
!15 = !{!12, !12, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass