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

; 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._VlScaleSpace = type { %struct._VlScaleSpaceGeometry, ptr }
%struct._VlScaleSpaceGeometry = type { i64, i64, i64, i64, i64, i64, i64, double, double }

; 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

declare void @vl_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @vl_scalespace_delete(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp ne ptr %4, null
  br i1 %5, label %6, label %58

6:                                                ; preds = %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._VlScaleSpace, ptr %7, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %56

11:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._VlScaleSpace, ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %13, i32 0, i32 2
  %15 = load i64, ptr %14, align 8, !tbaa !14
  store i64 %15, ptr %3, align 8, !tbaa !15
  br label %16

16:                                               ; preds = %49, %11
  %17 = load i64, ptr %3, align 8, !tbaa !15
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._VlScaleSpace, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %19, i32 0, i32 3
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = icmp sle i64 %17, %21
  br i1 %22, label %23, label %52

23:                                               ; preds = %16
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._VlScaleSpace, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = load i64, ptr %3, align 8, !tbaa !15
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._VlScaleSpace, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %29, i32 0, i32 2
  %31 = load i64, ptr %30, align 8, !tbaa !14
  %32 = sub nsw i64 %27, %31
  %33 = getelementptr inbounds ptr, ptr %26, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %48

36:                                               ; preds = %23
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._VlScaleSpace, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = load i64, ptr %3, align 8, !tbaa !15
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._VlScaleSpace, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %42, i32 0, i32 2
  %44 = load i64, ptr %43, align 8, !tbaa !14
  %45 = sub nsw i64 %40, %44
  %46 = getelementptr inbounds ptr, ptr %39, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  call void @vl_free(ptr noundef %47)
  br label %48

48:                                               ; preds = %36, %23
  br label %49

49:                                               ; preds = %48
  %50 = load i64, ptr %3, align 8, !tbaa !15
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %3, align 8, !tbaa !15
  br label %16, !llvm.loop !17

52:                                               ; preds = %16
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._VlScaleSpace, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  call void @vl_free(ptr noundef %55)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %56

56:                                               ; preds = %52, %6
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  call void @vl_free(ptr noundef %57)
  br label %58

58:                                               ; preds = %56, %1
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !6, i64 72}
!10 = !{!"_VlScaleSpace", !11, i64 0, !6, i64 72}
!11 = !{!"_VlScaleSpaceGeometry", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !13, i64 56, !13, i64 64}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!10, !12, i64 16}
!15 = !{!12, !12, i64 0}
!16 = !{!10, !12, i64 24}
!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"

declare void @vl_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @vl_scalespace_delete(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %22, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 72
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not15 = icmp eq ptr %4, null
  br i1 %.not15, label %21, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !14
  %.not1618 = icmp sgt i64 %7, %9
  br i1 %.not1618, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %17
  %10 = phi i64 [ %18, %17 ], [ %9, %5 ]
  %.019 = phi i64 [ %19, %17 ], [ %7, %5 ]
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load i64, ptr %6, align 8, !tbaa !13
  %13 = sub nsw i64 %.019, %12
  %14 = getelementptr inbounds ptr, ptr %11, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %.not17 = icmp eq ptr %15, null
  br i1 %.not17, label %17, label %16

16:                                               ; preds = %.lr.ph
  tail call void @vl_free(ptr noundef nonnull %15) #2
  %.pre = load i64, ptr %8, align 8, !tbaa !14
  br label %17

17:                                               ; preds = %.lr.ph, %16
  %18 = phi i64 [ %10, %.lr.ph ], [ %.pre, %16 ]
  %19 = add nsw i64 %.019, 1
  %.not16.not = icmp slt i64 %.019, %18
  br i1 %.not16.not, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !16

._crit_edge.loopexit:                             ; preds = %17
  %.pre20 = load ptr, ptr %3, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %5
  %20 = phi ptr [ %.pre20, %._crit_edge.loopexit ], [ %4, %5 ]
  tail call void @vl_free(ptr noundef %20) #2
  br label %21

21:                                               ; preds = %._crit_edge, %2
  tail call void @vl_free(ptr noundef nonnull %0) #2
  br label %22

22:                                               ; preds = %21, %1
  ret void
}

attributes #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 = { 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, !12, i64 72}
!6 = !{!"_VlScaleSpace", !7, i64 0, !12, i64 72}
!7 = !{!"_VlScaleSpaceGeometry", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !11, i64 56, !11, i64 64}
!8 = !{!"long long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!6, !8, i64 16}
!14 = !{!6, !8, i64 24}
!15 = !{!12, !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass