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

; 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._VlAIB = type { ptr, i32, ptr, ptr, ptr, i32, ptr, ptr, ptr, i32, i32, ptr, ptr, i32 }

; 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_aib_min_beta(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = 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 ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._VlAIB, ptr %10, i32 0, i32 2
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds double, ptr %12, i64 0
  %14 = load double, ptr %13, align 8, !tbaa !12
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  store double %14, ptr %15, align 8, !tbaa !12
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %16, align 4, !tbaa !14
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._VlAIB, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = getelementptr inbounds i32, ptr %19, i64 0
  %21 = load i32, ptr %20, align 4, !tbaa !14
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %21, ptr %22, align 4, !tbaa !14
  store i32 0, ptr %9, align 4, !tbaa !14
  br label %23

23:                                               ; preds = %60, %4
  %24 = load i32, ptr %9, align 4, !tbaa !14
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._VlAIB, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = icmp ult i32 %24, %27
  br i1 %28, label %29, label %63

29:                                               ; preds = %23
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._VlAIB, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !14
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds double, ptr %32, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !12
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load double, ptr %37, align 8, !tbaa !12
  %39 = fcmp olt double %36, %38
  br i1 %39, label %40, label %59

40:                                               ; preds = %29
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._VlAIB, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = load i32, ptr %9, align 4, !tbaa !14
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds double, ptr %43, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !12
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  store double %47, ptr %48, align 8, !tbaa !12
  %49 = load i32, ptr %9, align 4, !tbaa !14
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %49, ptr %50, align 4, !tbaa !14
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._VlAIB, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = load i32, ptr %9, align 4, !tbaa !14
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %53, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !14
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %57, ptr %58, align 4, !tbaa !14
  br label %59

59:                                               ; preds = %40, %29
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %9, align 4, !tbaa !14
  %62 = add i32 %61, 1
  store i32 %62, ptr %9, align 4, !tbaa !14
  br label %23, !llvm.loop !17

63:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret void
}

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 = { 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, !6, i64 16}
!10 = !{!"_VlAIB", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !11, i64 76, !6, i64 80, !6, i64 88, !11, i64 96}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !11, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"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(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @vl_aib_min_beta(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load double, ptr %6, align 8, !tbaa !11
  store double %7, ptr %3, align 8, !tbaa !11
  store i32 0, ptr %1, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = load i32, ptr %9, align 4, !tbaa !13
  store i32 %10, ptr %2, align 4, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %22
  %13 = phi i32 [ %23, %22 ], [ %12, %4 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %22 ], [ 0, %4 ]
  %14 = phi double [ %24, %22 ], [ %7, %4 ]
  %15 = getelementptr inbounds double, ptr %6, i64 %indvars.iv
  %16 = load double, ptr %15, align 8, !tbaa !11
  %17 = fcmp olt double %16, %14
  br i1 %17, label %18, label %22

18:                                               ; preds = %.lr.ph
  store double %16, ptr %3, align 8, !tbaa !11
  %19 = trunc nuw i64 %indvars.iv to i32
  store i32 %19, ptr %1, align 4, !tbaa !13
  %20 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %21 = load i32, ptr %20, align 4, !tbaa !13
  store i32 %21, ptr %2, align 4, !tbaa !13
  %.pre = load i32, ptr %11, align 8, !tbaa !15
  br label %22

22:                                               ; preds = %.lr.ph, %18
  %23 = phi i32 [ %13, %.lr.ph ], [ %.pre, %18 ]
  %24 = phi double [ %14, %.lr.ph ], [ %16, %18 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = zext i32 %23 to i64
  %26 = icmp ult i64 %indvars.iv.next, %25
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %22, %4
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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, !7, i64 16}
!6 = !{!"_VlAIB", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72, !10, i64 76, !7, i64 80, !7, i64 88, !10, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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