; LLVM IR from bbrister/SIFT3D :: sift3d (sift)

; 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._SIFT3D = type { %struct._Mesh, %struct._GSS_filters, %struct._SIFT_cl_kernels, %struct._Pyramid, %struct._Pyramid, %struct._Image, double, double, i32 }
%struct._Mesh = type { ptr, i32 }
%struct._GSS_filters = type { %struct._Gauss_filter, ptr, i32, i32 }
%struct._Gauss_filter = type { double, %struct._Sep_FIR_filter }
%struct._Sep_FIR_filter = type { i32, ptr, i32, i32, i32 }
%struct._SIFT_cl_kernels = type { i32 }
%struct._Pyramid = type { ptr, double, double, i32, i32, i32, i32, i32 }
%struct._Image = type { ptr, i32, double, i64, i32, i32, i32, double, double, double, i64, i64, i64, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_peak_thresh_SIFT3D(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_corner_thresh_SIFT3D(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_num_kp_levels_SIFT3D(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_sigma_n_SIFT3D(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_sigma0_SIFT3D(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @init_SIFT3D(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @copy_SIFT3D(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  call void @cleanup_SIFT3D(ptr noundef %6)
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = call i32 @init_SIFT3D(ptr noundef %7)
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  br label %80

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._SIFT3D, ptr %13, i32 0, i32 3
  %15 = getelementptr inbounds %struct._Pyramid, ptr %14, i32 0, i32 1
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = call i32 @set_sigma_n_SIFT3D(ptr noundef %12, double noundef %16)
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._SIFT3D, ptr %19, i32 0, i32 3
  %21 = getelementptr inbounds %struct._Pyramid, ptr %20, i32 0, i32 2
  %22 = load double, ptr %21, align 8, !tbaa !21
  %23 = call i32 @set_sigma0_SIFT3D(ptr noundef %18, double noundef %22)
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._SIFT3D, ptr %25, i32 0, i32 6
  %27 = load double, ptr %26, align 8, !tbaa !22
  %28 = call i32 @set_peak_thresh_SIFT3D(ptr noundef %24, double noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %45, label %30

30:                                               ; preds = %11
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._SIFT3D, ptr %32, i32 0, i32 7
  %34 = load double, ptr %33, align 8, !tbaa !23
  %35 = call i32 @set_corner_thresh_SIFT3D(ptr noundef %31, double noundef %34)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %45, label %37

37:                                               ; preds = %30
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._SIFT3D, ptr %39, i32 0, i32 3
  %41 = getelementptr inbounds %struct._Pyramid, ptr %40, i32 0, i32 3
  %42 = load i32, ptr %41, align 8, !tbaa !24
  %43 = call i32 @set_num_kp_levels_SIFT3D(ptr noundef %38, i32 noundef %42)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %37, %30, %11
  store i32 -1, ptr %3, align 4
  br label %80

46:                                               ; preds = %37
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._SIFT3D, ptr %47, i32 0, i32 8
  %49 = load i32, ptr %48, align 8, !tbaa !25
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._SIFT3D, ptr %50, i32 0, i32 8
  store i32 %49, ptr %51, align 8, !tbaa !25
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._SIFT3D, ptr %52, i32 0, i32 5
  %54 = getelementptr inbounds %struct._Image, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !26
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %64

57:                                               ; preds = %46
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._SIFT3D, ptr %59, i32 0, i32 5
  %61 = call i32 @set_im_SIFT3D(ptr noundef %58, ptr noundef %60)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  store i32 -1, ptr %3, align 4
  br label %80

64:                                               ; preds = %57, %46
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._SIFT3D, ptr %65, i32 0, i32 3
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._SIFT3D, ptr %67, i32 0, i32 3
  %69 = call i32 @copy_Pyramid(ptr noundef %66, ptr noundef %68)
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %78, label %71

71:                                               ; preds = %64
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._SIFT3D, ptr %72, i32 0, i32 4
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._SIFT3D, ptr %74, i32 0, i32 4
  %76 = call i32 @copy_Pyramid(ptr noundef %73, ptr noundef %75)
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %79

78:                                               ; preds = %71, %64
  store i32 -1, ptr %3, align 4
  br label %80

79:                                               ; preds = %71
  store i32 0, ptr %3, align 4
  br label %80

80:                                               ; preds = %79, %78, %63, %45, %10
  %81 = load i32, ptr %3, align 4
  ret i32 %81
}

; Function Attrs: nounwind uwtable
declare dso_local void @cleanup_SIFT3D(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @set_im_SIFT3D(ptr noundef, ptr noundef) #0

declare i32 @copy_Pyramid(ptr noundef, ptr noundef) #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 = { "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !15, i64 88}
!10 = !{!"_SIFT3D", !11, i64 0, !13, i64 16, !17, i64 72, !18, i64 80, !18, i64 128, !19, i64 176, !15, i64 280, !15, i64 288, !12, i64 296}
!11 = !{!"_Mesh", !6, i64 0, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_GSS_filters", !14, i64 0, !6, i64 40, !12, i64 48, !12, i64 52}
!14 = !{!"_Gauss_filter", !15, i64 0, !16, i64 8}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_Sep_FIR_filter", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24}
!17 = !{!"_SIFT_cl_kernels", !12, i64 0}
!18 = !{!"_Pyramid", !6, i64 0, !15, i64 8, !15, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40}
!19 = !{!"_Image", !6, i64 0, !12, i64 8, !15, i64 16, !20, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !20, i64 72, !20, i64 80, !20, i64 88, !12, i64 96, !12, i64 100}
!20 = !{!"long", !7, i64 0}
!21 = !{!10, !15, i64 96}
!22 = !{!10, !15, i64 280}
!23 = !{!10, !15, i64 288}
!24 = !{!10, !12, i64 104}
!25 = !{!10, !12, i64 296}
!26 = !{!10, !6, i64 176}


; 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: nounwind uwtable
declare dso_local i32 @set_peak_thresh_SIFT3D(ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_corner_thresh_SIFT3D(ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_num_kp_levels_SIFT3D(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_sigma_n_SIFT3D(ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_sigma0_SIFT3D(ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @init_SIFT3D(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @copy_SIFT3D(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @cleanup_SIFT3D(ptr noundef %1)
  %3 = tail call i32 @init_SIFT3D(ptr noundef %1)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %38

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = tail call i32 @set_sigma_n_SIFT3D(ptr noundef %1, double noundef %7)
  %9 = getelementptr inbounds i8, ptr %0, i64 96
  %10 = load double, ptr %9, align 8, !tbaa !20
  %11 = tail call i32 @set_sigma0_SIFT3D(ptr noundef %1, double noundef %10)
  %12 = getelementptr inbounds i8, ptr %0, i64 280
  %13 = load double, ptr %12, align 8, !tbaa !21
  %14 = tail call i32 @set_peak_thresh_SIFT3D(ptr noundef %1, double noundef %13)
  %.not21 = icmp eq i32 %14, 0
  br i1 %.not21, label %15, label %38

15:                                               ; preds = %4
  %16 = getelementptr inbounds i8, ptr %0, i64 288
  %17 = load double, ptr %16, align 8, !tbaa !22
  %18 = tail call i32 @set_corner_thresh_SIFT3D(ptr noundef %1, double noundef %17)
  %.not22 = icmp eq i32 %18, 0
  br i1 %.not22, label %19, label %38

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %0, i64 104
  %21 = load i32, ptr %20, align 8, !tbaa !23
  %22 = tail call i32 @set_num_kp_levels_SIFT3D(ptr noundef %1, i32 noundef %21)
  %.not23 = icmp eq i32 %22, 0
  br i1 %.not23, label %23, label %38

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %0, i64 296
  %25 = load i32, ptr %24, align 8, !tbaa !24
  %26 = getelementptr inbounds i8, ptr %1, i64 296
  store i32 %25, ptr %26, align 8, !tbaa !24
  %27 = getelementptr inbounds i8, ptr %0, i64 176
  %28 = load ptr, ptr %27, align 8, !tbaa !25
  %.not24 = icmp eq ptr %28, null
  br i1 %.not24, label %31, label %29

29:                                               ; preds = %23
  %30 = tail call i32 @set_im_SIFT3D(ptr noundef nonnull %1, ptr noundef nonnull %27)
  %.not25 = icmp eq i32 %30, 0
  br i1 %.not25, label %31, label %38

31:                                               ; preds = %29, %23
  %32 = getelementptr inbounds i8, ptr %1, i64 80
  %33 = tail call i32 @copy_Pyramid(ptr noundef nonnull %5, ptr noundef nonnull %32) #2
  %.not26 = icmp eq i32 %33, 0
  br i1 %.not26, label %34, label %38

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %0, i64 128
  %36 = getelementptr inbounds i8, ptr %1, i64 128
  %37 = tail call i32 @copy_Pyramid(ptr noundef nonnull %35, ptr noundef nonnull %36) #2
  %.not27 = icmp ne i32 %37, 0
  %spec.select = sext i1 %.not27 to i32
  br label %38

38:                                               ; preds = %34, %31, %29, %4, %15, %19, %2
  %.0 = phi i32 [ -1, %2 ], [ -1, %19 ], [ -1, %15 ], [ -1, %4 ], [ -1, %29 ], [ -1, %31 ], [ %spec.select, %34 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @cleanup_SIFT3D(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @set_im_SIFT3D(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @copy_Pyramid(ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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, !14, i64 88}
!6 = !{!"_SIFT3D", !7, i64 0, !12, i64 16, !16, i64 72, !17, i64 80, !17, i64 128, !18, i64 176, !14, i64 280, !14, i64 288, !11, i64 296}
!7 = !{!"_Mesh", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_GSS_filters", !13, i64 0, !8, i64 40, !11, i64 48, !11, i64 52}
!13 = !{!"_Gauss_filter", !14, i64 0, !15, i64 8}
!14 = !{!"double", !9, i64 0}
!15 = !{!"_Sep_FIR_filter", !11, i64 0, !8, i64 8, !11, i64 16, !11, i64 20, !11, i64 24}
!16 = !{!"_SIFT_cl_kernels", !11, i64 0}
!17 = !{!"_Pyramid", !8, i64 0, !14, i64 8, !14, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40}
!18 = !{!"_Image", !8, i64 0, !11, i64 8, !14, i64 16, !19, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !19, i64 72, !19, i64 80, !19, i64 88, !11, i64 96, !11, i64 100}
!19 = !{!"long", !9, i64 0}
!20 = !{!6, !14, i64 96}
!21 = !{!6, !14, i64 280}
!22 = !{!6, !14, i64 288}
!23 = !{!6, !11, i64 104}
!24 = !{!6, !11, i64 296}
!25 = !{!6, !8, i64 176}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass