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

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZN15CSiftDescriptor12PlaceInIndexEPfffff(ptr noundef nonnull align 8 dereferenceable(116), ptr noundef, float noundef, float noundef, float noundef, float noundef) #0 align 2

; 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

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

29:                                               ; preds = %10
  %30 = load i32, ptr %15, align 4, !tbaa !9
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = call noundef i32 @_ZNK12ImageContent1yEv(ptr noundef nonnull align 8 dereferenceable(80) %31)
  %33 = icmp uge i32 %30, %32
  br i1 %33, label %42, label %34

34:                                               ; preds = %29
  %35 = load i32, ptr %16, align 4, !tbaa !9
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %42, label %37

37:                                               ; preds = %34
  %38 = load i32, ptr %16, align 4, !tbaa !9
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = call noundef i32 @_ZNK12ImageContent1xEv(ptr noundef nonnull align 8 dereferenceable(80) %39)
  %41 = icmp uge i32 %38, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %37, %34, %29, %10
  store i32 1, ptr %25, align 4
  br label %103

43:                                               ; preds = %37
  %44 = load ptr, ptr @patch_mask, align 8, !tbaa !5
  %45 = getelementptr inbounds %class.ImageContent, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds ptr, ptr %46, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = load i32, ptr %16, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %50, i64 %52
  %54 = load float, ptr %53, align 4, !tbaa !11
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = getelementptr inbounds %class.ImageContent, ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = load i32, ptr %15, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = load i32, ptr %16, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds float, ptr %61, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !11
  %66 = fmul float %54, %65
  store float %66, ptr %21, align 4, !tbaa !11
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = getelementptr inbounds %class.ImageContent, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  %70 = load i32, ptr %15, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load i32, ptr %16, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds float, ptr %73, i64 %75
  %77 = load float, ptr %76, align 4, !tbaa !11
  store float %77, ptr %22, align 4, !tbaa !11
  br label %78

78:                                               ; preds = %82, %43
  %79 = load float, ptr %22, align 4, !tbaa !11
  %80 = fpext float %79 to double
  %81 = fcmp ogt double %80, 0x401921FB544486E0
  br i1 %81, label %82, label %87

82:                                               ; preds = %78
  %83 = load float, ptr %22, align 4, !tbaa !11
  %84 = fpext float %83 to double
  %85 = fsub double %84, 0x401921FB544486E0
  %86 = fptrunc double %85 to float
  store float %86, ptr %22, align 4, !tbaa !11
  br label %78, !llvm.loop !15

87:                                               ; preds = %78
  br label %88

88:                                               ; preds = %92, %87
  %89 = load float, ptr %22, align 4, !tbaa !11
  %90 = fpext float %89 to double
  %91 = fcmp olt double %90, 0.000000e+00
  br i1 %91, label %92, label %97

92:                                               ; preds = %88
  %93 = load float, ptr %22, align 4, !tbaa !11
  %94 = fpext float %93 to double
  %95 = fadd double %94, 0x401921FB544486E0
  %96 = fptrunc double %95 to float
  store float %96, ptr %22, align 4, !tbaa !11
  br label %88, !llvm.loop !17

97:                                               ; preds = %88
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = load float, ptr %21, align 4, !tbaa !11
  %100 = load float, ptr %22, align 4, !tbaa !11
  %101 = load float, ptr %17, align 4, !tbaa !11
  %102 = load float, ptr %18, align 4, !tbaa !11
  call void @_ZN15CSiftDescriptor12PlaceInIndexEPfffff(ptr noundef nonnull align 8 dereferenceable(116) %26, ptr noundef %98, float noundef %99, float noundef %100, float noundef %101, float noundef %102)
  store i32 0, ptr %25, align 4
  br label %103

103:                                              ; preds = %97, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  %104 = load i32, ptr %25, align 4
  switch i32 %104, label %106 [
    i32 0, label %105
    i32 1, label %105
  ]

105:                                              ; preds = %103, %103
  ret void

106:                                              ; preds = %103
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12ImageContent1yEv(ptr noundef nonnull align 8 dereferenceable(80)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12ImageContent1xEv(ptr noundef nonnull align 8 dereferenceable(80)) #3 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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint 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 #4 = { 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 nounwind uwtable
declare dso_local void @_ZN15CSiftDescriptor12PlaceInIndexEPfffff(ptr noundef nonnull align 8 dereferenceable(116), ptr noundef, float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN15CSiftDescriptor9AddSampleEPfP12ImageContentS2_iiffff(ptr noundef nonnull align 8 dereferenceable(116) %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3, i32 noundef %4, i32 noundef %5, float noundef %6, float noundef %7, float noundef %8, float noundef %9) local_unnamed_addr #0 align 2 {
  %11 = icmp slt i32 %4, 0
  br i1 %11, label %53, label %12

12:                                               ; preds = %10
  %13 = tail call noundef i32 @_ZNK12ImageContent1yEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %14 = icmp ule i32 %13, %4
  %15 = icmp slt i32 %5, 0
  %or.cond = or i1 %15, %14
  br i1 %or.cond, label %53, label %16

16:                                               ; preds = %12
  %17 = tail call noundef i32 @_ZNK12ImageContent1xEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %.not = icmp ugt i32 %17, %5
  br i1 %.not, label %18, label %53

18:                                               ; preds = %16
  %19 = load ptr, ptr @patch_mask, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = zext nneg i32 %4 to i64
  %23 = getelementptr inbounds ptr, ptr %21, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = zext nneg i32 %5 to i64
  %26 = getelementptr inbounds float, ptr %24, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %2, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %29, i64 %22
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds float, ptr %31, i64 %25
  %33 = load float, ptr %32, align 4, !tbaa !12
  %34 = fmul float %27, %33
  %35 = getelementptr inbounds i8, ptr %3, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %36, i64 %22
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds float, ptr %38, i64 %25
  %40 = load float, ptr %39, align 4, !tbaa !12
  %41 = fpext float %40 to double
  %42 = fcmp ogt double %41, 0x401921FB544486E0
  br i1 %42, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %18
  %.0.lcssa = phi float [ %40, %18 ], [ %46, %.lr.ph ]
  %43 = fcmp olt float %.0.lcssa, 0.000000e+00
  br i1 %43, label %.lr.ph29, label %._crit_edge

.lr.ph:                                           ; preds = %18, %.lr.ph
  %44 = phi double [ %47, %.lr.ph ], [ %41, %18 ]
  %45 = fadd double %44, 0xC01921FB544486E0
  %46 = fptrunc double %45 to float
  %47 = fpext float %46 to double
  %48 = fcmp ogt double %47, 0x401921FB544486E0
  br i1 %48, label %.lr.ph, label %.preheader, !llvm.loop !14

.lr.ph29:                                         ; preds = %.preheader, %.lr.ph29
  %.128 = phi float [ %51, %.lr.ph29 ], [ %.0.lcssa, %.preheader ]
  %49 = fpext float %.128 to double
  %50 = fadd double %49, 0x401921FB544486E0
  %51 = fptrunc double %50 to float
  %52 = fcmp olt float %51, 0.000000e+00
  br i1 %52, label %.lr.ph29, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph29, %.preheader
  %.1.lcssa = phi float [ %.0.lcssa, %.preheader ], [ %51, %.lr.ph29 ]
  tail call void @_ZN15CSiftDescriptor12PlaceInIndexEPfffff(ptr noundef nonnull align 8 dereferenceable(116) %0, ptr noundef %1, float noundef %34, float noundef %.1.lcssa, float noundef %6, float noundef %7)
  br label %53

53:                                               ; preds = %10, %12, %16, %._crit_edge
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12ImageContent1yEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK12ImageContent1xEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 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" }
attributes #1 = { inlinehint 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"_ZTS12ImageContent", !11, i64 0, !11, i64 4, !11, i64 8, !11, 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}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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