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

@.str = external hidden unnamed_addr constant [56 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.vl_kdforest_new = external hidden unnamed_addr constant [79 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @vl_kdforest_new(i32 noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %10 = call ptr @vl_calloc(i64 noundef 248, i64 noundef 1)
  store ptr %10, ptr %9, align 8, !tbaa !11
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %16, label %13

13:                                               ; preds = %4
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 2
  br i1 %15, label %16, label %17

16:                                               ; preds = %13, %4
  br label %18

17:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 337, ptr noundef @__PRETTY_FUNCTION__.vl_kdforest_new) #5
  unreachable

18:                                               ; preds = %16
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = icmp uge i64 %19, 1
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %23

22:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 338, ptr noundef @__PRETTY_FUNCTION__.vl_kdforest_new) #5
  unreachable

23:                                               ; preds = %21
  %24 = load i64, ptr %7, align 8, !tbaa !9
  %25 = icmp uge i64 %24, 1
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %28

27:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 339, ptr noundef @__PRETTY_FUNCTION__.vl_kdforest_new) #5
  unreachable

28:                                               ; preds = %26
  %29 = call ptr @vl_get_rand()
  %30 = load ptr, ptr %9, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct._VlKDForest, ptr %30, i32 0, i32 1
  store ptr %29, ptr %31, align 8, !tbaa !13
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !11
  %34 = getelementptr inbounds %struct._VlKDForest, ptr %33, i32 0, i32 2
  store i32 %32, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %9, align 8, !tbaa !11
  %36 = getelementptr inbounds %struct._VlKDForest, ptr %35, i32 0, i32 4
  store i64 0, ptr %36, align 8, !tbaa !16
  %37 = load ptr, ptr %9, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct._VlKDForest, ptr %37, i32 0, i32 3
  store ptr null, ptr %38, align 8, !tbaa !17
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = load ptr, ptr %9, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct._VlKDForest, ptr %40, i32 0, i32 0
  store i64 %39, ptr %41, align 8, !tbaa !18
  %42 = load i64, ptr %7, align 8, !tbaa !9
  %43 = load ptr, ptr %9, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct._VlKDForest, ptr %43, i32 0, i32 8
  store i64 %42, ptr %44, align 8, !tbaa !19
  %45 = load ptr, ptr %9, align 8, !tbaa !11
  %46 = getelementptr inbounds %struct._VlKDForest, ptr %45, i32 0, i32 7
  store ptr null, ptr %46, align 8, !tbaa !20
  %47 = load ptr, ptr %9, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct._VlKDForest, ptr %47, i32 0, i32 9
  store i32 0, ptr %48, align 8, !tbaa !21
  %49 = load i64, ptr %7, align 8, !tbaa !9
  %50 = icmp ult i64 %49, 5
  br i1 %50, label %51, label %53

51:                                               ; preds = %28
  %52 = load i64, ptr %7, align 8, !tbaa !9
  br label %54

53:                                               ; preds = %28
  br label %54

54:                                               ; preds = %53, %51
  %55 = phi i64 [ %52, %51 ], [ 5, %53 ]
  %56 = load ptr, ptr %9, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct._VlKDForest, ptr %56, i32 0, i32 12
  store i64 %55, ptr %57, align 8, !tbaa !22
  %58 = load ptr, ptr %9, align 8, !tbaa !11
  %59 = getelementptr inbounds %struct._VlKDForest, ptr %58, i32 0, i32 11
  store i64 0, ptr %59, align 8, !tbaa !23
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = load ptr, ptr %9, align 8, !tbaa !11
  %62 = getelementptr inbounds %struct._VlKDForest, ptr %61, i32 0, i32 5
  store i32 %60, ptr %62, align 8, !tbaa !24
  %63 = load ptr, ptr %9, align 8, !tbaa !11
  %64 = getelementptr inbounds %struct._VlKDForest, ptr %63, i32 0, i32 13
  store i64 0, ptr %64, align 8, !tbaa !25
  %65 = load ptr, ptr %9, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct._VlKDForest, ptr %65, i32 0, i32 15
  store i64 0, ptr %66, align 8, !tbaa !26
  %67 = load ptr, ptr %9, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct._VlKDForest, ptr %67, i32 0, i32 16
  store ptr null, ptr %68, align 8, !tbaa !27
  %69 = load ptr, ptr %9, align 8, !tbaa !11
  %70 = getelementptr inbounds %struct._VlKDForest, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !15
  switch i32 %71, label %82 [
    i32 1, label %72
    i32 2, label %77
  ]

72:                                               ; preds = %54
  %73 = load i32, ptr %8, align 4, !tbaa !5
  %74 = call ptr @vl_get_vector_comparison_function_f(i32 noundef %73)
  %75 = load ptr, ptr %9, align 8, !tbaa !11
  %76 = getelementptr inbounds %struct._VlKDForest, ptr %75, i32 0, i32 6
  store ptr %74, ptr %76, align 8, !tbaa !28
  br label %83

77:                                               ; preds = %54
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = call ptr @vl_get_vector_comparison_function_d(i32 noundef %78)
  %80 = load ptr, ptr %9, align 8, !tbaa !11
  %81 = getelementptr inbounds %struct._VlKDForest, ptr %80, i32 0, i32 6
  store ptr %79, ptr %81, align 8, !tbaa !28
  br label %83

82:                                               ; preds = %54
  call void @abort() #5
  unreachable

83:                                               ; preds = %77, %72
  %84 = load ptr, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret ptr %84
}

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

declare ptr @vl_calloc(i64 noundef, i64 noundef) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare ptr @vl_get_rand() #2

declare ptr @vl_get_vector_comparison_function_f(i32 noundef) #2

declare ptr @vl_get_vector_comparison_function_d(i32 noundef) #2

; Function Attrs: noreturn nounwind
declare void @abort() #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { noreturn nounwind "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 }
attributes #5 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_VlKDForest", !10, i64 0, !12, i64 8, !6, i64 16, !12, i64 24, !10, i64 32, !6, i64 40, !12, i64 48, !12, i64 56, !10, i64 64, !6, i64 72, !7, i64 80, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !12, i64 240}
!15 = !{!14, !6, i64 16}
!16 = !{!14, !10, i64 32}
!17 = !{!14, !12, i64 24}
!18 = !{!14, !10, i64 0}
!19 = !{!14, !10, i64 64}
!20 = !{!14, !12, i64 56}
!21 = !{!14, !6, i64 72}
!22 = !{!14, !10, i64 208}
!23 = !{!14, !10, i64 200}
!24 = !{!14, !6, i64 40}
!25 = !{!14, !10, i64 216}
!26 = !{!14, !10, i64 232}
!27 = !{!14, !12, i64 240}
!28 = !{!14, !12, i64 48}


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

@.str = external hidden unnamed_addr constant [56 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.vl_kdforest_new = external hidden unnamed_addr constant [79 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @vl_kdforest_new(i32 noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call ptr @vl_calloc(i64 noundef 248, i64 noundef 1) #5
  %6 = add i32 %0, -1
  %or.cond = icmp ult i32 %6, 2
  br i1 %or.cond, label %8, label %7

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 337, ptr noundef nonnull @__PRETTY_FUNCTION__.vl_kdforest_new) #6
  unreachable

8:                                                ; preds = %4
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %9, label %10

9:                                                ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 338, ptr noundef nonnull @__PRETTY_FUNCTION__.vl_kdforest_new) #6
  unreachable

10:                                               ; preds = %8
  %.not31 = icmp eq i64 %2, 0
  br i1 %.not31, label %11, label %12

11:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 339, ptr noundef nonnull @__PRETTY_FUNCTION__.vl_kdforest_new) #6
  unreachable

12:                                               ; preds = %10
  %13 = tail call ptr @vl_get_rand() #5
  %14 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %13, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 %0, ptr %15, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %5, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %16, i8 0, i64 16, i1 false)
  store i64 %1, ptr %5, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %5, i64 64
  store i64 %2, ptr %17, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr null, ptr %18, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %5, i64 72
  store i32 0, ptr %19, align 8, !tbaa !16
  %20 = tail call i64 @llvm.umin.i64(i64 %2, i64 5)
  %21 = getelementptr inbounds i8, ptr %5, i64 208
  store i64 %20, ptr %21, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %5, i64 200
  store i64 0, ptr %22, align 8, !tbaa !18
  %23 = getelementptr inbounds i8, ptr %5, i64 40
  store i32 %3, ptr %23, align 8, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %5, i64 216
  store i64 0, ptr %24, align 8, !tbaa !20
  %25 = getelementptr inbounds i8, ptr %5, i64 232
  %switch = icmp eq i32 %0, 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %25, i8 0, i64 16, i1 false)
  br i1 %switch, label %26, label %28

26:                                               ; preds = %12
  %27 = tail call ptr @vl_get_vector_comparison_function_f(i32 noundef %3) #5
  br label %30

28:                                               ; preds = %12
  %29 = tail call ptr @vl_get_vector_comparison_function_d(i32 noundef %3) #5
  br label %30

30:                                               ; preds = %28, %26
  %.sink = phi ptr [ %27, %26 ], [ %29, %28 ]
  %31 = getelementptr inbounds i8, ptr %5, i64 48
  store ptr %.sink, ptr %31, align 8
  ret ptr %5
}

declare ptr @vl_calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @vl_get_rand() local_unnamed_addr #1

declare ptr @vl_get_vector_comparison_function_f(i32 noundef) local_unnamed_addr #1

declare ptr @vl_get_vector_comparison_function_d(i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { noreturn nounwind "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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, !10, i64 8}
!6 = !{!"_VlKDForest", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 24, !7, i64 32, !11, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !11, i64 72, !8, i64 80, !7, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !10, i64 240}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 64}
!15 = !{!6, !10, i64 56}
!16 = !{!6, !11, i64 72}
!17 = !{!6, !7, i64 208}
!18 = !{!6, !7, i64 200}
!19 = !{!6, !11, i64 40}
!20 = !{!6, !7, i64 216}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass