; LLVM IR from ggml-org/ggml :: src (ggml-opt)

; 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_opt_params = type { ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr }
%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 [64 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@stderr = external global ptr, align 8
@.str.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [24 x i8], align 1
@__func__.ggml_opt_fit = external hidden unnamed_addr constant [13 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: noreturn
declare 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @ggml_opt_dataset_data(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_dataset_shuffle(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ggml_opt_default_params(ptr dead_on_unwind noalias writable sret(%struct.ggml_opt_params) align 8, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local ptr @ggml_opt_init(ptr noundef byval(%struct.ggml_opt_params) align 8) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_free(ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local ptr @ggml_opt_result_init() #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ggml_opt_result_free(ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ggml_opt_result_reset(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_epoch(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #4

declare i64 @ggml_time_us() #5

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_epoch_callback_progress_bar(i1 noundef zeroext, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) #4

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #6

; Function Attrs: mustprogress uwtable
define dso_local void @ggml_opt_fit(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6, i64 noundef %7, i64 noundef %8, float noundef %9, i1 noundef zeroext %10) #4 {
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca float, align 4
  %22 = alloca i8, align 1
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca i64, align 8
  %26 = alloca i64, align 8
  %27 = alloca i64, align 8
  %28 = alloca i64, align 8
  %29 = alloca i64, align 8
  %30 = alloca i64, align 8
  %31 = alloca %struct.ggml_opt_params, align 8
  %32 = alloca ptr, align 8
  %33 = alloca %struct.ggml_opt_params, align 8
  %34 = alloca ptr, align 8
  %35 = alloca ptr, align 8
  %36 = alloca ptr, align 8
  %37 = alloca i64, align 8
  %38 = alloca i64, align 8
  %39 = alloca i64, align 8
  store ptr %0, ptr %12, align 8, !tbaa !5
  store ptr %1, ptr %13, align 8, !tbaa !5
  store ptr %2, ptr %14, align 8, !tbaa !5
  store ptr %3, ptr %15, align 8, !tbaa !5
  store ptr %4, ptr %16, align 8, !tbaa !5
  store i32 %5, ptr %17, align 4, !tbaa !9
  store ptr %6, ptr %18, align 8, !tbaa !5
  store i64 %7, ptr %19, align 8, !tbaa !11
  store i64 %8, ptr %20, align 8, !tbaa !11
  store float %9, ptr %21, align 4, !tbaa !13
  %40 = zext i1 %10 to i8
  store i8 %40, ptr %22, align 1, !tbaa !15
  call void @ggml_time_init()
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  %41 = call i64 @ggml_time_us()
  store i64 %41, ptr %23, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  %42 = load ptr, ptr %16, align 8, !tbaa !5
  %43 = call ptr @ggml_opt_dataset_data(ptr noundef %42)
  %44 = getelementptr inbounds %struct.ggml_tensor, ptr %43, i32 0, i32 2
  %45 = getelementptr inbounds [4 x i64], ptr %44, i64 0, i64 1
  %46 = load i64, ptr %45, align 8, !tbaa !11
  store i64 %46, ptr %24, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #7
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ggml_tensor, ptr %47, i32 0, i32 2
  %49 = getelementptr inbounds [4 x i64], ptr %48, i64 0, i64 1
  %50 = load i64, ptr %49, align 8, !tbaa !11
  store i64 %50, ptr %25, align 8, !tbaa !11
  %51 = load i64, ptr %24, align 8, !tbaa !11
  %52 = load i64, ptr %20, align 8, !tbaa !11
  %53 = srem i64 %51, %52
  %54 = icmp eq i64 %53, 0
  br i1 %54, label %56, label %55

55:                                               ; preds = %11
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 796, ptr noundef @.str.1, ptr noundef @.str.40) #8
  unreachable

56:                                               ; preds = %11
  %57 = load i64, ptr %20, align 8, !tbaa !11
  %58 = load i64, ptr %25, align 8, !tbaa !11
  %59 = srem i64 %57, %58
  %60 = icmp eq i64 %59, 0
  br i1 %60, label %62, label %61

61:                                               ; preds = %56
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 797, ptr noundef @.str.1, ptr noundef @.str.41) #8
  unreachable

62:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #7
  %63 = load i64, ptr %20, align 8, !tbaa !11
  %64 = load i64, ptr %25, align 8, !tbaa !11
  %65 = sdiv i64 %63, %64
  store i64 %65, ptr %26, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #7
  %66 = load i64, ptr %24, align 8, !tbaa !11
  %67 = load i64, ptr %20, align 8, !tbaa !11
  %68 = sdiv i64 %66, %67
  store i64 %68, ptr %27, align 8, !tbaa !11
  %69 = load float, ptr %21, align 4, !tbaa !13
  %70 = fcmp oge float %69, 0.000000e+00
  br i1 %70, label %72, label %71

71:                                               ; preds = %62
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 802, ptr noundef @.str.1, ptr noundef @.str.42) #8
  unreachable

72:                                               ; preds = %62
  %73 = load float, ptr %21, align 4, !tbaa !13
  %74 = fcmp olt float %73, 1.000000e+00
  br i1 %74, label %76, label %75

75:                                               ; preds = %72
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 803, ptr noundef @.str.1, ptr noundef @.str.43) #8
  unreachable

76:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #7
  %77 = load float, ptr %21, align 4, !tbaa !13
  %78 = fsub float 1.000000e+00, %77
  %79 = load i64, ptr %27, align 8, !tbaa !11
  %80 = sitofp i64 %79 to float
  %81 = fmul float %78, %80
  %82 = fptosi float %81 to i64
  %83 = load i64, ptr %26, align 8, !tbaa !11
  %84 = mul nsw i64 %82, %83
  store i64 %84, ptr %28, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #7
  %85 = load i64, ptr %28, align 8, !tbaa !11
  %86 = load i64, ptr %25, align 8, !tbaa !11
  %87 = mul nsw i64 %85, %86
  store i64 %87, ptr %29, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #7
  store i64 1, ptr %30, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 64, ptr %31) #7
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = load ptr, ptr %13, align 8, !tbaa !5
  %90 = load ptr, ptr %14, align 8, !tbaa !5
  %91 = load ptr, ptr %15, align 8, !tbaa !5
  %92 = load i32, ptr %17, align 4, !tbaa !9
  call void @ggml_opt_default_params(ptr dead_on_unwind writable sret(%struct.ggml_opt_params) align 8 %31, ptr noundef %88, ptr noundef %89, ptr noundef %90, ptr noundef %91, i32 noundef %92)
  %93 = load i64, ptr %26, align 8, !tbaa !11
  %94 = trunc i64 %93 to i32
  %95 = getelementptr inbounds %struct.ggml_opt_params, ptr %31, i32 0, i32 6
  store i32 %94, ptr %95, align 8, !tbaa !17
  %96 = load ptr, ptr %18, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ggml_opt_params, ptr %31, i32 0, i32 7
  store ptr %96, ptr %97, align 8, !tbaa !21
  %98 = getelementptr inbounds %struct.ggml_opt_params, ptr %31, i32 0, i32 8
  store ptr %30, ptr %98, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %33, ptr align 8 %31, i64 64, i1 false), !tbaa.struct !23
  %99 = call ptr @ggml_opt_init(ptr noundef byval(%struct.ggml_opt_params) align 8 %33)
  store ptr %99, ptr %32, align 8, !tbaa !5
  %100 = load i64, ptr %20, align 8, !tbaa !11
  %101 = load i64, ptr %24, align 8, !tbaa !11
  %102 = icmp slt i64 %100, %101
  br i1 %102, label %103, label %106

103:                                              ; preds = %76
  %104 = load ptr, ptr %32, align 8, !tbaa !5
  %105 = load ptr, ptr %16, align 8, !tbaa !5
  call void @ggml_opt_dataset_shuffle(ptr noundef %104, ptr noundef %105, i64 noundef -1)
  br label %106

106:                                              ; preds = %103, %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %34) #7
  %107 = call ptr @ggml_opt_result_init()
  store ptr %107, ptr %34, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %35) #7
  %108 = call ptr @ggml_opt_result_init()
  store ptr %108, ptr %35, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %36) #7
  %109 = load i8, ptr %22, align 1, !tbaa !15, !range !26, !noundef !27
  %110 = trunc i8 %109 to i1
  %111 = zext i1 %110 to i64
  %112 = select i1 %110, ptr null, ptr @ggml_opt_epoch_callback_progress_bar
  store ptr %112, ptr %36, align 8, !tbaa !5
  br label %113

113:                                              ; preds = %149, %106
  %114 = load i64, ptr %30, align 8, !tbaa !11
  %115 = load i64, ptr %19, align 8, !tbaa !11
  %116 = icmp sle i64 %114, %115
  br i1 %116, label %117, label %152

117:                                              ; preds = %113
  %118 = load i64, ptr %20, align 8, !tbaa !11
  %119 = load i64, ptr %29, align 8, !tbaa !11
  %120 = icmp slt i64 %118, %119
  br i1 %120, label %121, label %125

121:                                              ; preds = %117
  %122 = load ptr, ptr %32, align 8, !tbaa !5
  %123 = load ptr, ptr %16, align 8, !tbaa !5
  %124 = load i64, ptr %29, align 8, !tbaa !11
  call void @ggml_opt_dataset_shuffle(ptr noundef %122, ptr noundef %123, i64 noundef %124)
  br label %125

125:                                              ; preds = %121, %117
  %126 = load ptr, ptr %34, align 8, !tbaa !5
  call void @ggml_opt_result_reset(ptr noundef %126)
  %127 = load ptr, ptr %35, align 8, !tbaa !5
  call void @ggml_opt_result_reset(ptr noundef %127)
  %128 = load i8, ptr %22, align 1, !tbaa !15, !range !26, !noundef !27
  %129 = trunc i8 %128 to i1
  br i1 %129, label %135, label %130

130:                                              ; preds = %125
  %131 = load ptr, ptr @stderr, align 8, !tbaa !5
  %132 = load i64, ptr %30, align 8, !tbaa !11
  %133 = load i64, ptr %19, align 8, !tbaa !11
  %134 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %131, ptr noundef @.str.44, ptr noundef @__func__.ggml_opt_fit, i64 noundef %132, i64 noundef %133) #7
  br label %135

135:                                              ; preds = %130, %125
  %136 = load ptr, ptr %32, align 8, !tbaa !5
  %137 = load ptr, ptr %16, align 8, !tbaa !5
  %138 = load ptr, ptr %34, align 8, !tbaa !5
  %139 = load ptr, ptr %35, align 8, !tbaa !5
  %140 = load i64, ptr %29, align 8, !tbaa !11
  %141 = load ptr, ptr %36, align 8, !tbaa !5
  %142 = load ptr, ptr %36, align 8, !tbaa !5
  call void @ggml_opt_epoch(ptr noundef %136, ptr noundef %137, ptr noundef %138, ptr noundef %139, i64 noundef %140, ptr noundef %141, ptr noundef %142)
  %143 = load i8, ptr %22, align 1, !tbaa !15, !range !26, !noundef !27
  %144 = trunc i8 %143 to i1
  br i1 %144, label %148, label %145

145:                                              ; preds = %135
  %146 = load ptr, ptr @stderr, align 8, !tbaa !5
  %147 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %146, ptr noundef @.str.39) #7
  br label %148

148:                                              ; preds = %145, %135
  br label %149

149:                                              ; preds = %148
  %150 = load i64, ptr %30, align 8, !tbaa !11
  %151 = add nsw i64 %150, 1
  store i64 %151, ptr %30, align 8, !tbaa !11
  br label %113, !llvm.loop !28

152:                                              ; preds = %113
  %153 = load i8, ptr %22, align 1, !tbaa !15, !range !26, !noundef !27
  %154 = trunc i8 %153 to i1
  br i1 %154, label %177, label %155

155:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 8, ptr %37) #7
  %156 = call i64 @ggml_time_us()
  %157 = load i64, ptr %23, align 8, !tbaa !11
  %158 = sub nsw i64 %156, %157
  %159 = sdiv i64 %158, 1000000
  store i64 %159, ptr %37, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %38) #7
  %160 = load i64, ptr %37, align 8, !tbaa !11
  %161 = sdiv i64 %160, 3600
  store i64 %161, ptr %38, align 8, !tbaa !11
  %162 = load i64, ptr %38, align 8, !tbaa !11
  %163 = mul nsw i64 %162, 3600
  %164 = load i64, ptr %37, align 8, !tbaa !11
  %165 = sub nsw i64 %164, %163
  store i64 %165, ptr %37, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %39) #7
  %166 = load i64, ptr %37, align 8, !tbaa !11
  %167 = sdiv i64 %166, 60
  store i64 %167, ptr %39, align 8, !tbaa !11
  %168 = load i64, ptr %39, align 8, !tbaa !11
  %169 = mul nsw i64 %168, 60
  %170 = load i64, ptr %37, align 8, !tbaa !11
  %171 = sub nsw i64 %170, %169
  store i64 %171, ptr %37, align 8, !tbaa !11
  %172 = load ptr, ptr @stderr, align 8, !tbaa !5
  %173 = load i64, ptr %38, align 8, !tbaa !11
  %174 = load i64, ptr %39, align 8, !tbaa !11
  %175 = load i64, ptr %37, align 8, !tbaa !11
  %176 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %172, ptr noundef @.str.45, ptr noundef @__func__.ggml_opt_fit, i64 noundef %173, i64 noundef %174, i64 noundef %175) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %39) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %38) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %37) #7
  br label %177

177:                                              ; preds = %155, %152
  %178 = load ptr, ptr %32, align 8, !tbaa !5
  call void @ggml_opt_free(ptr noundef %178)
  %179 = load ptr, ptr %34, align 8, !tbaa !5
  call void @ggml_opt_result_free(ptr noundef %179)
  %180 = load ptr, ptr %35, align 8, !tbaa !5
  call void @ggml_opt_result_free(ptr noundef %180)
  call void @llvm.lifetime.end.p0(i64 8, ptr %36) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %34) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %32) #7
  call void @llvm.lifetime.end.p0(i64 64, ptr %31) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  ret void
}

declare void @ggml_time_init() #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 #4 = { mustprogress 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 #5 = { "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 #6 = { nounwind "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 #7 = { nounwind }
attributes #8 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS18ggml_opt_loss_type", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!18, !20, i64 40}
!18 = !{!"_ZTS15ggml_opt_params", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !19, i64 36, !20, i64 40, !6, i64 48, !6, i64 56}
!19 = !{!"_ZTS19ggml_opt_build_type", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!18, !6, i64 48}
!22 = !{!18, !6, i64 56}
!23 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 4, !9, i64 36, i64 4, !24, i64 40, i64 4, !25, i64 48, i64 8, !5, i64 56, i64 8, !5}
!24 = !{!19, !19, i64 0}
!25 = !{!20, !20, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = distinct !{!28, !29}
!29 = !{!"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"

%struct.ggml_opt_params = type { ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr }

@.str = external hidden unnamed_addr constant [64 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [24 x i8], align 1
@__func__.ggml_opt_fit = external hidden unnamed_addr constant [13 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: noreturn
declare 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: mustprogress nounwind uwtable
declare dso_local ptr @ggml_opt_dataset_data(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_dataset_shuffle(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ggml_opt_default_params(ptr dead_on_unwind noalias writable sret(%struct.ggml_opt_params) align 8, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local ptr @ggml_opt_init(ptr noundef byval(%struct.ggml_opt_params) align 8) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local ptr @ggml_opt_result_init() local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ggml_opt_result_free(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ggml_opt_result_reset(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_epoch(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i64 @ggml_time_us() local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @ggml_opt_epoch_callback_progress_bar(i1 noundef zeroext, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) #3

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local void @ggml_opt_fit(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6, i64 noundef %7, i64 noundef %8, float noundef %9, i1 noundef zeroext %10) local_unnamed_addr #3 {
  %12 = alloca i64, align 8
  %13 = alloca %struct.ggml_opt_params, align 8
  tail call void @ggml_time_init()
  %14 = tail call i64 @ggml_time_us()
  %15 = tail call ptr @ggml_opt_dataset_data(ptr noundef %4)
  %16 = getelementptr inbounds i8, ptr %15, i64 24
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %2, i64 24
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = srem i64 %17, %8
  %21 = sdiv i64 %17, %8
  %22 = icmp eq i64 %20, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %11
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 796, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.40) #6
  unreachable

24:                                               ; preds = %11
  %25 = srem i64 %8, %19
  %26 = sdiv i64 %8, %19
  %27 = icmp eq i64 %25, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 797, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.41) #6
  unreachable

29:                                               ; preds = %24
  %30 = fcmp ult float %9, 0.000000e+00
  br i1 %30, label %31, label %32

31:                                               ; preds = %29
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 802, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.42) #6
  unreachable

32:                                               ; preds = %29
  %33 = fcmp olt float %9, 1.000000e+00
  br i1 %33, label %35, label %34

34:                                               ; preds = %32
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 803, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.43) #6
  unreachable

35:                                               ; preds = %32
  %36 = fsub float 1.000000e+00, %9
  %37 = sitofp i64 %21 to float
  %38 = fmul float %36, %37
  %39 = fptosi float %38 to i64
  %40 = mul i64 %26, %19
  %41 = mul i64 %40, %39
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #7
  store i64 1, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %13) #7
  call void @ggml_opt_default_params(ptr dead_on_unwind nonnull writable sret(%struct.ggml_opt_params) align 8 %13, ptr noundef %0, ptr noundef %1, ptr noundef nonnull %2, ptr noundef %3, i32 noundef %5)
  %42 = trunc i64 %26 to i32
  %43 = getelementptr inbounds i8, ptr %13, i64 40
  store i32 %42, ptr %43, align 8, !tbaa !9
  %44 = getelementptr inbounds i8, ptr %13, i64 48
  store ptr %6, ptr %44, align 8, !tbaa !15
  %45 = getelementptr inbounds i8, ptr %13, i64 56
  store ptr %12, ptr %45, align 8, !tbaa !16
  %46 = call ptr @ggml_opt_init(ptr noundef nonnull byval(%struct.ggml_opt_params) align 8 %13)
  %47 = icmp sgt i64 %17, %8
  br i1 %47, label %48, label %49

48:                                               ; preds = %35
  call void @ggml_opt_dataset_shuffle(ptr noundef %46, ptr noundef %4, i64 noundef -1)
  br label %49

49:                                               ; preds = %48, %35
  %50 = call ptr @ggml_opt_result_init()
  %51 = call ptr @ggml_opt_result_init()
  %52 = load i64, ptr %12, align 8, !tbaa !5
  %.not63 = icmp sgt i64 %52, %7
  br i1 %.not63, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %49
  %53 = icmp sgt i64 %41, %8
  br i1 %10, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %53, label %.critedge.us.us, label %.critedge.us

.critedge.us.us:                                  ; preds = %.lr.ph.split.us, %.critedge.us.us
  call void @ggml_opt_dataset_shuffle(ptr noundef %46, ptr noundef %4, i64 noundef %41)
  call void @ggml_opt_result_reset(ptr noundef %50)
  call void @ggml_opt_result_reset(ptr noundef %51)
  call void @ggml_opt_epoch(ptr noundef %46, ptr noundef %4, ptr noundef %50, ptr noundef %51, i64 noundef %41, ptr noundef null, ptr noundef null)
  %54 = load i64, ptr %12, align 8, !tbaa !5
  %55 = add nsw i64 %54, 1
  store i64 %55, ptr %12, align 8, !tbaa !5
  %.not.us.us.not = icmp slt i64 %54, %7
  br i1 %.not.us.us.not, label %.critedge.us.us, label %._crit_edge, !llvm.loop !17

.critedge.us:                                     ; preds = %.lr.ph.split.us, %.critedge.us
  call void @ggml_opt_result_reset(ptr noundef %50)
  call void @ggml_opt_result_reset(ptr noundef %51)
  call void @ggml_opt_epoch(ptr noundef %46, ptr noundef %4, ptr noundef %50, ptr noundef %51, i64 noundef %41, ptr noundef null, ptr noundef null)
  %56 = load i64, ptr %12, align 8, !tbaa !5
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %12, align 8, !tbaa !5
  %.not.us.not = icmp slt i64 %56, %7
  br i1 %.not.us.not, label %.critedge.us, label %._crit_edge, !llvm.loop !17

.lr.ph.split:                                     ; preds = %.lr.ph
  br i1 %53, label %.lr.ph.split.split.us, label %.lr.ph.split.split

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split, %.lr.ph.split.split.us
  call void @ggml_opt_dataset_shuffle(ptr noundef %46, ptr noundef %4, i64 noundef %41)
  call void @ggml_opt_result_reset(ptr noundef %50)
  call void @ggml_opt_result_reset(ptr noundef %51)
  %58 = load ptr, ptr @stderr, align 8, !tbaa !19
  %59 = load i64, ptr %12, align 8, !tbaa !5
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef nonnull @.str.44, ptr noundef nonnull @__func__.ggml_opt_fit, i64 noundef %59, i64 noundef %7) #8
  call void @ggml_opt_epoch(ptr noundef %46, ptr noundef %4, ptr noundef %50, ptr noundef %51, i64 noundef %41, ptr noundef nonnull @ggml_opt_epoch_callback_progress_bar, ptr noundef nonnull @ggml_opt_epoch_callback_progress_bar)
  %61 = load ptr, ptr @stderr, align 8, !tbaa !19
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef nonnull @.str.39) #8
  %63 = load i64, ptr %12, align 8, !tbaa !5
  %64 = add nsw i64 %63, 1
  store i64 %64, ptr %12, align 8, !tbaa !5
  %.not.us64.not = icmp slt i64 %63, %7
  br i1 %.not.us64.not, label %.lr.ph.split.split.us, label %._crit_edge, !llvm.loop !17

.lr.ph.split.split:                               ; preds = %.lr.ph.split, %.lr.ph.split.split
  call void @ggml_opt_result_reset(ptr noundef %50)
  call void @ggml_opt_result_reset(ptr noundef %51)
  %65 = load ptr, ptr @stderr, align 8, !tbaa !19
  %66 = load i64, ptr %12, align 8, !tbaa !5
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef nonnull @.str.44, ptr noundef nonnull @__func__.ggml_opt_fit, i64 noundef %66, i64 noundef %7) #8
  call void @ggml_opt_epoch(ptr noundef %46, ptr noundef %4, ptr noundef %50, ptr noundef %51, i64 noundef %41, ptr noundef nonnull @ggml_opt_epoch_callback_progress_bar, ptr noundef nonnull @ggml_opt_epoch_callback_progress_bar)
  %68 = load ptr, ptr @stderr, align 8, !tbaa !19
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef nonnull @.str.39) #8
  %70 = load i64, ptr %12, align 8, !tbaa !5
  %71 = add nsw i64 %70, 1
  store i64 %71, ptr %12, align 8, !tbaa !5
  %.not.not = icmp slt i64 %70, %7
  br i1 %.not.not, label %.lr.ph.split.split, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph.split.split, %.lr.ph.split.split.us, %.critedge.us, %.critedge.us.us, %49
  br i1 %10, label %82, label %72

72:                                               ; preds = %._crit_edge
  %73 = call i64 @ggml_time_us()
  %74 = sub nsw i64 %73, %14
  %75 = sdiv i64 %74, 1000000
  %76 = sdiv i64 %74, 3600000000
  %.neg = mul nsw i64 %76, -3600
  %77 = add nsw i64 %.neg, %75
  %78 = sdiv i64 %77, 60
  %.neg62 = mul nsw i64 %78, -60
  %79 = add nsw i64 %.neg62, %77
  %80 = load ptr, ptr @stderr, align 8, !tbaa !19
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef nonnull @.str.45, ptr noundef nonnull @__func__.ggml_opt_fit, i64 noundef %76, i64 noundef %78, i64 noundef %79) #8
  br label %82

82:                                               ; preds = %72, %._crit_edge
  call void @ggml_opt_free(ptr noundef %46)
  call void @ggml_opt_result_free(ptr noundef %50)
  call void @ggml_opt_result_free(ptr noundef %51)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #7
  ret void
}

declare void @ggml_time_init() local_unnamed_addr #4

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { mustprogress 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 #4 = { "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 #5 = { nofree nounwind "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 #6 = { noreturn }
attributes #7 = { nounwind }
attributes #8 = { cold 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++ TBAA"}
!9 = !{!10, !14, i64 40}
!10 = !{!"_ZTS15ggml_opt_params", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !13, i64 36, !14, i64 40, !11, i64 48, !11, i64 56}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_ZTS18ggml_opt_loss_type", !7, i64 0}
!13 = !{!"_ZTS19ggml_opt_build_type", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !11, i64 48}
!16 = !{!10, !11, i64 56}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,DivRemPairsPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass