; 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.49 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.94 = 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 zeroext i1 @ggml_is_contiguous(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @ggml_new_tensor_4d(ptr noundef, i32 noundef, i64 noundef, i64 noundef, i64 noundef, i64 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_pad_reflect_1d(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [2 x i32], align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = icmp sge i32 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %4
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 4249, ptr noundef @.str.13, ptr noundef @.str.91) #3
  unreachable

14:                                               ; preds = %4
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = icmp sge i32 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 4250, ptr noundef @.str.13, ptr noundef @.str.92) #3
  unreachable

18:                                               ; preds = %14
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ggml_tensor, ptr %21, i32 0, i32 2
  %23 = getelementptr inbounds [4 x i64], ptr %22, i64 0, i64 0
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = icmp slt i64 %20, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %18
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 4252, ptr noundef @.str.13, ptr noundef @.str.93) #3
  unreachable

27:                                               ; preds = %18
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = load ptr, ptr %6, 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 0
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = icmp slt i64 %29, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %27
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 4253, ptr noundef @.str.13, ptr noundef @.str.94) #3
  unreachable

36:                                               ; preds = %27
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call zeroext i1 @ggml_is_contiguous(ptr noundef %37)
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 4255, ptr noundef @.str.13, ptr noundef @.str.49) #3
  unreachable

40:                                               ; preds = %36
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ggml_tensor, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !13
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %40
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 4256, ptr noundef @.str.13, ptr noundef @.str.95) #3
  unreachable

46:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ggml_tensor, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ggml_tensor, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds [4 x i64], ptr %52, i64 0, i64 0
  %54 = load i64, ptr %53, align 8, !tbaa !11
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = add nsw i64 %54, %56
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = add nsw i64 %57, %59
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ggml_tensor, ptr %61, i32 0, i32 2
  %63 = getelementptr inbounds [4 x i64], ptr %62, i64 0, i64 1
  %64 = load i64, ptr %63, align 8, !tbaa !11
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ggml_tensor, ptr %65, i32 0, i32 2
  %67 = getelementptr inbounds [4 x i64], ptr %66, i64 0, i64 2
  %68 = load i64, ptr %67, align 8, !tbaa !11
  %69 = load ptr, ptr %6, 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 3
  %72 = load i64, ptr %71, align 8, !tbaa !11
  %73 = call ptr @ggml_new_tensor_4d(ptr noundef %47, i32 noundef %50, i64 noundef %60, i64 noundef %64, i64 noundef %68, i64 noundef %72)
  store ptr %73, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %74 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %74, ptr %10, align 4, !tbaa !9
  %75 = getelementptr inbounds i32, ptr %10, i64 1
  %76 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %76, ptr %75, align 4, !tbaa !9
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 0
  call void @ggml_set_op_params(ptr noundef %77, ptr noundef %78, i64 noundef 8)
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ggml_tensor, ptr %79, i32 0, i32 4
  store i32 58, ptr %80, align 8, !tbaa !15
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ggml_tensor, ptr %82, i32 0, i32 7
  %84 = getelementptr inbounds [10 x ptr], ptr %83, i64 0, i64 0
  store ptr %81, ptr %84, align 8, !tbaa !5
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret ptr %85
}

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.49 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.94 = 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 zeroext i1 @ggml_is_contiguous(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @ggml_new_tensor_4d(ptr noundef, i32 noundef, i64 noundef, i64 noundef, i64 noundef, i64 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_pad_reflect_1d(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca [2 x i32], align 4
  %6 = icmp sgt i32 %2, -1
  br i1 %6, label %8, label %7

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

8:                                                ; preds = %4
  %9 = icmp sgt i32 %3, -1
  br i1 %9, label %11, label %10

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

11:                                               ; preds = %8
  %12 = zext nneg i32 %2 to i64
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = icmp sgt i64 %14, %12
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 4252, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.93) #3
  unreachable

17:                                               ; preds = %11
  %18 = zext nneg i32 %3 to i64
  %19 = icmp ugt i64 %14, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 4253, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.94) #3
  unreachable

21:                                               ; preds = %17
  %22 = tail call zeroext i1 @ggml_is_contiguous(ptr noundef nonnull %1)
  br i1 %22, label %24, label %23

23:                                               ; preds = %21
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 4255, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.49) #3
  unreachable

24:                                               ; preds = %21
  %25 = load i32, ptr %1, align 8, !tbaa !9
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %24
  %29 = load i64, ptr %13, align 8, !tbaa !5
  %30 = add nuw nsw i64 %18, %12
  %31 = add i64 %30, %29
  %32 = getelementptr inbounds i8, ptr %1, i64 24
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %1, i64 32
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %1, i64 40
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = tail call ptr @ggml_new_tensor_4d(ptr noundef %0, i32 noundef 0, i64 noundef %31, i64 noundef %33, i64 noundef %35, i64 noundef %37)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i32 %2, ptr %5, align 4, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %3, ptr %39, align 4, !tbaa !13
  call void @ggml_set_op_params(ptr noundef %38, ptr noundef nonnull %5, i64 noundef 8)
  %40 = getelementptr inbounds i8, ptr %38, i64 80
  store i32 58, ptr %40, align 8, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %38, i64 152
  store ptr %1, ptr %41, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret ptr %38
}

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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass