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

; 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._VlArray = type { i32, i32, i32, i64, [16 x i64], ptr, ptr, ptr }

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

11:                                               ; preds = %1
  store i64 0, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %32

12:                                               ; preds = %1
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %27, %12
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._VlArray, ptr %15, i32 0, i32 3
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = icmp ult i64 %14, %17
  br i1 %18, label %19, label %30

19:                                               ; preds = %13
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._VlArray, ptr %20, i32 0, i32 4
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds [16 x i64], ptr %21, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = mul i64 %25, %24
  store i64 %26, ptr %4, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %19
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = add i64 %28, 1
  store i64 %29, ptr %5, align 8, !tbaa !9
  br label %13, !llvm.loop !14

30:                                               ; preds = %13
  %31 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %31, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %32

32:                                               ; preds = %30, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %33 = load i64, ptr %2, align 8
  ret i64 %33
}

; 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

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 = { 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, !10, i64 16}
!12 = !{!"_VlArray", !13, i64 0, !13, i64 4, !13, i64 8, !10, i64 16, !7, i64 24, !6, i64 152, !6, i64 160, !6, i64 168}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local i64 @vl_array_get_num_elements(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = icmp eq i64 %3, 0
  br i1 %4, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %xtraiter = and i64 %3, 7
  %6 = icmp ult i64 %3, 8
  br i1 %6, label %.loopexit.loopexit.unr-lcssa, label %.preheader.new

.preheader.new:                                   ; preds = %.preheader
  %unroll_iter = and i64 %3, -8
  br label %7

7:                                                ; preds = %7, %.preheader.new
  %.011 = phi i64 [ 0, %.preheader.new ], [ %39, %7 ]
  %.0810 = phi i64 [ 1, %.preheader.new ], [ %38, %7 ]
  %niter = phi i64 [ 0, %.preheader.new ], [ %niter.next.7, %7 ]
  %8 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %.011
  %9 = load i64, ptr %8, align 8, !tbaa !12
  %10 = mul i64 %9, %.0810
  %11 = or disjoint i64 %.011, 1
  %12 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !12
  %14 = mul i64 %13, %10
  %15 = or disjoint i64 %.011, 2
  %16 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !12
  %18 = mul i64 %17, %14
  %19 = or disjoint i64 %.011, 3
  %20 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !12
  %22 = mul i64 %21, %18
  %23 = or disjoint i64 %.011, 4
  %24 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !12
  %26 = mul i64 %25, %22
  %27 = or disjoint i64 %.011, 5
  %28 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !12
  %30 = mul i64 %29, %26
  %31 = or disjoint i64 %.011, 6
  %32 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !12
  %34 = mul i64 %33, %30
  %35 = or disjoint i64 %.011, 7
  %36 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !12
  %38 = mul i64 %37, %34
  %39 = add nuw i64 %.011, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.loopexit.loopexit.unr-lcssa, label %7, !llvm.loop !13

.loopexit.loopexit.unr-lcssa:                     ; preds = %7, %.preheader
  %.lcssa.ph = phi i64 [ poison, %.preheader ], [ %38, %7 ]
  %.011.unr = phi i64 [ 0, %.preheader ], [ %39, %7 ]
  %.0810.unr = phi i64 [ 1, %.preheader ], [ %38, %7 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader
  %.011.epil = phi i64 [ %43, %.epil.preheader ], [ %.011.unr, %.loopexit.loopexit.unr-lcssa ]
  %.0810.epil = phi i64 [ %42, %.epil.preheader ], [ %.0810.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %40 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %.011.epil
  %41 = load i64, ptr %40, align 8, !tbaa !12
  %42 = mul i64 %41, %.0810.epil
  %43 = add nuw i64 %.011.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.epil.preheader, !llvm.loop !15

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader, %1
  %.09 = phi i64 [ 0, %1 ], [ %.lcssa.ph, %.loopexit.loopexit.unr-lcssa ], [ %42, %.epil.preheader ]
  ret i64 %.09
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: read) 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" }

!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 16}
!6 = !{!"_VlArray", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !8, i64 24, !11, i64 152, !11, i64 160, !11, i64 168}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}


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