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

@stderr = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [108 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @SIFT3D_detect_keypoints(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  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
  %8 = load ptr, ptr %6, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._Image, ptr %8, i32 0, i32 13
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %11 = icmp ne i32 %10, 1
  br i1 %11, label %12, label %18

12:                                               ; preds = %3
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._Image, ptr %14, i32 0, i32 13
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef @.str.8, i32 noundef %16) #2
  store i32 -1, ptr %4, align 4
  br label %47

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call i32 @set_im_SIFT3D(ptr noundef %19, ptr noundef %20)
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  store i32 -1, ptr %4, align 4
  br label %47

24:                                               ; preds = %18
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call i32 @build_gpyr(ptr noundef %25)
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  store i32 -1, ptr %4, align 4
  br label %47

29:                                               ; preds = %24
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call i32 @build_dog(ptr noundef %30)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %29
  store i32 -1, ptr %4, align 4
  br label %47

34:                                               ; preds = %29
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call i32 @detect_extrema(ptr noundef %35, ptr noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  store i32 -1, ptr %4, align 4
  br label %47

40:                                               ; preds = %34
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = call i32 @assign_orientations(ptr noundef %41, ptr noundef %42)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %40
  store i32 -1, ptr %4, align 4
  br label %47

46:                                               ; preds = %40
  store i32 0, ptr %4, align 4
  br label %47

47:                                               ; preds = %46, %45, %39, %33, %28, %23, %12
  %48 = load i32, ptr %4, align 4
  ret i32 %48
}

; Function Attrs: nounwind uwtable
declare hidden i32 @build_gpyr(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @build_dog(ptr noundef) #1

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

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

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, !11, i64 96}
!10 = !{!"_Image", !6, i64 0, !11, i64 8, !12, i64 16, !13, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !11, i64 96, !11, i64 100}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"long", !7, i64 0}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [108 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @SIFT3D_detect_keypoints(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %1, i64 96
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 1
  br i1 %.not, label %9, label %6

6:                                                ; preds = %3
  %7 = load ptr, ptr @stderr, align 8, !tbaa !13
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.8, i32 noundef %5) #2
  br label %19

9:                                                ; preds = %3
  %10 = tail call i32 @set_im_SIFT3D(ptr noundef %0, ptr noundef nonnull %1)
  %.not11 = icmp eq i32 %10, 0
  br i1 %.not11, label %11, label %19

11:                                               ; preds = %9
  %12 = tail call i32 @build_gpyr(ptr noundef %0)
  %.not12 = icmp eq i32 %12, 0
  br i1 %.not12, label %13, label %19

13:                                               ; preds = %11
  %14 = tail call i32 @build_dog(ptr noundef %0)
  %.not13 = icmp eq i32 %14, 0
  br i1 %.not13, label %15, label %19

15:                                               ; preds = %13
  %16 = tail call i32 @detect_extrema(ptr noundef %0, ptr noundef %2)
  %.not14 = icmp eq i32 %16, 0
  br i1 %.not14, label %17, label %19

17:                                               ; preds = %15
  %18 = tail call i32 @assign_orientations(ptr noundef %0, ptr noundef %2)
  %.not15 = icmp ne i32 %18, 0
  %. = sext i1 %.not15 to i32
  br label %19

19:                                               ; preds = %17, %15, %13, %11, %9, %6
  %.0 = phi i32 [ -1, %6 ], [ -1, %9 ], [ -1, %11 ], [ -1, %13 ], [ -1, %15 ], [ %., %17 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @build_gpyr(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @build_dog(ptr noundef) local_unnamed_addr #1

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

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

attributes #0 = { nofree 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 = { cold 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, !10, i64 96}
!6 = !{!"_Image", !7, i64 0, !10, i64 8, !11, i64 16, !12, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !10, i64 96, !10, i64 100}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!7, !7, i64 0}


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