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

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind noalias writable sret(%struct._VlScaleSpaceOctaveGeometry) align 8 %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i64 %2, ptr %5, align 8, !tbaa !9
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = sub nsw i64 0, %6
  %8 = icmp sge i64 %7, 0
  br i1 %8, label %9, label %17

9:                                                ; preds = %3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._VlScaleSpace, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = sub nsw i64 0, %14
  %16 = shl i64 %13, %15
  br label %26

17:                                               ; preds = %3
  %18 = load ptr, ptr %4, 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 0
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = sub nsw i64 0, %22
  %24 = sub nsw i64 0, %23
  %25 = lshr i64 %21, %24
  br label %26

26:                                               ; preds = %17, %9
  %27 = phi i64 [ %16, %9 ], [ %25, %17 ]
  %28 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %0, i32 0, i32 0
  store i64 %27, ptr %28, align 8, !tbaa !15
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = sub nsw i64 0, %29
  %31 = icmp sge i64 %30, 0
  br i1 %31, label %32, label %40

32:                                               ; preds = %26
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._VlScaleSpace, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !17
  %37 = load i64, ptr %5, align 8, !tbaa !9
  %38 = sub nsw i64 0, %37
  %39 = shl i64 %36, %38
  br label %49

40:                                               ; preds = %26
  %41 = load ptr, ptr %4, 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 1
  %44 = load i64, ptr %43, align 8, !tbaa !17
  %45 = load i64, ptr %5, align 8, !tbaa !9
  %46 = sub nsw i64 0, %45
  %47 = sub nsw i64 0, %46
  %48 = lshr i64 %44, %47
  br label %49

49:                                               ; preds = %40, %32
  %50 = phi i64 [ %39, %32 ], [ %48, %40 ]
  %51 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %0, i32 0, i32 1
  store i64 %50, ptr %51, align 8, !tbaa !18
  %52 = load i64, ptr %5, align 8, !tbaa !9
  %53 = sitofp i64 %52 to double
  %54 = call double @pow(double noundef 2.000000e+00, double noundef %53) #2
  %55 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %0, i32 0, i32 2
  store double %54, ptr %55, align 8, !tbaa !19
  ret void
}

attributes #0 = { 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 #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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_VlScaleSpace", !13, i64 0, !6, i64 72}
!13 = !{!"_VlScaleSpaceGeometry", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !14, i64 56, !14, i64 64}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"_VlScaleSpaceOctaveGeometry", !10, i64 0, !10, i64 8, !14, i64 16}
!17 = !{!12, !10, i64 8}
!18 = !{!16, !10, i64 8}
!19 = !{!16, !14, i64 16}


; 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"

%struct._VlScaleSpaceOctaveGeometry = type { i64, i64, double }

; Function Attrs: nounwind uwtable
define dso_local void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct._VlScaleSpaceOctaveGeometry) align 8 %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = icmp slt i64 %2, 1
  br i1 %4, label %5, label %12

5:                                                ; preds = %3
  %6 = sub nsw i64 0, %2
  %7 = load i64, ptr %1, align 8, !tbaa !5
  %8 = shl i64 %7, %6
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !13
  %11 = shl i64 %10, %6
  br label %18

12:                                               ; preds = %3
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = lshr i64 %13, %2
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !13
  %17 = lshr i64 %16, %2
  br label %18

18:                                               ; preds = %12, %5
  %.sink = phi i64 [ %8, %5 ], [ %14, %12 ]
  %19 = phi i64 [ %11, %5 ], [ %17, %12 ]
  store i64 %.sink, ptr %0, align 8
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %19, ptr %20, align 8, !tbaa !14
  %21 = sitofp i64 %2 to double
  %exp2 = tail call double @exp2(double %21) #1
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  store double %exp2, ptr %22, align 8, !tbaa !16
  ret void
}

declare double @exp2(double) local_unnamed_addr

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 = { 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, !8, i64 0}
!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 8}
!14 = !{!15, !8, i64 8}
!15 = !{!"_VlScaleSpaceOctaveGeometry", !8, i64 0, !8, i64 8, !11, i64 16}
!16 = !{!15, !11, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass