; 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.156 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.157 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.158 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.159 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [34 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 i64 @ggml_nelements(ptr noundef) #2

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

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

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

19:                                               ; preds = %6
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 5098, ptr noundef @.str.13, ptr noundef @.str.156) #3
  unreachable

20:                                               ; preds = %6
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = call zeroext i1 @ggml_are_same_shape(ptr noundef %21, ptr noundef %22)
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %20
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = call zeroext i1 @ggml_are_same_shape(ptr noundef %26, ptr noundef %27)
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 5100, ptr noundef @.str.13, ptr noundef @.str.158) #3
  unreachable

30:                                               ; preds = %25
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = call zeroext i1 @ggml_are_same_shape(ptr noundef %31, ptr noundef %32)
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 5101, ptr noundef @.str.13, ptr noundef @.str.159) #3
  unreachable

35:                                               ; preds = %30
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ggml_tensor, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !13
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 5102, ptr noundef @.str.13, ptr noundef @.str.160) #3
  unreachable

41:                                               ; preds = %35
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = call i64 @ggml_nelements(ptr noundef %42)
  %44 = icmp eq i64 %43, 7
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 5103, ptr noundef @.str.13, ptr noundef @.str.161) #3
  unreachable

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = call ptr @ggml_view_tensor(ptr noundef %47, ptr noundef %48)
  store ptr %49, ptr %13, align 8, !tbaa !5
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ggml_tensor, ptr %50, i32 0, i32 4
  store i32 81, ptr %51, align 8, !tbaa !14
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ggml_tensor, ptr %53, i32 0, i32 7
  %55 = getelementptr inbounds [10 x ptr], ptr %54, i64 0, i64 0
  store ptr %52, ptr %55, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ggml_tensor, ptr %57, i32 0, i32 7
  %59 = getelementptr inbounds [10 x ptr], ptr %58, i64 0, i64 1
  store ptr %56, ptr %59, align 8, !tbaa !5
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ggml_tensor, ptr %61, i32 0, i32 7
  %63 = getelementptr inbounds [10 x ptr], ptr %62, i64 0, i64 2
  store ptr %60, ptr %63, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ggml_tensor, ptr %65, i32 0, i32 7
  %67 = getelementptr inbounds [10 x ptr], ptr %66, i64 0, i64 3
  store ptr %64, ptr %67, align 8, !tbaa !5
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ggml_tensor, ptr %69, i32 0, i32 7
  %71 = getelementptr inbounds [10 x ptr], ptr %70, i64 0, i64 4
  store ptr %68, ptr %71, align 8, !tbaa !5
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret ptr %72
}

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, !11, i64 148}
!10 = !{!"ggml_tensor", !11, i64 0, !6, i64 8, !7, i64 16, !7, i64 48, !11, i64 80, !7, i64 84, !11, i64 148, !7, i64 152, !6, i64 232, !12, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, 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.156 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.157 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.158 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.159 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [34 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: nounwind uwtable
declare dso_local i64 @ggml_nelements(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ggml_are_same_shape(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ggml_opt_step_adamw(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #1 {
  %7 = getelementptr inbounds i8, ptr %1, i64 148
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = and i32 %8, 4
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %11

10:                                               ; preds = %6
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 5098, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.156) #2
  unreachable

11:                                               ; preds = %6
  %12 = tail call zeroext i1 @ggml_are_same_shape(ptr noundef nonnull %1, ptr noundef %2)
  br i1 %12, label %14, label %13

13:                                               ; preds = %11
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 5099, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.157) #2
  unreachable

14:                                               ; preds = %11
  %15 = tail call zeroext i1 @ggml_are_same_shape(ptr noundef nonnull %1, ptr noundef %3)
  br i1 %15, label %17, label %16

16:                                               ; preds = %14
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 5100, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.158) #2
  unreachable

17:                                               ; preds = %14
  %18 = tail call zeroext i1 @ggml_are_same_shape(ptr noundef nonnull %1, ptr noundef %4)
  br i1 %18, label %20, label %19

19:                                               ; preds = %17
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 5101, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.159) #2
  unreachable

20:                                               ; preds = %17
  %21 = load i32, ptr %5, align 8, !tbaa !12
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 5102, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.160) #2
  unreachable

24:                                               ; preds = %20
  %25 = tail call i64 @ggml_nelements(ptr noundef nonnull %5)
  %26 = icmp eq i64 %25, 7
  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 5103, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.161) #2
  unreachable

28:                                               ; preds = %24
  %29 = tail call ptr @ggml_view_tensor(ptr noundef %0, ptr noundef nonnull %1)
  %30 = getelementptr inbounds i8, ptr %29, i64 80
  store i32 81, ptr %30, align 8, !tbaa !13
  %31 = getelementptr inbounds i8, ptr %29, i64 152
  store ptr %1, ptr %31, align 8, !tbaa !14
  %32 = getelementptr inbounds i8, ptr %29, i64 160
  store ptr %2, ptr %32, align 8, !tbaa !14
  %33 = getelementptr inbounds i8, ptr %29, i64 168
  store ptr %3, ptr %33, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %29, i64 176
  store ptr %4, ptr %34, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %29, i64 184
  store ptr %5, ptr %35, align 8, !tbaa !14
  ret ptr %29
}

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 = { 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 }

!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 148}
!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 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 80}
!14 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass