; LLVM IR from openxrlab/xrsfm :: 3rdparty/SiftGPU/SiftMatch.ll (ZN11SiftMatchGL12GetBestMatchEiPA2_jffi)

; 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.SiftMatchGL = type { %class.SiftMatchGPU.base, [4 x i8], [2 x %class.GLTexImage], [2 x %class.GLTexImage], %class.GLTexImage, [2 x %class.GLTexImage], ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [2 x i32], [2 x i32], [2 x i32], i32, i32, i32, i32, i32, %"class.std::vector" }
%class.SiftMatchGPU.base = type <{ ptr, i32, i32, ptr, i32 }>
%class.GLTexImage = type <{ ptr, i32, i32, i32, i32, i32, i32, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@__glewActiveTexture = external global ptr, align 8
@__glewUniform3f = external global ptr, align 8
@__glewUseProgram = external global ptr, align 8

declare i32 @glGetError() #0

; 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
declare dso_local void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

declare void @_ZN10GLTexImage7BindTexEv(ptr noundef nonnull align 8 dereferenceable(36)) #0

declare void @_ZN10GLTexImage11AttachToFBOEi(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) #0

declare void @_ZN10GLTexImage14FitTexViewPortEv(ptr noundef nonnull align 8 dereferenceable(36)) #0

declare void @_ZN10GLTexImage8DrawQuadEv(ptr noundef nonnull align 8 dereferenceable(36)) #0

declare void @_ZN10GLTexImage14UnbindMultiTexEi(i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11SiftMatchGL12GetBestMatchEiPA2_jffi(ptr noundef nonnull align 8 dereferenceable(464) %0, i32 noundef %1, ptr noundef %2, float noundef %3, float noundef %4, i32 noundef %5) #2 align 2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store float %3, ptr %11, align 4, !tbaa !11
  store float %4, ptr %12, align 4, !tbaa !11
  store i32 %5, ptr %13, align 4, !tbaa !9
  %21 = load ptr, ptr %8, align 8
  %22 = load ptr, ptr @__glewActiveTexture, align 8, !tbaa !5
  call void %22(i32 noundef 33984)
  %23 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 4
  call void @_ZN10GLTexImage7BindTexEv(ptr noundef nonnull align 8 dereferenceable(36) %23)
  %24 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 30
  %25 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %26 = getelementptr inbounds [2 x i32], ptr %25, i64 0, i64 0
  %27 = load i32, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %29 = getelementptr inbounds [2 x i32], ptr %28, i64 0, i64 1
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = add nsw i32 %27, %30
  %32 = add nsw i32 %31, 16
  %33 = sext i32 %32 to i64
  call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %33)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %34 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 30
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %34, i64 noundef 0) #4
  store ptr %35, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %36 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 30
  %37 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %38 = getelementptr inbounds [2 x i32], ptr %37, i64 0, i64 0
  %39 = load i32, ptr %38, align 8, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %40) #4
  store ptr %41, ptr %15, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %43 = getelementptr inbounds [2 x %class.GLTexImage], ptr %42, i64 0, i64 0
  call void @_ZN10GLTexImage11AttachToFBOEi(ptr noundef nonnull align 8 dereferenceable(36) %43, i32 noundef 0)
  %44 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %45 = getelementptr inbounds [2 x %class.GLTexImage], ptr %44, i64 0, i64 0
  %46 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %47 = getelementptr inbounds [2 x i32], ptr %46, i64 0, i64 0
  %48 = load i32, ptr %47, align 8, !tbaa !9
  %49 = add nsw i32 %48, 15
  %50 = sdiv i32 %49, 16
  %51 = load ptr, ptr %45, align 8, !tbaa !13
  %52 = getelementptr inbounds ptr, ptr %51, i64 5
  %53 = load ptr, ptr %52, align 8
  call void %53(ptr noundef nonnull align 8 dereferenceable(36) %45, i32 noundef 16, i32 noundef %50)
  %54 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %55 = getelementptr inbounds [2 x %class.GLTexImage], ptr %54, i64 0, i64 0
  call void @_ZN10GLTexImage14FitTexViewPortEv(ptr noundef nonnull align 8 dereferenceable(36) %55)
  %56 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 9
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = getelementptr inbounds ptr, ptr %58, i64 0
  %60 = load ptr, ptr %59, align 8
  %61 = call noundef i32 %60(ptr noundef nonnull align 8 dereferenceable(8) %57)
  %62 = load ptr, ptr @__glewUniform3f, align 8, !tbaa !5
  %63 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 13
  %64 = load i32, ptr %63, align 4, !tbaa !23
  %65 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %66 = getelementptr inbounds [2 x i32], ptr %65, i64 0, i64 1
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = sitofp i32 %67 to float
  %69 = load float, ptr %11, align 4, !tbaa !11
  %70 = load float, ptr %12, align 4, !tbaa !11
  call void %62(i32 noundef %64, float noundef %68, float noundef %69, float noundef %70)
  %71 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %72 = getelementptr inbounds [2 x %class.GLTexImage], ptr %71, i64 0, i64 0
  call void @_ZN10GLTexImage8DrawQuadEv(ptr noundef nonnull align 8 dereferenceable(36) %72)
  %73 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %74 = getelementptr inbounds [2 x i32], ptr %73, i64 0, i64 0
  %75 = load i32, ptr %74, align 8, !tbaa !9
  %76 = add nsw i32 %75, 15
  %77 = sdiv i32 %76, 16
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  call void @glReadPixels(i32 noundef 0, i32 noundef 0, i32 noundef 16, i32 noundef %77, i32 noundef 6403, i32 noundef 5126, ptr noundef %78)
  %79 = load i32, ptr %13, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %119

81:                                               ; preds = %6
  %82 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %83 = getelementptr inbounds [2 x %class.GLTexImage], ptr %82, i64 0, i64 1
  call void @_ZN10GLTexImage11AttachToFBOEi(ptr noundef nonnull align 8 dereferenceable(36) %83, i32 noundef 0)
  %84 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %85 = getelementptr inbounds [2 x %class.GLTexImage], ptr %84, i64 0, i64 1
  %86 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %87 = getelementptr inbounds [2 x i32], ptr %86, i64 0, i64 1
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = add nsw i32 %88, 15
  %90 = sdiv i32 %89, 16
  %91 = load ptr, ptr %85, align 8, !tbaa !13
  %92 = getelementptr inbounds ptr, ptr %91, i64 5
  %93 = load ptr, ptr %92, align 8
  call void %93(ptr noundef nonnull align 8 dereferenceable(36) %85, i32 noundef 16, i32 noundef %90)
  %94 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %95 = getelementptr inbounds [2 x %class.GLTexImage], ptr %94, i64 0, i64 1
  call void @_ZN10GLTexImage14FitTexViewPortEv(ptr noundef nonnull align 8 dereferenceable(36) %95)
  %96 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 8
  %97 = load ptr, ptr %96, align 8, !tbaa !24
  %98 = load ptr, ptr %97, align 8, !tbaa !13
  %99 = getelementptr inbounds ptr, ptr %98, i64 0
  %100 = load ptr, ptr %99, align 8
  %101 = call noundef i32 %100(ptr noundef nonnull align 8 dereferenceable(8) %97)
  %102 = load ptr, ptr @__glewUniform3f, align 8, !tbaa !5
  %103 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 13
  %104 = load i32, ptr %103, align 4, !tbaa !23
  %105 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %106 = getelementptr inbounds [2 x i32], ptr %105, i64 0, i64 0
  %107 = load i32, ptr %106, align 8, !tbaa !9
  %108 = sitofp i32 %107 to float
  %109 = load float, ptr %11, align 4, !tbaa !11
  %110 = load float, ptr %12, align 4, !tbaa !11
  call void %102(i32 noundef %104, float noundef %108, float noundef %109, float noundef %110)
  %111 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 5
  %112 = getelementptr inbounds [2 x %class.GLTexImage], ptr %111, i64 0, i64 1
  call void @_ZN10GLTexImage8DrawQuadEv(ptr noundef nonnull align 8 dereferenceable(36) %112)
  %113 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %114 = getelementptr inbounds [2 x i32], ptr %113, i64 0, i64 1
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = add nsw i32 %115, 15
  %117 = sdiv i32 %116, 16
  %118 = load ptr, ptr %15, align 8, !tbaa !5
  call void @glReadPixels(i32 noundef 0, i32 noundef 0, i32 noundef 16, i32 noundef %117, i32 noundef 6403, i32 noundef 5126, ptr noundef %118)
  br label %119

119:                                              ; preds = %81, %6
  %120 = load ptr, ptr @__glewUseProgram, align 8, !tbaa !5
  call void %120(i32 noundef 0)
  call void @_ZN10GLTexImage14UnbindMultiTexEi(i32 noundef 2)
  call void @_ZN10GlobalUtil13CleanupOpenGLEv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %121

121:                                              ; preds = %171, %119
  %122 = load i32, ptr %18, align 4, !tbaa !9
  %123 = getelementptr inbounds %class.SiftMatchGL, ptr %21, i32 0, i32 22
  %124 = getelementptr inbounds [2 x i32], ptr %123, i64 0, i64 0
  %125 = load i32, ptr %124, align 8, !tbaa !9
  %126 = icmp slt i32 %122, %125
  br i1 %126, label %127, label %131

127:                                              ; preds = %121
  %128 = load i32, ptr %16, align 4, !tbaa !9
  %129 = load i32, ptr %9, align 4, !tbaa !9
  %130 = icmp slt i32 %128, %129
  br label %131

131:                                              ; preds = %127, %121
  %132 = phi i1 [ false, %121 ], [ %130, %127 ]
  br i1 %132, label %134, label %133

133:                                              ; preds = %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %174

134:                                              ; preds = %131
  %135 = load ptr, ptr %14, align 8, !tbaa !5
  %136 = load i32, ptr %18, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds float, ptr %135, i64 %137
  %139 = load float, ptr %138, align 4, !tbaa !11
  %140 = fptosi float %139 to i32
  store i32 %140, ptr %17, align 4, !tbaa !9
  %141 = load i32, ptr %17, align 4, !tbaa !9
  %142 = icmp sge i32 %141, 0
  br i1 %142, label %143, label %170

143:                                              ; preds = %134
  %144 = load i32, ptr %13, align 4, !tbaa !9
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %146, label %155

146:                                              ; preds = %143
  %147 = load ptr, ptr %15, align 8, !tbaa !5
  %148 = load i32, ptr %17, align 4, !tbaa !9
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds float, ptr %147, i64 %149
  %151 = load float, ptr %150, align 4, !tbaa !11
  %152 = fptosi float %151 to i32
  %153 = load i32, ptr %18, align 4, !tbaa !9
  %154 = icmp eq i32 %152, %153
  br i1 %154, label %155, label %170

155:                                              ; preds = %146, %143
  %156 = load i32, ptr %18, align 4, !tbaa !9
  %157 = load ptr, ptr %10, align 8, !tbaa !5
  %158 = load i32, ptr %16, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [2 x i32], ptr %157, i64 %159
  %161 = getelementptr inbounds [2 x i32], ptr %160, i64 0, i64 0
  store i32 %156, ptr %161, align 4, !tbaa !9
  %162 = load i32, ptr %17, align 4, !tbaa !9
  %163 = load ptr, ptr %10, align 8, !tbaa !5
  %164 = load i32, ptr %16, align 4, !tbaa !9
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [2 x i32], ptr %163, i64 %165
  %167 = getelementptr inbounds [2 x i32], ptr %166, i64 0, i64 1
  store i32 %162, ptr %167, align 4, !tbaa !9
  %168 = load i32, ptr %16, align 4, !tbaa !9
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %16, align 4, !tbaa !9
  br label %170

170:                                              ; preds = %155, %146, %134
  br label %171

171:                                              ; preds = %170
  %172 = load i32, ptr %18, align 4, !tbaa !9
  %173 = add nsw i32 %172, 1
  store i32 %173, ptr %18, align 4, !tbaa !9
  br label %121, !llvm.loop !25

174:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %175 = call i32 @glGetError()
  store i32 %175, ptr %19, align 4, !tbaa !9
  %176 = load i32, ptr %19, align 4, !tbaa !9
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %178, label %179

178:                                              ; preds = %174
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %181

179:                                              ; preds = %174
  %180 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %180, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %181

181:                                              ; preds = %179, %178
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %182 = load i32, ptr %7, align 4
  ret i32 %182
}

declare void @glReadPixels(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #0

declare void @_ZN10GlobalUtil13CleanupOpenGLEv() #0

attributes #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 = { 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, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !6, i64 336}
!16 = !{!"_ZTS11SiftMatchGL", !17, i64 0, !7, i64 32, !7, i64 112, !18, i64 192, !7, i64 232, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !10, i64 344, !10, i64 348, !10, i64 352, !10, i64 356, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !10, i64 376, !10, i64 380, !10, i64 384, !10, i64 388, !7, i64 392, !7, i64 400, !7, i64 408, !10, i64 416, !10, i64 420, !10, i64 424, !10, i64 428, !10, i64 432, !19, i64 440}
!17 = !{!"_ZTS12SiftMatchGPU", !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24}
!18 = !{!"_ZTS10GLTexImage", !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32}
!19 = !{!"_ZTSSt6vectorIfSaIfEE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!16, !10, i64 356}
!24 = !{!16, !6, i64 328}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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

@__glewActiveTexture = external local_unnamed_addr global ptr, align 8
@__glewUniform3f = external local_unnamed_addr global ptr, align 8
@__glewUseProgram = external local_unnamed_addr global ptr, align 8

declare i32 @glGetError() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

declare void @_ZN10GLTexImage7BindTexEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #0

declare void @_ZN10GLTexImage11AttachToFBOEi(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef) local_unnamed_addr #0

declare void @_ZN10GLTexImage14FitTexViewPortEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #0

declare void @_ZN10GLTexImage8DrawQuadEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #0

declare void @_ZN10GLTexImage14UnbindMultiTexEi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11SiftMatchGL12GetBestMatchEiPA2_jffi(ptr noundef nonnull align 8 dereferenceable(464) %0, i32 noundef %1, ptr nocapture noundef writeonly %2, float noundef %3, float noundef %4, i32 noundef %5) local_unnamed_addr #1 align 2 {
  %7 = load ptr, ptr @__glewActiveTexture, align 8, !tbaa !5
  tail call void %7(i32 noundef 33984)
  %8 = getelementptr inbounds i8, ptr %0, i64 192
  tail call void @_ZN10GLTexImage7BindTexEv(ptr noundef nonnull align 8 dereferenceable(36) %8)
  %9 = getelementptr inbounds i8, ptr %0, i64 440
  %10 = getelementptr inbounds i8, ptr %0, i64 392
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %0, i64 396
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = add i32 %11, 16
  %15 = add i32 %14, %13
  %16 = sext i32 %15 to i64
  tail call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %16)
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef 0) #3
  %18 = load i32, ptr %10, align 8, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %19) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 232
  tail call void @_ZN10GLTexImage11AttachToFBOEi(ptr noundef nonnull align 8 dereferenceable(36) %21, i32 noundef 0)
  %22 = load i32, ptr %10, align 8, !tbaa !9
  %23 = add nsw i32 %22, 15
  %24 = sdiv i32 %23, 16
  %25 = load ptr, ptr %21, align 8, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %25, i64 40
  %27 = load ptr, ptr %26, align 8
  tail call void %27(ptr noundef nonnull align 8 dereferenceable(36) %21, i32 noundef 16, i32 noundef %24)
  tail call void @_ZN10GLTexImage14FitTexViewPortEv(ptr noundef nonnull align 8 dereferenceable(36) %21)
  %28 = getelementptr inbounds i8, ptr %0, i64 336
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = load ptr, ptr %30, align 8
  %32 = tail call noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(8) %29)
  %33 = load ptr, ptr @__glewUniform3f, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %0, i64 356
  %35 = load i32, ptr %34, align 4, !tbaa !21
  %36 = load i32, ptr %12, align 4, !tbaa !9
  %37 = sitofp i32 %36 to float
  tail call void %33(i32 noundef %35, float noundef %37, float noundef %3, float noundef %4)
  tail call void @_ZN10GLTexImage8DrawQuadEv(ptr noundef nonnull align 8 dereferenceable(36) %21)
  %38 = load i32, ptr %10, align 8, !tbaa !9
  %39 = add nsw i32 %38, 15
  %40 = sdiv i32 %39, 16
  tail call void @glReadPixels(i32 noundef 0, i32 noundef 0, i32 noundef 16, i32 noundef %40, i32 noundef 6403, i32 noundef 5126, ptr noundef nonnull %17)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %61, label %41

41:                                               ; preds = %6
  %42 = getelementptr inbounds i8, ptr %0, i64 272
  tail call void @_ZN10GLTexImage11AttachToFBOEi(ptr noundef nonnull align 8 dereferenceable(36) %42, i32 noundef 0)
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = add nsw i32 %43, 15
  %45 = sdiv i32 %44, 16
  %46 = load ptr, ptr %42, align 8, !tbaa !11
  %47 = getelementptr inbounds i8, ptr %46, i64 40
  %48 = load ptr, ptr %47, align 8
  tail call void %48(ptr noundef nonnull align 8 dereferenceable(36) %42, i32 noundef 16, i32 noundef %45)
  tail call void @_ZN10GLTexImage14FitTexViewPortEv(ptr noundef nonnull align 8 dereferenceable(36) %42)
  %49 = getelementptr inbounds i8, ptr %0, i64 328
  %50 = load ptr, ptr %49, align 8, !tbaa !22
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = load ptr, ptr %51, align 8
  %53 = tail call noundef i32 %52(ptr noundef nonnull align 8 dereferenceable(8) %50)
  %54 = load ptr, ptr @__glewUniform3f, align 8, !tbaa !5
  %55 = load i32, ptr %34, align 4, !tbaa !21
  %56 = load i32, ptr %10, align 8, !tbaa !9
  %57 = sitofp i32 %56 to float
  tail call void %54(i32 noundef %55, float noundef %57, float noundef %3, float noundef %4)
  tail call void @_ZN10GLTexImage8DrawQuadEv(ptr noundef nonnull align 8 dereferenceable(36) %42)
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = add nsw i32 %58, 15
  %60 = sdiv i32 %59, 16
  tail call void @glReadPixels(i32 noundef 0, i32 noundef 0, i32 noundef 16, i32 noundef %60, i32 noundef 6403, i32 noundef 5126, ptr noundef nonnull %20)
  br label %61

61:                                               ; preds = %41, %6
  %62 = load ptr, ptr @__glewUseProgram, align 8, !tbaa !5
  tail call void %62(i32 noundef 0)
  tail call void @_ZN10GLTexImage14UnbindMultiTexEi(i32 noundef 2)
  tail call void @_ZN10GlobalUtil13CleanupOpenGLEv()
  %63 = load i32, ptr %10, align 8, !tbaa !9
  %64 = icmp sgt i32 %63, 0
  %65 = icmp sgt i32 %1, 0
  %66 = and i1 %64, %65
  br i1 %66, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %61
  br i1 %.not, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %78
  %67 = phi i32 [ %79, %78 ], [ %63, %.lr.ph ]
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %78 ], [ 0, %.lr.ph ]
  %.02932.us = phi i32 [ %.1.us, %78 ], [ 0, %.lr.ph ]
  %68 = getelementptr inbounds float, ptr %17, i64 %indvars.iv36
  %69 = load float, ptr %68, align 4, !tbaa !23
  %70 = fptosi float %69 to i32
  %71 = icmp sgt i32 %70, -1
  br i1 %71, label %72, label %78

72:                                               ; preds = %.lr.ph.split.us
  %73 = sext i32 %.02932.us to i64
  %74 = getelementptr inbounds [2 x i32], ptr %2, i64 %73
  %75 = trunc nuw nsw i64 %indvars.iv36 to i32
  store i32 %75, ptr %74, align 4, !tbaa !9
  %76 = getelementptr inbounds i8, ptr %74, i64 4
  store i32 %70, ptr %76, align 4, !tbaa !9
  %77 = add nsw i32 %.02932.us, 1
  %.pre39 = load i32, ptr %10, align 8, !tbaa !9
  br label %78

78:                                               ; preds = %72, %.lr.ph.split.us
  %79 = phi i32 [ %.pre39, %72 ], [ %67, %.lr.ph.split.us ]
  %.1.us = phi i32 [ %77, %72 ], [ %.02932.us, %.lr.ph.split.us ]
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv.next37, %80
  %82 = icmp slt i32 %.1.us, %1
  %83 = select i1 %81, i1 %82, i1 false
  br i1 %83, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %103, %78, %61
  %.029.lcssa = phi i32 [ 0, %61 ], [ %.1.us, %78 ], [ %.1, %103 ]
  %84 = tail call i32 @glGetError()
  %.not31 = icmp eq i32 %84, 0
  %.029. = select i1 %.not31, i32 %.029.lcssa, i32 -1
  ret i32 %.029.

.lr.ph.split:                                     ; preds = %.lr.ph, %103
  %85 = phi i32 [ %104, %103 ], [ %63, %.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %103 ], [ 0, %.lr.ph ]
  %.02932 = phi i32 [ %.1, %103 ], [ 0, %.lr.ph ]
  %86 = getelementptr inbounds float, ptr %17, i64 %indvars.iv
  %87 = load float, ptr %86, align 4, !tbaa !23
  %88 = fptosi float %87 to i32
  %89 = icmp sgt i32 %88, -1
  br i1 %89, label %90, label %103

90:                                               ; preds = %.lr.ph.split
  %91 = zext nneg i32 %88 to i64
  %92 = getelementptr inbounds float, ptr %20, i64 %91
  %93 = load float, ptr %92, align 4, !tbaa !23
  %94 = fptosi float %93 to i32
  %95 = zext i32 %94 to i64
  %96 = icmp eq i64 %indvars.iv, %95
  br i1 %96, label %97, label %103

97:                                               ; preds = %90
  %98 = sext i32 %.02932 to i64
  %99 = getelementptr inbounds [2 x i32], ptr %2, i64 %98
  %100 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %100, ptr %99, align 4, !tbaa !9
  %101 = getelementptr inbounds i8, ptr %99, i64 4
  store i32 %88, ptr %101, align 4, !tbaa !9
  %102 = add nsw i32 %.02932, 1
  %.pre = load i32, ptr %10, align 8, !tbaa !9
  br label %103

103:                                              ; preds = %.lr.ph.split, %90, %97
  %104 = phi i32 [ %.pre, %97 ], [ %85, %90 ], [ %85, %.lr.ph.split ]
  %.1 = phi i32 [ %102, %97 ], [ %.02932, %90 ], [ %.02932, %.lr.ph.split ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %105 = sext i32 %104 to i64
  %106 = icmp slt i64 %indvars.iv.next, %105
  %107 = icmp slt i32 %.1, %1
  %108 = select i1 %106, i1 %107, i1 false
  br i1 %108, label %.lr.ph.split, label %._crit_edge, !llvm.loop !25
}

declare void @glReadPixels(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare void @_ZN10GlobalUtil13CleanupOpenGLEv() local_unnamed_addr #0

attributes #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 = { 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 #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 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !6, i64 336}
!14 = !{!"_ZTS11SiftMatchGL", !15, i64 0, !7, i64 32, !7, i64 112, !16, i64 192, !7, i64 232, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !10, i64 344, !10, i64 348, !10, i64 352, !10, i64 356, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !10, i64 376, !10, i64 380, !10, i64 384, !10, i64 388, !7, i64 392, !7, i64 400, !7, i64 408, !10, i64 416, !10, i64 420, !10, i64 424, !10, i64 428, !10, i64 432, !17, i64 440}
!15 = !{!"_ZTS12SiftMatchGPU", !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24}
!16 = !{!"_ZTS10GLTexImage", !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32}
!17 = !{!"_ZTSSt6vectorIfSaIfEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!14, !10, i64 356}
!22 = !{!14, !6, i64 328}
!23 = !{!24, !24, i64 0}
!24 = !{!"float", !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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