; LLVM IR from sbu-fsl/kernel-ml :: src/functions (cross_entropy_loss)

; 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.cross_entropy_loss = type { ptr, ptr, ptr }
%struct.matrix = type { i32, i32, i32, %union.anon }
%union.anon = type { ptr }

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__.compute_cross_entropy_loss = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @compute_cross_entropy_loss(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %9 = call ptr @kml_calloc(i64 noundef 1, i64 noundef 8)
  store ptr %9, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.cross_entropy_loss, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds %struct.matrix, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.cross_entropy_loss, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.matrix, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = call ptr @allocate_matrix(i32 noundef %14, i32 noundef 1, i32 noundef %19)
  store ptr %20, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.cross_entropy_loss, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds %struct.matrix, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.cross_entropy_loss, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds %struct.matrix, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 8, !tbaa !15
  %31 = call ptr @allocate_matrix(i32 noundef %25, i32 noundef 1, i32 noundef %30)
  store ptr %31, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.cross_entropy_loss, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.matrix, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !13
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.cross_entropy_loss, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = getelementptr inbounds %struct.matrix, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 8, !tbaa !15
  %42 = call ptr @allocate_matrix(i32 noundef %36, i32 noundef 1, i32 noundef %41)
  store ptr %42, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %153, %1
  %44 = load i32, ptr %3, align 4, !tbaa !9
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.cross_entropy_loss, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct.matrix, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !13
  %50 = icmp slt i32 %44, %49
  br i1 %50, label %51, label %156

51:                                               ; preds = %43
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.cross_entropy_loss, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct.matrix, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !15
  switch i32 %56, label %152 [
    i32 1, label %57
    i32 2, label %104
    i32 0, label %151
  ]

57:                                               ; preds = %51
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.cross_entropy_loss, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.matrix, ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = load i32, ptr %3, align 4, !tbaa !9
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.cross_entropy_loss, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  %67 = getelementptr inbounds %struct.matrix, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !17
  %69 = mul nsw i32 %63, %68
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.cross_entropy_loss, ptr %70, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !18
  %73 = getelementptr inbounds %struct.matrix, ptr %72, i32 0, i32 3
  %74 = load ptr, ptr %73, align 8, !tbaa !16
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr %74, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !9
  %79 = add nsw i32 %69, %78
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds float, ptr %62, i64 %80
  %82 = load float, ptr %81, align 4, !tbaa !19
  %83 = fmul float %82, -1.000000e+00
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.matrix, ptr %84, i32 0, i32 3
  %86 = load ptr, ptr %85, align 8, !tbaa !16
  %87 = load i32, ptr %3, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %86, i64 %88
  store float %83, ptr %89, align 4, !tbaa !19
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.cross_entropy_loss, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !11
  %93 = load i32, ptr %3, align 4, !tbaa !9
  %94 = call ptr @get_row(ptr noundef %92, i32 noundef %93)
  store ptr %94, ptr %4, align 8, !tbaa !5
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = call float @logsumexp(ptr noundef %95)
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.matrix, ptr %97, i32 0, i32 3
  %99 = load ptr, ptr %98, align 8, !tbaa !16
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds float, ptr %99, i64 %101
  store float %96, ptr %102, align 4, !tbaa !19
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free_matrix(ptr noundef %103)
  br label %152

104:                                              ; preds = %51
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.cross_entropy_loss, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !11
  %108 = getelementptr inbounds %struct.matrix, ptr %107, i32 0, i32 3
  %109 = load ptr, ptr %108, align 8, !tbaa !16
  %110 = load i32, ptr %3, align 4, !tbaa !9
  %111 = load ptr, ptr %2, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.cross_entropy_loss, ptr %111, i32 0, i32 0
  %113 = load ptr, ptr %112, align 8, !tbaa !11
  %114 = getelementptr inbounds %struct.matrix, ptr %113, i32 0, i32 1
  %115 = load i32, ptr %114, align 4, !tbaa !17
  %116 = mul nsw i32 %110, %115
  %117 = load ptr, ptr %2, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.cross_entropy_loss, ptr %117, i32 0, i32 1
  %119 = load ptr, ptr %118, align 8, !tbaa !18
  %120 = getelementptr inbounds %struct.matrix, ptr %119, i32 0, i32 3
  %121 = load ptr, ptr %120, align 8, !tbaa !16
  %122 = load i32, ptr %3, align 4, !tbaa !9
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i32, ptr %121, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !9
  %126 = add nsw i32 %116, %125
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds double, ptr %109, i64 %127
  %129 = load double, ptr %128, align 8, !tbaa !21
  %130 = fmul double %129, -1.000000e+00
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.matrix, ptr %131, i32 0, i32 3
  %133 = load ptr, ptr %132, align 8, !tbaa !16
  %134 = load i32, ptr %3, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds double, ptr %133, i64 %135
  store double %130, ptr %136, align 8, !tbaa !21
  %137 = load ptr, ptr %2, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.cross_entropy_loss, ptr %137, i32 0, i32 0
  %139 = load ptr, ptr %138, align 8, !tbaa !11
  %140 = load i32, ptr %3, align 4, !tbaa !9
  %141 = call ptr @get_row(ptr noundef %139, i32 noundef %140)
  store ptr %141, ptr %4, align 8, !tbaa !5
  %142 = load ptr, ptr %4, align 8, !tbaa !5
  %143 = call double @logsumexp_d(ptr noundef %142)
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.matrix, ptr %144, i32 0, i32 3
  %146 = load ptr, ptr %145, align 8, !tbaa !16
  %147 = load i32, ptr %3, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds double, ptr %146, i64 %148
  store double %143, ptr %149, align 8, !tbaa !21
  %150 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free_matrix(ptr noundef %150)
  br label %152

151:                                              ; preds = %51
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 58, ptr noundef @__PRETTY_FUNCTION__.compute_cross_entropy_loss) #5
  unreachable

152:                                              ; preds = %104, %57, %51
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %3, align 4, !tbaa !9
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %3, align 4, !tbaa !9
  br label %43, !llvm.loop !23

156:                                              ; preds = %43
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  %158 = load ptr, ptr %6, align 8, !tbaa !5
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  call void @matrix_add(ptr noundef %157, ptr noundef %158, ptr noundef %159)
  %160 = load ptr, ptr %7, align 8, !tbaa !5
  %161 = load ptr, ptr %8, align 8, !tbaa !5
  call void @matrix_sum_up(ptr noundef %160, ptr noundef %161)
  %162 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free_matrix(ptr noundef %162)
  %163 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free_matrix(ptr noundef %163)
  %164 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free_matrix(ptr noundef %164)
  %165 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret ptr %165
}

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

declare ptr @kml_calloc(i64 noundef, i64 noundef) #2

declare ptr @allocate_matrix(i32 noundef, i32 noundef, i32 noundef) #2

declare ptr @get_row(ptr noundef, i32 noundef) #2

declare float @logsumexp(ptr noundef) #2

declare void @free_matrix(ptr noundef) #2

declare double @logsumexp_d(ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare void @matrix_add(ptr noundef, ptr noundef, ptr noundef) #2

declare void @matrix_sum_up(ptr noundef, ptr noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = { nounwind }
attributes #5 = { noreturn 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, !6, i64 0}
!12 = !{!"cross_entropy_loss", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!14, !10, i64 0}
!14 = !{!"matrix", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16}
!15 = !{!14, !10, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!14, !10, i64 4}
!18 = !{!12, !6, i64 8}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"double", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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"

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__.compute_cross_entropy_loss = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @compute_cross_entropy_loss(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = tail call ptr @kml_calloc(i64 noundef 1, i64 noundef 8) #3
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = load i32, ptr %3, align 8, !tbaa !10
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !13
  %7 = tail call ptr @allocate_matrix(i32 noundef %4, i32 noundef 1, i32 noundef %6) #3
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %9 = load i32, ptr %8, align 8, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = tail call ptr @allocate_matrix(i32 noundef %9, i32 noundef 1, i32 noundef %11) #3
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 8, !tbaa !10
  %15 = getelementptr inbounds i8, ptr %13, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = tail call ptr @allocate_matrix(i32 noundef %14, i32 noundef 1, i32 noundef %16) #3
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = load i32, ptr %18, align 8, !tbaa !10
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = getelementptr inbounds i8, ptr %7, i64 16
  %23 = getelementptr inbounds i8, ptr %12, i64 16
  br label %24

24:                                               ; preds = %.lr.ph, %75
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %75 ]
  %25 = phi ptr [ %18, %.lr.ph ], [ %76, %75 ]
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load i32, ptr %26, align 8, !tbaa !13
  switch i32 %27, label %75 [
    i32 1, label %28
    i32 2, label %51
    i32 0, label %74
  ]

28:                                               ; preds = %24
  %29 = getelementptr inbounds i8, ptr %25, i64 16
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %25, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = trunc nuw nsw i64 %indvars.iv to i32
  %34 = mul nsw i32 %32, %33
  %35 = load ptr, ptr %21, align 8, !tbaa !16
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds i32, ptr %37, i64 %indvars.iv
  %39 = load i32, ptr %38, align 4, !tbaa !17
  %40 = add nsw i32 %39, %34
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %30, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !18
  %44 = fneg float %43
  %45 = load ptr, ptr %22, align 8, !tbaa !14
  %46 = getelementptr inbounds float, ptr %45, i64 %indvars.iv
  store float %44, ptr %46, align 4, !tbaa !18
  %47 = tail call ptr @get_row(ptr noundef nonnull %25, i32 noundef %33) #3
  %48 = tail call float @logsumexp(ptr noundef %47) #3
  %49 = load ptr, ptr %23, align 8, !tbaa !14
  %50 = getelementptr inbounds float, ptr %49, i64 %indvars.iv
  store float %48, ptr %50, align 4, !tbaa !18
  br label %.sink.split

51:                                               ; preds = %24
  %52 = getelementptr inbounds i8, ptr %25, i64 16
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = getelementptr inbounds i8, ptr %25, i64 4
  %55 = load i32, ptr %54, align 4, !tbaa !15
  %56 = trunc nuw nsw i64 %indvars.iv to i32
  %57 = mul nsw i32 %55, %56
  %58 = load ptr, ptr %21, align 8, !tbaa !16
  %59 = getelementptr inbounds i8, ptr %58, i64 16
  %60 = load ptr, ptr %59, align 8, !tbaa !14
  %61 = getelementptr inbounds i32, ptr %60, i64 %indvars.iv
  %62 = load i32, ptr %61, align 4, !tbaa !17
  %63 = add nsw i32 %62, %57
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %53, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !20
  %67 = fneg double %66
  %68 = load ptr, ptr %22, align 8, !tbaa !14
  %69 = getelementptr inbounds double, ptr %68, i64 %indvars.iv
  store double %67, ptr %69, align 8, !tbaa !20
  %70 = tail call ptr @get_row(ptr noundef nonnull %25, i32 noundef %56) #3
  %71 = tail call double @logsumexp_d(ptr noundef %70) #3
  %72 = load ptr, ptr %23, align 8, !tbaa !14
  %73 = getelementptr inbounds double, ptr %72, i64 %indvars.iv
  store double %71, ptr %73, align 8, !tbaa !20
  br label %.sink.split

74:                                               ; preds = %24
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 58, ptr noundef nonnull @__PRETTY_FUNCTION__.compute_cross_entropy_loss) #4
  unreachable

.sink.split:                                      ; preds = %51, %28
  %.sink = phi ptr [ %47, %28 ], [ %70, %51 ]
  tail call void @free_matrix(ptr noundef %.sink) #3
  br label %75

75:                                               ; preds = %.sink.split, %24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %76 = load ptr, ptr %0, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 8, !tbaa !10
  %78 = sext i32 %77 to i64
  %79 = icmp slt i64 %indvars.iv.next, %78
  br i1 %79, label %24, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %75, %1
  tail call void @matrix_add(ptr noundef %7, ptr noundef %12, ptr noundef %17) #3
  tail call void @matrix_sum_up(ptr noundef %17, ptr noundef %2) #3
  tail call void @free_matrix(ptr noundef %7) #3
  tail call void @free_matrix(ptr noundef %12) #3
  tail call void @free_matrix(ptr noundef %17) #3
  ret ptr %2
}

declare ptr @kml_calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

declare ptr @allocate_matrix(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare ptr @get_row(ptr noundef, i32 noundef) local_unnamed_addr #1

declare float @logsumexp(ptr noundef) local_unnamed_addr #1

declare void @free_matrix(ptr noundef) local_unnamed_addr #1

declare double @logsumexp_d(ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @matrix_add(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @matrix_sum_up(ptr noundef, ptr noundef) local_unnamed_addr #1

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 = { "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 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 #3 = { nounwind }
attributes #4 = { noreturn 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 = !{!"cross_entropy_loss", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 0}
!11 = !{!"matrix", !12, i64 0, !12, i64 4, !12, i64 8, !8, i64 16}
!12 = !{!"int", !8, i64 0}
!13 = !{!11, !12, i64 8}
!14 = !{!8, !8, i64 0}
!15 = !{!11, !12, i64 4}
!16 = !{!6, !7, i64 8}
!17 = !{!12, !12, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !8, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !8, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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