; LLVM IR from ox-vgg/vise :: src/search_engine/relja_retrival/external/KMCode_relja/descriptor/ComplexGauss._049601d2 (Z3K22iiP12ImageContent)

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

@_ZL5ksize = external hidden global i32, align 4
@_ZL4Kr22 = external hidden global <{ <{ [21 x double], [20 x double] }>, <{ [27 x double], [14 x double] }>, <{ [29 x double], [12 x double] }>, <{ [31 x double], [10 x double] }>, <{ [33 x double], [8 x double] }>, [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], <{ [33 x double], [8 x double] }>, <{ [31 x double], [10 x double] }>, <{ [29 x double], [12 x double] }>, <{ [27 x double], [14 x double] }>, <{ [21 x double], [20 x double] }> }>, align 16

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

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

13:                                               ; preds = %60, %3
  %14 = load i32, ptr %8, align 4, !tbaa !5
  %15 = load i32, ptr @_ZL5ksize, align 4, !tbaa !5
  %16 = icmp sle i32 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %63

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %19 = load i32, ptr @_ZL5ksize, align 4, !tbaa !5
  %20 = sub nsw i32 0, %19
  store i32 %20, ptr %10, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %56, %18
  %22 = load i32, ptr %10, align 4, !tbaa !5
  %23 = load i32, ptr @_ZL5ksize, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %59

26:                                               ; preds = %21
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = getelementptr inbounds %class.ImageContent, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = add nsw i32 %30, %31
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds ptr, ptr %29, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = add nsw i32 %36, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %35, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !15
  %42 = fpext float %41 to double
  %43 = load i32, ptr %10, align 4, !tbaa !5
  %44 = load i32, ptr @_ZL5ksize, align 4, !tbaa !5
  %45 = add nsw i32 %43, %44
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [41 x [41 x double]], ptr @_ZL4Kr22, i64 0, i64 %46
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = load i32, ptr @_ZL5ksize, align 4, !tbaa !5
  %50 = add nsw i32 %48, %49
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [41 x double], ptr %47, i64 0, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !11
  %54 = load double, ptr %7, align 8, !tbaa !11
  %55 = call double @llvm.fmuladd.f64(double %42, double %53, double %54)
  store double %55, ptr %7, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %26
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %10, align 4, !tbaa !5
  br label %21, !llvm.loop !17

59:                                               ; preds = %25
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %8, align 4, !tbaa !5
  br label %13, !llvm.loop !19

63:                                               ; preds = %17
  %64 = load double, ptr %7, align 8, !tbaa !11
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret double %64
}

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


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

@_ZL5ksize = external hidden local_unnamed_addr global i32, align 4
@_ZL4Kr22 = external hidden local_unnamed_addr global <{ <{ [21 x double], [20 x double] }>, <{ [27 x double], [14 x double] }>, <{ [29 x double], [12 x double] }>, <{ [31 x double], [10 x double] }>, <{ [33 x double], [8 x double] }>, [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], [41 x double], <{ [33 x double], [8 x double] }>, <{ [31 x double], [10 x double] }>, <{ [29 x double], [12 x double] }>, <{ [27 x double], [14 x double] }>, <{ [21 x double], [20 x double] }> }>, align 16

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef double @_Z3K22iiP12ImageContent(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %4 = load i32, ptr @_ZL5ksize, align 4, !tbaa !5
  %.not20 = icmp slt i32 %4, 0
  br i1 %.not20, label %._crit_edge23, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %3
  %5 = sub nsw i32 0, %4
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = sext i32 %5 to i64
  %9 = sext i32 %1 to i64
  %10 = zext nneg i32 %4 to i64
  %11 = add nuw i32 %4, 1
  %12 = sext i32 %0 to i64
  %invariant.gep = getelementptr ptr, ptr %7, i64 %9
  %gep.prol = getelementptr ptr, ptr %invariant.gep, i64 %8
  %13 = add nsw i64 %8, %10
  %indvars.iv.next.prol = add nsw i64 %8, 1
  %14 = icmp eq i32 %4, 0
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvars.iv26 = phi i64 [ %8, %.preheader.lr.ph ], [ %indvars.iv.next27, %._crit_edge ]
  %.01321 = phi double [ 0.000000e+00, %.preheader.lr.ph ], [ %.lcssa, %._crit_edge ]
  %15 = add nsw i64 %indvars.iv26, %10
  %16 = load ptr, ptr %gep.prol, align 8, !tbaa !12
  %17 = getelementptr float, ptr %16, i64 %indvars.iv26
  %18 = getelementptr float, ptr %17, i64 %12
  %19 = load float, ptr %18, align 4, !tbaa !13
  %20 = fpext float %19 to double
  %21 = getelementptr inbounds [41 x [41 x double]], ptr @_ZL4Kr22, i64 0, i64 %13, i64 %15
  %22 = load double, ptr %21, align 8, !tbaa !15
  %23 = tail call double @llvm.fmuladd.f64(double %20, double %22, double %.01321)
  br i1 %14, label %._crit_edge, label %.preheader.new

._crit_edge23:                                    ; preds = %._crit_edge, %3
  %.013.lcssa = phi double [ 0.000000e+00, %3 ], [ %.lcssa, %._crit_edge ]
  ret double %.013.lcssa

._crit_edge:                                      ; preds = %.preheader.new, %.preheader
  %.lcssa = phi double [ %23, %.preheader ], [ %41, %.preheader.new ]
  %indvars.iv.next27 = add nsw i64 %indvars.iv26, 1
  %lftr.wideiv29 = trunc i64 %indvars.iv.next27 to i32
  %exitcond30.not = icmp eq i32 %11, %lftr.wideiv29
  br i1 %exitcond30.not, label %._crit_edge23, label %.preheader, !llvm.loop !17

.preheader.new:                                   ; preds = %.preheader, %.preheader.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.preheader.new ], [ %indvars.iv.next.prol, %.preheader ]
  %.118 = phi double [ %41, %.preheader.new ], [ %23, %.preheader ]
  %gep = getelementptr ptr, ptr %invariant.gep, i64 %indvars.iv
  %24 = load ptr, ptr %gep, align 8, !tbaa !12
  %25 = getelementptr float, ptr %24, i64 %indvars.iv26
  %26 = getelementptr float, ptr %25, i64 %12
  %27 = load float, ptr %26, align 4, !tbaa !13
  %28 = fpext float %27 to double
  %29 = add nsw i64 %indvars.iv, %10
  %30 = getelementptr inbounds [41 x [41 x double]], ptr @_ZL4Kr22, i64 0, i64 %29, i64 %15
  %31 = load double, ptr %30, align 8, !tbaa !15
  %32 = tail call double @llvm.fmuladd.f64(double %28, double %31, double %.118)
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %gep.1 = getelementptr ptr, ptr %invariant.gep, i64 %indvars.iv.next
  %33 = load ptr, ptr %gep.1, align 8, !tbaa !12
  %34 = getelementptr float, ptr %33, i64 %indvars.iv26
  %35 = getelementptr float, ptr %34, i64 %12
  %36 = load float, ptr %35, align 4, !tbaa !13
  %37 = fpext float %36 to double
  %38 = add nsw i64 %indvars.iv.next, %10
  %39 = getelementptr inbounds [41 x [41 x double]], ptr @_ZL4Kr22, i64 0, i64 %38, i64 %15
  %40 = load double, ptr %39, align 8, !tbaa !15
  %41 = tail call double @llvm.fmuladd.f64(double %37, double %40, double %32)
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %lftr.wideiv.1 = trunc i64 %indvars.iv.next.1 to i32
  %exitcond.not.1 = icmp eq i32 %11, %lftr.wideiv.1
  br i1 %exitcond.not.1, label %._crit_edge, label %.preheader.new, !llvm.loop !19
}

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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"_ZTS12ImageContent", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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