; LLVM IR from ox-vgg/vise :: src/search_engine/relja_retrival/external/KMCode_relja/descriptor/MomentDescrip_37b75b5b (Z15computMoment000P12ImageContenti)

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

@patch_mask = external global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_Z15computMoment000P12ImageContenti(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store float 0.000000e+00, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = sub nsw i32 0, %9
  store i32 %10, ptr %6, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %35, %2
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %38

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = sub nsw i32 0, %17
  store i32 %18, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %31, %16
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %34

24:                                               ; preds = %19
  %25 = load ptr, ptr @patch_mask, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load float, ptr %5, align 4, !tbaa !11
  %29 = fadd float %28, 1.000000e+00
  store float %29, ptr %5, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %27, %24
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %8, align 4, !tbaa !9
  br label %19, !llvm.loop !13

34:                                               ; preds = %23
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !15

38:                                               ; preds = %15
  %39 = load float, ptr %5, align 4, !tbaa !11
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret float %39
}

; 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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@patch_mask = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef float @_Z15computMoment000P12ImageContenti(ptr nocapture noundef readnone %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = sub nsw i32 0, %1
  %.not17 = icmp slt i32 %1, 0
  %4 = load ptr, ptr @patch_mask, align 8
  %.fr = freeze ptr %4
  %.not13 = icmp eq ptr %.fr, null
  %or.cond = or i1 %.not17, %.not13
  br i1 %or.cond, label %._crit_edge20, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %5 = shl nuw i32 %1, 1
  %6 = and i32 %5, 6
  %7 = icmp ult i32 %1, 4
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge.split
  %.0919 = phi i32 [ %11, %._crit_edge.split ], [ %3, %.preheader.preheader ]
  %.01018 = phi float [ %.lcssa, %._crit_edge.split ], [ 0.000000e+00, %.preheader.preheader ]
  br label %8

8:                                                ; preds = %8, %.preheader
  %.016.prol = phi i32 [ %3, %.preheader ], [ %10, %8 ]
  %.115.prol = phi float [ %.01018, %.preheader ], [ %9, %8 ]
  %prol.iter = phi i32 [ 0, %.preheader ], [ %prol.iter.next, %8 ]
  %9 = fadd float %.115.prol, 1.000000e+00
  %10 = add i32 %.016.prol, 1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter, %6
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %8, !llvm.loop !5

.prol.loopexit:                                   ; preds = %8
  br i1 %7, label %._crit_edge.split, label %.preheader.new

._crit_edge20:                                    ; preds = %._crit_edge.split, %2
  %.010.lcssa = phi float [ 0.000000e+00, %2 ], [ %.lcssa, %._crit_edge.split ]
  ret float %.010.lcssa

._crit_edge.split:                                ; preds = %.preheader.new, %.prol.loopexit
  %.lcssa = phi float [ %9, %.prol.loopexit ], [ %20, %.preheader.new ]
  %11 = add i32 %.0919, 1
  %exitcond30.not = icmp eq i32 %.0919, %1
  br i1 %exitcond30.not, label %._crit_edge20, label %.preheader, !llvm.loop !7

.preheader.new:                                   ; preds = %.prol.loopexit, %.preheader.new
  %.016 = phi i32 [ %21, %.preheader.new ], [ %10, %.prol.loopexit ]
  %.115 = phi float [ %20, %.preheader.new ], [ %9, %.prol.loopexit ]
  %12 = fadd float %.115, 1.000000e+00
  %13 = fadd float %12, 1.000000e+00
  %14 = fadd float %13, 1.000000e+00
  %15 = fadd float %14, 1.000000e+00
  %16 = fadd float %15, 1.000000e+00
  %17 = fadd float %16, 1.000000e+00
  %18 = fadd float %17, 1.000000e+00
  %19 = add i32 %.016, 7
  %20 = fadd float %18, 1.000000e+00
  %21 = add i32 %.016, 8
  %exitcond.not.7 = icmp eq i32 %19, %1
  br i1 %exitcond.not.7, label %._crit_edge.split, label %.preheader.new, !llvm.loop !9
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.unroll.disable"}
!7 = distinct !{!7, !8}
!8 = !{!"llvm.loop.mustprogress"}
!9 = distinct !{!9, !8}


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