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

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

%class.ImageContent = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@patch_mask = external global ptr, align 8

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_Z15computMoment012P12ImageContenti(ptr noundef %0, i32 noundef %1) #2 {
  %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) #3
  store float 0.000000e+00, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %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 = %68, %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) #3
  br label %71

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %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 = %64, %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) #3
  br label %67

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 %63

27:                                               ; preds = %24
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sitofp i32 %28 to float
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.ImageContent, ptr %30, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = add nsw i32 %33, %34
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %32, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = add nsw i32 %39, %40
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %38, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !11
  %45 = fmul float %29, %44
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %class.ImageContent, ptr %46, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = add nsw i32 %49, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %48, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !9
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = add nsw i32 %55, %56
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %54, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !11
  %61 = load float, ptr %5, align 4, !tbaa !11
  %62 = call float @llvm.fmuladd.f32(float %45, float %60, float %61)
  store float %62, ptr %5, align 4, !tbaa !11
  br label %63

63:                                               ; preds = %27, %24
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %8, align 4, !tbaa !9
  br label %19, !llvm.loop !15

67:                                               ; preds = %23
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !17

71:                                               ; preds = %15
  %72 = 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) #3
  ret float %72
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"_ZTS12ImageContent", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef float @_Z15computMoment012P12ImageContenti(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not28 = icmp slt i32 %1, 0
  %3 = load ptr, ptr @patch_mask, align 8
  %.not24 = icmp eq ptr %3, null
  %or.cond = select i1 %.not28, i1 true, i1 %.not24
  br i1 %or.cond, label %._crit_edge31, label %.preheader.lr.ph.split.split

.preheader.lr.ph.split.split:                     ; preds = %2
  %4 = sub nsw i32 0, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = sext i32 %4 to i64
  %8 = zext nneg i32 %1 to i64
  %9 = add nuw i32 %1, 1
  %invariant.gep47 = getelementptr ptr, ptr %6, i64 %8
  %10 = shl nuw i32 %1, 1
  %11 = and i32 %10, 2
  %12 = icmp ult i32 %1, 2
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph.split.split, %._crit_edge.split
  %indvars.iv42 = phi i64 [ %7, %.preheader.lr.ph.split.split ], [ %indvars.iv.next43, %._crit_edge.split ]
  %.02129 = phi float [ 0.000000e+00, %.preheader.lr.ph.split.split ], [ %.lcssa, %._crit_edge.split ]
  %gep48 = getelementptr ptr, ptr %invariant.gep47, i64 %indvars.iv42
  %13 = load ptr, ptr %gep48, align 8, !tbaa !11
  %invariant.gep = getelementptr float, ptr %13, i64 %8
  br label %14

14:                                               ; preds = %14, %.preheader
  %indvars.iv.prol = phi i64 [ %7, %.preheader ], [ %indvars.iv.next.prol, %14 ]
  %.126.prol = phi float [ %.02129, %.preheader ], [ %19, %14 ]
  %prol.iter = phi i32 [ 0, %.preheader ], [ %prol.iter.next, %14 ]
  %15 = trunc nsw i64 %indvars.iv.prol to i32
  %16 = sitofp i32 %15 to float
  %gep.prol = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.prol
  %17 = load float, ptr %gep.prol, align 4, !tbaa !12
  %18 = fmul float %17, %16
  %19 = tail call float @llvm.fmuladd.f32(float %18, float %17, float %.126.prol)
  %indvars.iv.next.prol = add nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter, %11
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %14, !llvm.loop !14

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

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

._crit_edge.split:                                ; preds = %.preheader.new, %.prol.loopexit
  %.lcssa = phi float [ %19, %.prol.loopexit ], [ %39, %.preheader.new ]
  %indvars.iv.next43 = add nsw i64 %indvars.iv42, 1
  %lftr.wideiv45 = trunc i64 %indvars.iv.next43 to i32
  %exitcond46.not = icmp eq i32 %9, %lftr.wideiv45
  br i1 %exitcond46.not, label %._crit_edge31, label %.preheader, !llvm.loop !16

.preheader.new:                                   ; preds = %.prol.loopexit, %.preheader.new
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.preheader.new ], [ %indvars.iv.next.prol, %.prol.loopexit ]
  %.126 = phi float [ %39, %.preheader.new ], [ %19, %.prol.loopexit ]
  %20 = trunc nsw i64 %indvars.iv to i32
  %21 = sitofp i32 %20 to float
  %gep = getelementptr float, ptr %invariant.gep, i64 %indvars.iv
  %22 = load float, ptr %gep, align 4, !tbaa !12
  %23 = fmul float %22, %21
  %24 = tail call float @llvm.fmuladd.f32(float %23, float %22, float %.126)
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %25 = trunc nsw i64 %indvars.iv.next to i32
  %26 = sitofp i32 %25 to float
  %gep.1 = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.next
  %27 = load float, ptr %gep.1, align 4, !tbaa !12
  %28 = fmul float %27, %26
  %29 = tail call float @llvm.fmuladd.f32(float %28, float %27, float %24)
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %30 = trunc nsw i64 %indvars.iv.next.1 to i32
  %31 = sitofp i32 %30 to float
  %gep.2 = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.next.1
  %32 = load float, ptr %gep.2, align 4, !tbaa !12
  %33 = fmul float %32, %31
  %34 = tail call float @llvm.fmuladd.f32(float %33, float %32, float %29)
  %indvars.iv.next.2 = add nsw i64 %indvars.iv, 3
  %35 = trunc nsw i64 %indvars.iv.next.2 to i32
  %36 = sitofp i32 %35 to float
  %gep.3 = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.next.2
  %37 = load float, ptr %gep.3, align 4, !tbaa !12
  %38 = fmul float %37, %36
  %39 = tail call float @llvm.fmuladd.f32(float %38, float %37, float %34)
  %indvars.iv.next.3 = add nsw i64 %indvars.iv, 4
  %lftr.wideiv.3 = trunc i64 %indvars.iv.next.3 to i32
  %exitcond.not.3 = icmp eq i32 %9, %lftr.wideiv.3
  br i1 %exitcond.not.3, label %._crit_edge.split, label %.preheader.new, !llvm.loop !18
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, 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 = !{!6, !10, i64 16}
!6 = !{!"_ZTS12ImageContent", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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