; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl (covdet)

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

%struct._VlFrameOrientedEllipse = type { float, float, float, float, float, float }
%struct._VlCovDet = type { ptr, ptr, i32, double, double, double, i64, i64, double, i64, ptr, i64, i64, ptr, i64, i32, [4 x %struct._VlCovDetFeatureOrientation], [4 x %struct._VlCovDetFeatureLaplacianScale], i32, [1681 x float], [1681 x float], [1681 x float], [1681 x float], [1089 x float], [10890 x float], [5 x i64] }
%struct._VlCovDetFeatureOrientation = type { double, double }
%struct._VlCovDetFeatureLaplacianScale = type { double, double }
%struct._VlCovDetFeature = type { %struct._VlFrameOrientedEllipse, float, float, float, float }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @vl_covdet_get_num_features(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @_vl_covdet_check_frame_inside(ptr noundef, ptr noundef byval(%struct._VlFrameOrientedEllipse) align 8, double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @vl_covdet_drop_features_outside(ptr noundef %0, double noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct._VlFrameOrientedEllipse, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i64 @vl_covdet_get_num_features(ptr noundef %10)
  store i64 %11, ptr %7, align 8, !tbaa !11
  store i64 0, ptr %5, align 8, !tbaa !11
  br label %12

12:                                               ; preds = %44, %2
  %13 = load i64, ptr %5, align 8, !tbaa !11
  %14 = load i64, ptr %7, align 8, !tbaa !11
  %15 = trunc i64 %14 to i32
  %16 = sext i32 %15 to i64
  %17 = icmp slt i64 %13, %16
  br i1 %17, label %18, label %47

18:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._VlCovDet, ptr %20, i32 0, i32 10
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load i64, ptr %5, align 8, !tbaa !11
  %24 = getelementptr inbounds %struct._VlCovDetFeature, ptr %22, i64 %23
  %25 = getelementptr inbounds %struct._VlCovDetFeature, ptr %24, i32 0, i32 0
  %26 = load double, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 4 %25, i64 24, i1 false), !tbaa.struct !16
  %27 = call i32 @_vl_covdet_check_frame_inside(ptr noundef %19, ptr noundef byval(%struct._VlFrameOrientedEllipse) align 8 %9, double noundef %26)
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #3
  store i32 %27, ptr %8, align 4, !tbaa !19
  %28 = load i32, ptr %8, align 4, !tbaa !19
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %43

30:                                               ; preds = %18
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._VlCovDet, ptr %31, i32 0, i32 10
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load i64, ptr %6, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct._VlCovDetFeature, ptr %33, i64 %34
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._VlCovDet, ptr %36, i32 0, i32 10
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load i64, ptr %5, align 8, !tbaa !11
  %40 = getelementptr inbounds %struct._VlCovDetFeature, ptr %38, i64 %39
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %35, ptr align 4 %40, i64 40, i1 false), !tbaa.struct !20
  %41 = load i64, ptr %6, align 8, !tbaa !11
  %42 = add nsw i64 %41, 1
  store i64 %42, ptr %6, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %30, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %44

44:                                               ; preds = %43
  %45 = load i64, ptr %5, align 8, !tbaa !11
  %46 = add nsw i64 %45, 1
  store i64 %46, ptr %5, align 8, !tbaa !11
  br label %12, !llvm.loop !21

47:                                               ; preds = %12
  %48 = load i64, ptr %6, align 8, !tbaa !11
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._VlCovDet, ptr %49, i32 0, i32 11
  store i64 %48, ptr %50, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !6, i64 80}
!14 = !{!"_VlCovDet", !6, i64 0, !6, i64 8, !15, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !12, i64 48, !12, i64 56, !10, i64 64, !12, i64 72, !6, i64 80, !12, i64 88, !12, i64 96, !6, i64 104, !12, i64 112, !15, i64 120, !7, i64 128, !7, i64 192, !15, i64 256, !7, i64 260, !7, i64 6984, !7, i64 13708, !7, i64 20432, !7, i64 27156, !7, i64 31512, !7, i64 75072}
!15 = !{!"int", !7, i64 0}
!16 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 4, !17, i64 12, i64 4, !17, i64 16, i64 4, !17, i64 20, i64 4, !17}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!15, !15, i64 0}
!20 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 4, !17, i64 12, i64 4, !17, i64 16, i64 4, !17, i64 20, i64 4, !17, i64 24, i64 4, !17, i64 28, i64 4, !17, i64 32, i64 4, !17, i64 36, i64 4, !17}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!14, !12, i64 88}


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

%struct._VlFrameOrientedEllipse = type { float, float, float, float, float, float }
%struct._VlCovDetFeature = type { %struct._VlFrameOrientedEllipse, float, float, float, float }

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @vl_covdet_get_num_features(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @_vl_covdet_check_frame_inside(ptr noundef, ptr noundef byval(%struct._VlFrameOrientedEllipse) align 8, double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @vl_covdet_drop_features_outside(ptr noundef %0, double noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct._VlFrameOrientedEllipse, align 8
  %4 = tail call i64 @vl_covdet_get_num_features(ptr noundef %0)
  %sext = shl i64 %4, 32
  %5 = ashr exact i64 %sext, 32
  %6 = icmp sgt i64 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  br label %8

8:                                                ; preds = %.lr.ph, %17
  %.017 = phi i64 [ 0, %.lr.ph ], [ %18, %17 ]
  %.01516 = phi i64 [ 0, %.lr.ph ], [ %.1, %17 ]
  %9 = load ptr, ptr %7, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._VlCovDetFeature, ptr %9, i64 %.017
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 4 dereferenceable(24) %10, i64 24, i1 false), !tbaa.struct !13
  %11 = tail call i32 @_vl_covdet_check_frame_inside(ptr noundef %0, ptr noundef nonnull byval(%struct._VlFrameOrientedEllipse) align 8 %3, double noundef %1)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %17, label %12

12:                                               ; preds = %8
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._VlCovDetFeature, ptr %13, i64 %.01516
  %15 = getelementptr inbounds %struct._VlCovDetFeature, ptr %13, i64 %.017
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(40) %14, ptr noundef nonnull align 4 dereferenceable(40) %15, i64 40, i1 false), !tbaa.struct !16
  %16 = add nsw i64 %.01516, 1
  br label %17

17:                                               ; preds = %12, %8
  %.1 = phi i64 [ %16, %12 ], [ %.01516, %8 ]
  %18 = add nuw nsw i64 %.017, 1
  %exitcond.not = icmp eq i64 %18, %5
  br i1 %exitcond.not, label %._crit_edge, label %8, !llvm.loop !17

._crit_edge:                                      ; preds = %17, %2
  %.015.lcssa = phi i64 [ 0, %2 ], [ %.1, %17 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 88
  store i64 %.015.lcssa, ptr %19, align 8, !tbaa !19
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !7, i64 80}
!6 = !{!"_VlCovDet", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !12, i64 48, !12, i64 56, !11, i64 64, !12, i64 72, !7, i64 80, !12, i64 88, !12, i64 96, !7, i64 104, !12, i64 112, !10, i64 120, !8, i64 128, !8, i64 192, !10, i64 256, !8, i64 260, !8, i64 6984, !8, i64 13708, !8, i64 20432, !8, i64 27156, !8, i64 31512, !8, i64 75072}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{i64 0, i64 4, !14, i64 4, i64 4, !14, i64 8, i64 4, !14, i64 12, i64 4, !14, i64 16, i64 4, !14, i64 20, i64 4, !14}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = !{i64 0, i64 4, !14, i64 4, i64 4, !14, i64 8, i64 4, !14, i64 12, i64 4, !14, i64 16, i64 4, !14, i64 20, i64 4, !14, i64 24, i64 4, !14, i64 28, i64 4, !14, i64 32, i64 4, !14, i64 36, i64 4, !14}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !12, i64 88}


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