; LLVM IR from ggml-org/ggml :: examples/yolo/yolo-image.ll (Z10draw_labelR10yolo_imageiiRKS_PKf)

; 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.yolo_image = type { i32, i32, i32, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10draw_labelR10yolo_imageiiRKS_PKf(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.yolo_image, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !11
  store i32 %20, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.yolo_image, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !17
  store i32 %23, ptr %12, align 4, !tbaa !9
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = sub nsw i32 %24, %25
  %27 = icmp sge i32 %26, 0
  br i1 %27, label %28, label %32

28:                                               ; preds = %5
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = load i32, ptr %12, align 4, !tbaa !9
  %31 = sub nsw i32 %29, %30
  store i32 %31, ptr %7, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %28, %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %101, %32
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %45

37:                                               ; preds = %33
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = add nsw i32 %38, %39
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.yolo_image, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = icmp slt i32 %40, %43
  br label %45

45:                                               ; preds = %37, %33
  %46 = phi i1 [ false, %33 ], [ %44, %37 ]
  br i1 %46, label %48, label %47

47:                                               ; preds = %45
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %104

48:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %97, %48
  %50 = load i32, ptr %15, align 4, !tbaa !9
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %53, label %61

53:                                               ; preds = %49
  %54 = load i32, ptr %15, align 4, !tbaa !9
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = add nsw i32 %54, %55
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.yolo_image, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = icmp slt i32 %56, %59
  br label %61

61:                                               ; preds = %53, %49
  %62 = phi i1 [ false, %49 ], [ %60, %53 ]
  br i1 %62, label %64, label %63

63:                                               ; preds = %61
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %100

64:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %93, %64
  %66 = load i32, ptr %16, align 4, !tbaa !9
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.yolo_image, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 8, !tbaa !18
  %70 = icmp slt i32 %66, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %65
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %96

72:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = load i32, ptr %15, align 4, !tbaa !9
  %75 = load i32, ptr %13, align 4, !tbaa !9
  %76 = load i32, ptr %16, align 4, !tbaa !9
  %77 = call noundef float @_ZNK10yolo_image9get_pixelEiii(ptr noundef nonnull align 8 dereferenceable(40) %73, i32 noundef %74, i32 noundef %75, i32 noundef %76)
  store float %77, ptr %17, align 4, !tbaa !19
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = load i32, ptr %15, align 4, !tbaa !9
  %80 = load i32, ptr %8, align 4, !tbaa !9
  %81 = add nsw i32 %79, %80
  %82 = load i32, ptr %13, align 4, !tbaa !9
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = add nsw i32 %82, %83
  %85 = load i32, ptr %16, align 4, !tbaa !9
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load i32, ptr %16, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %86, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !19
  %91 = load float, ptr %17, align 4, !tbaa !19
  %92 = fmul float %90, %91
  call void @_ZN10yolo_image9set_pixelEiiif(ptr noundef nonnull align 8 dereferenceable(40) %78, i32 noundef %81, i32 noundef %84, i32 noundef %85, float noundef %92)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %93

93:                                               ; preds = %72
  %94 = load i32, ptr %16, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %16, align 4, !tbaa !9
  br label %65, !llvm.loop !21

96:                                               ; preds = %71
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %15, align 4, !tbaa !9
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %15, align 4, !tbaa !9
  br label %49, !llvm.loop !23

100:                                              ; preds = %63
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %13, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %13, align 4, !tbaa !9
  br label %33, !llvm.loop !24

104:                                              ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK10yolo_image9get_pixelEiii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10yolo_image9set_pixelEiiif(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef, float noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS10yolo_image", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16}
!13 = !{!"_ZTSSt6vectorIfSaIfEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!12, !10, i64 4}
!18 = !{!12, !10, i64 8}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = distinct !{!24, !22}


; 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z10draw_labelR10yolo_imageiiRKS_PKf(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(40) %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = load i32, ptr %3, align 8, !tbaa !5
  %.fr51 = freeze i32 %6
  %7 = getelementptr inbounds i8, ptr %3, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !15
  %9 = sub nsw i32 %1, %8
  %10 = icmp slt i32 %9, 0
  %spec.select = select i1 %10, i32 %1, i32 %9
  %11 = icmp sgt i32 %8, 0
  br i1 %11, label %.lr.ph48, label %.critedge

.lr.ph48:                                         ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = icmp sgt i32 %.fr51, 0
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  br i1 %13, label %.lr.ph48.split.us, label %.critedge

.lr.ph48.split.us:                                ; preds = %.lr.ph48, %.critedge2.us
  %.03746.us = phi i32 [ %21, %.critedge2.us ], [ 0, %.lr.ph48 ]
  %15 = add nsw i32 %.03746.us, %spec.select
  %16 = load i32, ptr %12, align 4, !tbaa !15
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %.preheader41.us, label %.critedge

.preheader41.us:                                  ; preds = %.lr.ph48.split.us, %._crit_edge.us
  %.03643.us = phi i32 [ %22, %._crit_edge.us ], [ 0, %.lr.ph48.split.us ]
  %18 = add nsw i32 %.03643.us, %2
  %19 = load i32, ptr %0, align 8, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %.preheader.us, label %.critedge2.us

.critedge2.us:                                    ; preds = %.preheader41.us, %._crit_edge.us
  %21 = add nuw nsw i32 %.03746.us, 1
  %exitcond54.not = icmp eq i32 %21, %8
  br i1 %exitcond54.not, label %.critedge, label %.lr.ph48.split.us, !llvm.loop !16

._crit_edge.us:                                   ; preds = %.lr.ph.us, %.preheader.us
  %22 = add nuw nsw i32 %.03643.us, 1
  %exitcond.not = icmp eq i32 %22, %.fr51
  br i1 %exitcond.not, label %.critedge2.us, label %.preheader41.us, !llvm.loop !18

.lr.ph.us:                                        ; preds = %.preheader.us, %.lr.ph.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.us ], [ 0, %.preheader.us ]
  %23 = trunc nuw nsw i64 %indvars.iv to i32
  %24 = tail call noundef float @_ZNK10yolo_image9get_pixelEiii(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef %.03643.us, i32 noundef %.03746.us, i32 noundef %23)
  %25 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  %26 = load float, ptr %25, align 4, !tbaa !19
  %27 = fmul float %24, %26
  tail call void @_ZN10yolo_image9set_pixelEiiif(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %18, i32 noundef %15, i32 noundef %23, float noundef %27)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %14, align 8, !tbaa !21
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next, %29
  br i1 %30, label %.lr.ph.us, label %._crit_edge.us, !llvm.loop !22

.preheader.us:                                    ; preds = %.preheader41.us
  %31 = load i32, ptr %14, align 8, !tbaa !21
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph.us, label %._crit_edge.us

.critedge:                                        ; preds = %.lr.ph48.split.us, %.critedge2.us, %.lr.ph48, %5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK10yolo_image9get_pixelEiii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10yolo_image9set_pixelEiiif(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef, float noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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" }

!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 = !{!"_ZTS10yolo_image", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIfSaIfEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !7, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !8, i64 0}
!21 = !{!6, !7, i64 8}
!22 = distinct !{!22, !17}


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