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

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

; 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 nounwind uwtable
define dso_local noundef i32 @_Z15checkMaskHarrisP12ImageContentS0_iif(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store float %4, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.ImageContent, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %10, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds ptr, ptr %18, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds float, ptr %22, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !11
  store float %26, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = sub nsw i32 %27, 1
  store i32 %28, ptr %13, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %83, %5
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = add nsw i32 %31, 2
  %33 = icmp slt i32 %30, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %29
  store i32 2, ptr %14, align 4
  br label %86

35:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = sub nsw i32 %36, 1
  store i32 %37, ptr %15, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %77, %35
  %39 = load i32, ptr %15, align 4, !tbaa !9
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = add nsw i32 %40, 2
  %42 = icmp slt i32 %39, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %38
  store i32 5, ptr %14, align 4
  br label %80

44:                                               ; preds = %38
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.ImageContent, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = load i32, ptr %15, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %51, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !11
  %56 = fcmp ogt float %55, 0.000000e+00
  br i1 %56, label %57, label %71

57:                                               ; preds = %44
  %58 = load float, ptr %12, align 4, !tbaa !11
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %class.ImageContent, ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !11
  %70 = fcmp olt float %58, %69
  br i1 %70, label %75, label %71

71:                                               ; preds = %57, %44
  %72 = load float, ptr %12, align 4, !tbaa !11
  %73 = load float, ptr %11, align 4, !tbaa !11
  %74 = fcmp olt float %72, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %71, %57
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %80

76:                                               ; preds = %71
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %15, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %15, align 4, !tbaa !9
  br label %38, !llvm.loop !15

80:                                               ; preds = %75, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  %81 = load i32, ptr %14, align 4
  switch i32 %81, label %86 [
    i32 5, label %82
  ]

82:                                               ; preds = %80
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %13, align 4, !tbaa !9
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %13, align 4, !tbaa !9
  br label %29, !llvm.loop !17

86:                                               ; preds = %80, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  %87 = load i32, ptr %14, align 4
  switch i32 %87, label %89 [
    i32 2, label %88
  ]

88:                                               ; preds = %86
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %89

89:                                               ; preds = %88, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %90 = load i32, ptr %6, align 4
  ret i32 %90
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef i32 @_Z15checkMaskHarrisP12ImageContentS0_iif(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, float noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = sext i32 %3 to i64
  %9 = getelementptr inbounds ptr, ptr %7, i64 %8
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = sext i32 %2 to i64
  %12 = getelementptr inbounds float, ptr %10, i64 %11
  %13 = load float, ptr %12, align 4, !tbaa !12
  %.fr90 = freeze float %13
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %.old = fcmp olt float %.fr90, %4
  br i1 %.old, label %.loopexit, label %.split.preheader

.split.preheader:                                 ; preds = %5
  %16 = add i32 %2, 2
  %17 = add i32 %2, -1
  %18 = add i32 %3, 2
  %19 = add i32 %3, -1
  %20 = sext i32 %17 to i64
  %smax = tail call i32 @llvm.smax.i32(i32 %2, i32 %16)
  %21 = sext i32 %19 to i64
  %22 = sext i32 %18 to i64
  %smax102 = tail call i32 @llvm.smax.i32(i32 %3, i32 %18)
  br label %.split

.split:                                           ; preds = %.split.preheader, %.critedge.split.split
  %indvars.iv100 = phi i64 [ %21, %.split.preheader ], [ %indvars.iv.next101, %.critedge.split.split ]
  %.not2767 = phi i1 [ false, %.split.preheader ], [ %.not27, %.critedge.split.split ]
  %23 = getelementptr inbounds ptr, ptr %15, i64 %indvars.iv100
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv100
  br label %26

26:                                               ; preds = %.split, %35
  %indvars.iv = phi i64 [ %20, %.split ], [ %indvars.iv.next, %35 ]
  %27 = getelementptr inbounds float, ptr %24, i64 %indvars.iv
  %28 = load float, ptr %27, align 4, !tbaa !12
  %29 = fcmp ogt float %28, 0.000000e+00
  br i1 %29, label %30, label %35

30:                                               ; preds = %26
  %31 = load ptr, ptr %25, align 8, !tbaa !11
  %32 = getelementptr inbounds float, ptr %31, i64 %indvars.iv
  %33 = load float, ptr %32, align 4, !tbaa !12
  %34 = fcmp olt float %.fr90, %33
  br i1 %34, label %.loopexit, label %35

35:                                               ; preds = %26, %30
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %smax, %lftr.wideiv
  br i1 %exitcond.not, label %.critedge.split.split, label %26, !llvm.loop !14

.critedge.split.split:                            ; preds = %35
  %indvars.iv.next101 = add nsw i64 %indvars.iv100, 1
  %.not27 = icmp sge i64 %indvars.iv.next101, %22
  %lftr.wideiv103 = trunc i64 %indvars.iv.next101 to i32
  %exitcond104 = icmp eq i32 %smax102, %lftr.wideiv103
  br i1 %exitcond104, label %.loopexit, label %.split, !llvm.loop !16

.loopexit:                                        ; preds = %.critedge.split.split, %30, %5
  %.not2730 = phi i1 [ false, %5 ], [ %.not2767, %30 ], [ %.not27, %.critedge.split.split ]
  %spec.select = zext i1 %.not2730 to i32
  ret i32 %spec.select
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { 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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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.mustprogress"}
!16 = distinct !{!16, !15}


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