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

; 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._VlKDForestSearcher = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64 }
%struct._VlKDForest = type { i64, ptr, i32, ptr, i64, i32, ptr, ptr, i64, i32, [5 x %struct._VlKDTreeSplitDimension], i64, i64, i64, i64, i64, ptr }
%struct._VlKDTreeSplitDimension = type { i32, double, double }

; Function Attrs: nounwind uwtable
define dso_local void @vl_kdforestsearcher_delete(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %3, i32 0, i32 1
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %27

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %27

12:                                               ; preds = %7
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %18, i32 0, i32 0
  store ptr %15, ptr %19, align 8, !tbaa !12
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %25, i32 0, i32 1
  store ptr %22, ptr %26, align 8, !tbaa !9
  br label %71

27:                                               ; preds = %7, %1
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %42

32:                                               ; preds = %27
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !12
  %36 = icmp ne ptr %35, null
  br i1 %36, label %42, label %37

37:                                               ; preds = %32
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %40, i32 0, i32 0
  store ptr null, ptr %41, align 8, !tbaa !12
  br label %70

42:                                               ; preds = %32, %27
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = icmp ne ptr %45, null
  br i1 %46, label %64, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !12
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %64

52:                                               ; preds = %47
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !12
  %56 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %55, i32 0, i32 1
  store ptr null, ptr %56, align 8, !tbaa !9
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !12
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %60, i32 0, i32 4
  %62 = load ptr, ptr %61, align 8, !tbaa !13
  %63 = getelementptr inbounds %struct._VlKDForest, ptr %62, i32 0, i32 16
  store ptr %59, ptr %63, align 8, !tbaa !14
  br label %69

64:                                               ; preds = %47, %42
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = getelementptr inbounds %struct._VlKDForest, ptr %67, i32 0, i32 16
  store ptr null, ptr %68, align 8, !tbaa !14
  br label %69

69:                                               ; preds = %64, %52
  br label %70

70:                                               ; preds = %69, %37
  br label %71

71:                                               ; preds = %70, %12
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %72, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !13
  %75 = getelementptr inbounds %struct._VlKDForest, ptr %74, i32 0, i32 15
  %76 = load i64, ptr %75, align 8, !tbaa !17
  %77 = add i64 %76, -1
  store i64 %77, ptr %75, align 8, !tbaa !17
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %78, i32 0, i32 3
  %80 = load ptr, ptr %79, align 8, !tbaa !18
  call void @vl_free(ptr noundef %80)
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._VlKDForestSearcher, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !19
  call void @vl_free(ptr noundef %83)
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  call void @vl_free(ptr noundef %84)
  ret void
}

declare void @vl_free(ptr noundef) #1

attributes #0 = { 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 = { "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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_VlKDForestSearcher", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72}
!11 = !{!"long long", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!10, !6, i64 32}
!14 = !{!15, !6, i64 240}
!15 = !{!"_VlKDForest", !11, i64 0, !6, i64 8, !16, i64 16, !6, i64 24, !11, i64 32, !16, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !16, i64 72, !7, i64 80, !11, i64 200, !11, i64 208, !11, i64 216, !11, i64 224, !11, i64 232, !6, i64 240}
!16 = !{!"int", !7, i64 0}
!17 = !{!15, !11, i64 232}
!18 = !{!10, !6, i64 24}
!19 = !{!10, !6, i64 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: nounwind uwtable
define dso_local void @vl_kdforestsearcher_delete(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  %4 = load ptr, ptr %0, align 8, !tbaa !11
  %.not26 = icmp eq ptr %4, null
  br i1 %.not, label %10, label %5

5:                                                ; preds = %1
  br i1 %.not26, label %9, label %6

6:                                                ; preds = %5
  store ptr %4, ptr %3, align 8, !tbaa !11
  %7 = load ptr, ptr %0, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %3, ptr %8, align 8, !tbaa !5
  br label %20

9:                                                ; preds = %5
  store ptr null, ptr %3, align 8, !tbaa !11
  br label %20

10:                                               ; preds = %1
  br i1 %.not26, label %16, label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr null, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %14, i64 240
  store ptr %4, ptr %15, align 8, !tbaa !13
  br label %20

16:                                               ; preds = %10
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %18, i64 240
  store ptr null, ptr %19, align 8, !tbaa !13
  br label %20

20:                                               ; preds = %9, %16, %11, %6
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %22, i64 232
  %24 = load i64, ptr %23, align 8, !tbaa !16
  %25 = add i64 %24, -1
  store i64 %25, ptr %23, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  tail call void @vl_free(ptr noundef %27) #2
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  tail call void @vl_free(ptr noundef %29) #2
  tail call void @vl_free(ptr noundef nonnull %0) #2
  ret void
}

declare void @vl_free(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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, !7, i64 8}
!6 = !{!"_VlKDForestSearcher", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!14, !7, i64 240}
!14 = !{!"_VlKDForest", !10, i64 0, !7, i64 8, !15, i64 16, !7, i64 24, !10, i64 32, !15, i64 40, !7, i64 48, !7, i64 56, !10, i64 64, !15, i64 72, !8, i64 80, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !7, i64 240}
!15 = !{!"int", !8, i64 0}
!16 = !{!14, !10, i64 232}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass