; 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
declare double @log(double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind uwtable
define dso_local void @vl_aib_calculate_information(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  store double 0.000000e+00, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store double 0.000000e+00, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %11

11:                                               ; preds = %120, %3
  %12 = load i32, ptr %7, align 4, !tbaa !11
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._VlAIB, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %17, label %123

17:                                               ; preds = %11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._VlAIB, ptr %18, i32 0, i32 7
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = load i32, ptr %7, align 4, !tbaa !11
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds double, ptr %20, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = fcmp oeq double %24, 0.000000e+00
  br i1 %25, label %26, label %27

26:                                               ; preds = %17
  br label %120

27:                                               ; preds = %17
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._VlAIB, ptr %28, i32 0, i32 7
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = load i32, ptr %7, align 4, !tbaa !11
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds double, ptr %30, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = call double @log(double noundef %34) #4
  %36 = fneg double %35
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._VlAIB, ptr %37, i32 0, i32 7
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load i32, ptr %7, align 4, !tbaa !11
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %39, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = call double @llvm.fmuladd.f64(double %36, double %43, double %45)
  store double %46, ptr %44, align 8, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %116, %27
  %48 = load i32, ptr %8, align 4, !tbaa !11
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._VlAIB, ptr %49, i32 0, i32 10
  %51 = load i32, ptr %50, align 4, !tbaa !16
  %52 = icmp ult i32 %48, %51
  br i1 %52, label %53, label %119

53:                                               ; preds = %47
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._VlAIB, ptr %54, i32 0, i32 6
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = load i32, ptr %7, align 4, !tbaa !11
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._VlAIB, ptr %58, i32 0, i32 10
  %60 = load i32, ptr %59, align 4, !tbaa !16
  %61 = mul i32 %57, %60
  %62 = load i32, ptr %8, align 4, !tbaa !11
  %63 = add i32 %61, %62
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %56, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = fcmp oeq double %66, 0.000000e+00
  br i1 %67, label %68, label %69

68:                                               ; preds = %53
  br label %116

69:                                               ; preds = %53
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._VlAIB, ptr %70, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !17
  %73 = load i32, ptr %7, align 4, !tbaa !11
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._VlAIB, ptr %74, i32 0, i32 10
  %76 = load i32, ptr %75, align 4, !tbaa !16
  %77 = mul i32 %73, %76
  %78 = load i32, ptr %8, align 4, !tbaa !11
  %79 = add i32 %77, %78
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds double, ptr %72, i64 %80
  %82 = load double, ptr %81, align 8, !tbaa !9
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._VlAIB, ptr %83, i32 0, i32 6
  %85 = load ptr, ptr %84, align 8, !tbaa !17
  %86 = load i32, ptr %7, align 4, !tbaa !11
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._VlAIB, ptr %87, i32 0, i32 10
  %89 = load i32, ptr %88, align 4, !tbaa !16
  %90 = mul i32 %86, %89
  %91 = load i32, ptr %8, align 4, !tbaa !11
  %92 = add i32 %90, %91
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds double, ptr %85, i64 %93
  %95 = load double, ptr %94, align 8, !tbaa !9
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct._VlAIB, ptr %96, i32 0, i32 7
  %98 = load ptr, ptr %97, align 8, !tbaa !15
  %99 = load i32, ptr %7, align 4, !tbaa !11
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds double, ptr %98, i64 %100
  %102 = load double, ptr %101, align 8, !tbaa !9
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct._VlAIB, ptr %103, i32 0, i32 8
  %105 = load ptr, ptr %104, align 8, !tbaa !18
  %106 = load i32, ptr %8, align 4, !tbaa !11
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds double, ptr %105, i64 %107
  %109 = load double, ptr %108, align 8, !tbaa !9
  %110 = fmul double %102, %109
  %111 = fdiv double %95, %110
  %112 = call double @log(double noundef %111) #4
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = load double, ptr %113, align 8, !tbaa !9
  %115 = call double @llvm.fmuladd.f64(double %82, double %112, double %114)
  store double %115, ptr %113, align 8, !tbaa !9
  br label %116

116:                                              ; preds = %69, %68
  %117 = load i32, ptr %8, align 4, !tbaa !11
  %118 = add i32 %117, 1
  store i32 %118, ptr %8, align 4, !tbaa !11
  br label %47, !llvm.loop !19

119:                                              ; preds = %47
  br label %120

120:                                              ; preds = %119, %26
  %121 = load i32, ptr %7, align 4, !tbaa !11
  %122 = add i32 %121, 1
  store i32 %122, ptr %7, align 4, !tbaa !11
  br label %11, !llvm.loop !21

123:                                              ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_VlAIB", !6, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !6, i64 80, !6, i64 88, !12, i64 96}
!15 = !{!14, !6, i64 56}
!16 = !{!14, !12, i64 76}
!17 = !{!14, !6, i64 48}
!18 = !{!14, !6, i64 64}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; 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 nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: write) uwtable
define dso_local void @vl_aib_calculate_information(ptr nocapture noundef readonly %0, ptr nocapture noundef %1, ptr nocapture noundef %2) local_unnamed_addr #2 {
  store double 0.000000e+00, ptr %2, align 8, !tbaa !5
  store double 0.000000e+00, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph37

.lr.ph37:                                         ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = getelementptr inbounds i8, ptr %0, i64 76
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  br label %10

10:                                               ; preds = %.lr.ph37, %.loopexit
  %indvars.iv40 = phi i64 [ 0, %.lr.ph37 ], [ %indvars.iv.next41, %.loopexit ]
  %11 = load ptr, ptr %6, align 8, !tbaa !13
  %12 = getelementptr inbounds double, ptr %11, i64 %indvars.iv40
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fcmp oeq double %13, 0.000000e+00
  br i1 %14, label %.loopexit, label %15

15:                                               ; preds = %10
  %16 = tail call double @log(double noundef %13) #3
  %17 = fneg double %16
  %18 = load ptr, ptr %6, align 8, !tbaa !13
  %19 = getelementptr inbounds double, ptr %18, i64 %indvars.iv40
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = load double, ptr %2, align 8, !tbaa !5
  %22 = tail call double @llvm.fmuladd.f64(double %17, double %20, double %21)
  store double %22, ptr %2, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !14
  %.not38 = icmp eq i32 %23, 0
  br i1 %.not38, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %15
  %24 = trunc nuw i64 %indvars.iv40 to i32
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %46
  %25 = phi i32 [ %23, %.lr.ph.preheader ], [ %47, %46 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %46 ]
  %26 = load ptr, ptr %8, align 8, !tbaa !15
  %27 = mul i32 %25, %24
  %28 = trunc nuw i64 %indvars.iv to i32
  %29 = add i32 %27, %28
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds double, ptr %26, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fcmp oeq double %32, 0.000000e+00
  br i1 %33, label %46, label %34

34:                                               ; preds = %.lr.ph
  %35 = load ptr, ptr %6, align 8, !tbaa !13
  %36 = getelementptr inbounds double, ptr %35, i64 %indvars.iv40
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !16
  %39 = getelementptr inbounds double, ptr %38, i64 %indvars.iv
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = fmul double %37, %40
  %42 = fdiv double %32, %41
  %43 = tail call double @log(double noundef %42) #3
  %44 = load double, ptr %1, align 8, !tbaa !5
  %45 = tail call double @llvm.fmuladd.f64(double %32, double %43, double %44)
  store double %45, ptr %1, align 8, !tbaa !5
  %.pre = load i32, ptr %7, align 4, !tbaa !14
  br label %46

46:                                               ; preds = %.lr.ph, %34
  %47 = phi i32 [ %25, %.lr.ph ], [ %.pre, %34 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %48 = zext i32 %47 to i64
  %49 = icmp ult i64 %indvars.iv.next, %48
  br i1 %49, label %.lr.ph, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %46, %15, %10
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %50 = load i32, ptr %4, align 8, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = icmp ult i64 %indvars.iv.next41, %51
  br i1 %52, label %10, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %.loopexit, %3
  ret void
}

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


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