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

; 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._VlHIKMTree = type { i64, i64, i64, i64, i32, i32, ptr }
%struct._VlHIKMNode = type { 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: nounwind uwtable
define dso_local void @vl_hikm_push(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i64 @vl_hikm_get_ndims(ptr noundef %16)
  store i64 %17, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call i64 @vl_hikm_get_depth(ptr noundef %18)
  store i64 %19, ptr %12, align 8, !tbaa !9
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %67, %4
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %24, label %70

24:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._VlHIKMTree, ptr %25, i32 0, i32 6
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  store ptr %27, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %65, %24
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %66

31:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._VlHIKMNode, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i64, ptr %9, align 8, !tbaa !9
  %37 = load i64, ptr %11, align 8, !tbaa !9
  %38 = mul i64 %36, %37
  %39 = getelementptr inbounds i8, ptr %35, i64 %38
  call void @vl_ikm_push(ptr noundef %34, ptr noundef %14, ptr noundef %39, i64 noundef 1)
  %40 = load i32, ptr %14, align 4, !tbaa !16
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i64, ptr %9, align 8, !tbaa !9
  %43 = load i64, ptr %12, align 8, !tbaa !9
  %44 = mul i64 %42, %43
  %45 = load i64, ptr %10, align 8, !tbaa !9
  %46 = add i64 %44, %45
  %47 = getelementptr inbounds i32, ptr %41, i64 %46
  store i32 %40, ptr %47, align 4, !tbaa !16
  %48 = load i64, ptr %10, align 8, !tbaa !9
  %49 = add i64 %48, 1
  store i64 %49, ptr %10, align 8, !tbaa !9
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._VlHIKMNode, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = icmp ne ptr %52, null
  br i1 %53, label %55, label %54

54:                                               ; preds = %31
  store i32 6, ptr %15, align 4
  br label %63

55:                                               ; preds = %31
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._VlHIKMNode, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !17
  %59 = load i32, ptr %14, align 4, !tbaa !16
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  store ptr %62, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %15, align 4
  br label %63

63:                                               ; preds = %55, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %64 = load i32, ptr %15, align 4
  switch i32 %64, label %71 [
    i32 0, label %65
    i32 6, label %66
  ]

65:                                               ; preds = %63
  br label %28, !llvm.loop !18

66:                                               ; preds = %63, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %67

67:                                               ; preds = %66
  %68 = load i64, ptr %9, align 8, !tbaa !9
  %69 = add i64 %68, 1
  store i64 %69, ptr %9, align 8, !tbaa !9
  br label %20, !llvm.loop !20

70:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void

71:                                               ; preds = %63
  unreachable
}

; Function Attrs: nounwind uwtable
declare dso_local i64 @vl_hikm_get_ndims(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @vl_hikm_get_depth(ptr noundef) #1

declare void @vl_ikm_push(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 40}
!12 = !{!"_VlHIKMTree", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !13, i64 36, !6, i64 40}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"_VlHIKMNode", !6, i64 0, !6, i64 8}
!16 = !{!13, !13, i64 0}
!17 = !{!15, !6, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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 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: nounwind uwtable
define dso_local void @vl_hikm_push(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #1 {
  %5 = alloca i32, align 4
  %6 = tail call i64 @vl_hikm_get_ndims(ptr noundef %0)
  %7 = tail call i64 @vl_hikm_get_depth(ptr noundef %0)
  %.not32 = icmp eq i64 %3, 0
  br i1 %.not32, label %._crit_edge, label %.lr.ph31

.lr.ph31:                                         ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %._crit_edge, label %.lr.ph31.split

.lr.ph31.splitthread-pre-split:                   ; preds = %.loopexit
  %.pr = load ptr, ptr %8, align 8, !tbaa !5
  br label %.lr.ph31.split

.lr.ph31.split:                                   ; preds = %.lr.ph31, %.lr.ph31.splitthread-pre-split
  %11 = phi ptr [ %.pr, %.lr.ph31.splitthread-pre-split ], [ %9, %.lr.ph31 ]
  %.01929 = phi i64 [ %27, %.lr.ph31.splitthread-pre-split ], [ 0, %.lr.ph31 ]
  %.not26 = icmp eq ptr %11, null
  br i1 %.not26, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph31.split
  %12 = mul i64 %.01929, %6
  %13 = getelementptr inbounds i8, ptr %2, i64 %12
  %14 = mul i64 %.01929, %7
  %15 = getelementptr i32, ptr %1, i64 %14
  br label %16

16:                                               ; preds = %.lr.ph, %22
  %.01828 = phi ptr [ %11, %.lr.ph ], [ %26, %22 ]
  %.02027 = phi i64 [ 0, %.lr.ph ], [ %23, %22 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %17 = load ptr, ptr %.01828, align 8, !tbaa !12
  call void @vl_ikm_push(ptr noundef %17, ptr noundef nonnull %5, ptr noundef %13, i64 noundef 1) #3
  %18 = load i32, ptr %5, align 4, !tbaa !14
  %19 = getelementptr i32, ptr %15, i64 %.02027
  store i32 %18, ptr %19, align 4, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %.01828, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %.not22 = icmp eq ptr %21, null
  br i1 %.not22, label %.thread, label %22

.thread:                                          ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  br label %.loopexit

22:                                               ; preds = %16
  %23 = add i64 %.02027, 1
  %24 = zext i32 %18 to i64
  %25 = getelementptr inbounds ptr, ptr %21, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %.loopexit, label %16

.loopexit:                                        ; preds = %22, %.lr.ph31.split, %.thread
  %27 = add nuw i64 %.01929, 1
  %exitcond.not = icmp eq i64 %27, %3
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph31.splitthread-pre-split, !llvm.loop !17

._crit_edge:                                      ; preds = %.loopexit, %.lr.ph31, %4
  ret void
}

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

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

declare void @vl_ikm_push(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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, !11, i64 40}
!6 = !{!"_VlHIKMTree", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !11, i64 40}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_VlHIKMNode", !11, i64 0, !11, i64 8}
!14 = !{!10, !10, i64 0}
!15 = !{!13, !11, i64 8}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18, !19}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.unswitch.partial.disable"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass