; LLVM IR from bbrister/SIFT3D :: cli (kpSift3D)

; 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.option = type { ptr, i32, ptr, i32 }
%struct._Image = type { ptr, i32, double, i64, i32, i32, i32, double, double, double, i64, i64, i64, i32, i32 }
%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._Keypoint_store = type { ptr, %struct._Slab, i32, i32, i32 }
%struct._Slab = type { ptr, i64, i64 }
%struct._SIFT3D_Descriptor_store = type { ptr, i64, i32, i32, i32 }
%struct._Mat_rm = type { %union.anon, i64, i32, i32, i32, i32 }
%union.anon = type { ptr }

@help_msg = external dso_local constant [617 x i8], align 16
@__const.main.longopts = external hidden unnamed_addr constant [4 x %struct.option], align 16
@.str.3 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@opterr = external global i32, align 4
@.str.5 = external hidden unnamed_addr constant [1 x i8], align 1
@optarg = external global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@optind = external global i32, align 4
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct._Image, align 8
  %7 = alloca %struct._SIFT3D, align 8
  %8 = alloca %struct._Keypoint_store, align 8
  %9 = alloca %struct._SIFT3D_Descriptor_store, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca [4 x %struct.option], align 16
  %17 = alloca i32, align 4
  %18 = alloca [1024 x i8], align 16
  %19 = alloca [1024 x i8], align 16
  %20 = alloca %struct._Image, align 8
  %21 = alloca %struct._Mat_rm, align 8
  %22 = alloca [1024 x i8], align 16
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 104, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 304, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 48, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr %16) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %16, ptr align 16 @__const.main.longopts, i64 128, i1 false)
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !9
  %25 = call i32 @parse_gnu(i32 noundef %23, ptr noundef %24)
  switch i32 %25, label %29 [
    i32 1, label %26
    i32 2, label %28
    i32 0, label %30
  ]

26:                                               ; preds = %2
  %27 = call i32 @puts(ptr noundef @help_msg)
  call void @print_opts_SIFT3D()
  store i32 0, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

28:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

29:                                               ; preds = %2
  call void @err_msgu(ptr noundef @.str.3)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

30:                                               ; preds = %2
  %31 = call i32 @init_SIFT3D(ptr noundef %7)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  call void @err_msgu(ptr noundef @.str.4)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

34:                                               ; preds = %30
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = call i32 @parse_args_SIFT3D(ptr noundef %7, i32 noundef %35, ptr noundef %36, i32 noundef 0)
  store i32 %37, ptr %4, align 4, !tbaa !5
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

40:                                               ; preds = %34
  store i32 1, ptr @opterr, align 4, !tbaa !5
  store ptr null, ptr %13, align 8, !tbaa !9
  store ptr null, ptr %12, align 8, !tbaa !9
  store ptr null, ptr %11, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %57, %40
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = getelementptr inbounds [4 x %struct.option], ptr %16, i64 0, i64 0
  %45 = call i32 @getopt_long(i32 noundef %42, ptr noundef %43, ptr noundef @.str.5, ptr noundef %44, ptr noundef null) #5
  store i32 %45, ptr %14, align 4, !tbaa !5
  %46 = icmp ne i32 %45, -1
  br i1 %46, label %47, label %58

47:                                               ; preds = %41
  %48 = load i32, ptr %14, align 4, !tbaa !5
  switch i32 %48, label %56 [
    i32 97, label %49
    i32 98, label %51
    i32 99, label %53
    i32 63, label %55
  ]

49:                                               ; preds = %47
  %50 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %50, ptr %11, align 8, !tbaa !9
  br label %57

51:                                               ; preds = %47
  %52 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %52, ptr %12, align 8, !tbaa !9
  br label %57

53:                                               ; preds = %47
  %54 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %54, ptr %13, align 8, !tbaa !9
  br label %57

55:                                               ; preds = %47
  br label %56

56:                                               ; preds = %55, %47
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

57:                                               ; preds = %53, %51, %49
  br label %41, !llvm.loop !11

58:                                               ; preds = %41
  %59 = load ptr, ptr %11, align 8, !tbaa !9
  %60 = icmp eq ptr %59, null
  br i1 %60, label %61, label %68

61:                                               ; preds = %58
  %62 = load ptr, ptr %12, align 8, !tbaa !9
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %68

64:                                               ; preds = %61
  %65 = load ptr, ptr %13, align 8, !tbaa !9
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %64
  call void @err_msg(ptr noundef @.str.6)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

68:                                               ; preds = %64, %61, %58
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = load i32, ptr @optind, align 4, !tbaa !5
  %71 = sub nsw i32 %69, %70
  store i32 %71, ptr %15, align 4, !tbaa !5
  %72 = load i32, ptr %15, align 4, !tbaa !5
  %73 = icmp slt i32 %72, 1
  br i1 %73, label %74, label %75

74:                                               ; preds = %68
  call void @err_msg(ptr noundef @.str.7)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

75:                                               ; preds = %68
  %76 = load i32, ptr %15, align 4, !tbaa !5
  %77 = icmp sgt i32 %76, 1
  br i1 %77, label %78, label %79

78:                                               ; preds = %75
  call void @err_msg(ptr noundef @.str.8)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

79:                                               ; preds = %75
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr %5, align 8, !tbaa !9
  %82 = load i32, ptr @optind, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds ptr, ptr %81, i64 %83
  %85 = load ptr, ptr %84, align 8, !tbaa !9
  store ptr %85, ptr %10, align 8, !tbaa !9
  call void @init_Keypoint_store(ptr noundef %8)
  call void @init_SIFT3D_Descriptor_store(ptr noundef %9)
  call void @init_im(ptr noundef %6)
  %86 = load ptr, ptr %10, align 8, !tbaa !9
  %87 = call i32 @im_read(ptr noundef %86, ptr noundef %6)
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %80
  call void @err_msg(ptr noundef @.str.9)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

90:                                               ; preds = %80
  %91 = call i32 @SIFT3D_detect_keypoints(ptr noundef %7, ptr noundef %6, ptr noundef %8)
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %94

93:                                               ; preds = %90
  call void @err_msgu(ptr noundef @.str.10)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

94:                                               ; preds = %90
  %95 = load ptr, ptr %11, align 8, !tbaa !9
  %96 = icmp ne ptr %95, null
  br i1 %96, label %97, label %106

97:                                               ; preds = %94
  %98 = load ptr, ptr %11, align 8, !tbaa !9
  %99 = call i32 @write_Keypoint_store(ptr noundef %98, ptr noundef %8)
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %101, label %106

101:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 1024, ptr %18) #5
  %102 = getelementptr inbounds [1024 x i8], ptr %18, i64 0, i64 0
  %103 = load ptr, ptr %11, align 8, !tbaa !9
  %104 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %102, i64 noundef 1024, ptr noundef @.str.11, ptr noundef %103) #5
  %105 = getelementptr inbounds [1024 x i8], ptr %18, i64 0, i64 0
  call void @err_msg(ptr noundef %105)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %18) #5
  br label %153

106:                                              ; preds = %97, %94
  %107 = load ptr, ptr %12, align 8, !tbaa !9
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %123

109:                                              ; preds = %106
  %110 = call i32 @SIFT3D_extract_descriptors(ptr noundef %7, ptr noundef %8, ptr noundef %9)
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %113

112:                                              ; preds = %109
  call void @err_msgu(ptr noundef @.str.12)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

113:                                              ; preds = %109
  %114 = load ptr, ptr %12, align 8, !tbaa !9
  %115 = call i32 @write_SIFT3D_Descriptor_store(ptr noundef %114, ptr noundef %9)
  %116 = icmp ne i32 %115, 0
  br i1 %116, label %117, label %122

117:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 1024, ptr %19) #5
  %118 = getelementptr inbounds [1024 x i8], ptr %19, i64 0, i64 0
  %119 = load ptr, ptr %12, align 8, !tbaa !9
  %120 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %118, i64 noundef 1024, ptr noundef @.str.13, ptr noundef %119) #5
  %121 = getelementptr inbounds [1024 x i8], ptr %19, i64 0, i64 0
  call void @err_msg(ptr noundef %121)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %19) #5
  br label %153

122:                                              ; preds = %113
  br label %123

123:                                              ; preds = %122, %106
  %124 = load ptr, ptr %13, align 8, !tbaa !9
  %125 = icmp ne ptr %124, null
  br i1 %125, label %126, label %152

126:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 104, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %21) #5
  call void @init_im(ptr noundef %20)
  %127 = call i32 @init_Mat_rm(ptr noundef %21, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %130

129:                                              ; preds = %126
  call void @err_msgu(ptr noundef @.str.14)
  br label %130

130:                                              ; preds = %129, %126
  %131 = call i32 @Keypoint_store_to_Mat_rm(ptr noundef %8, ptr noundef %21)
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %134

133:                                              ; preds = %130
  call void @err_msgu(ptr noundef @.str.15)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %149

134:                                              ; preds = %130
  %135 = getelementptr inbounds %struct._Image, ptr %6, i32 0, i32 4
  %136 = call i32 @draw_points(ptr noundef %21, ptr noundef %135, i32 noundef 1, ptr noundef %20)
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %139

138:                                              ; preds = %134
  call void @err_msgu(ptr noundef @.str.16)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %149

139:                                              ; preds = %134
  %140 = load ptr, ptr %13, align 8, !tbaa !9
  %141 = call i32 @im_write(ptr noundef %140, ptr noundef %20)
  %142 = icmp ne i32 %141, 0
  br i1 %142, label %143, label %148

143:                                              ; preds = %139
  call void @llvm.lifetime.start.p0(i64 1024, ptr %22) #5
  %144 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %145 = load ptr, ptr %13, align 8, !tbaa !9
  %146 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %144, i64 noundef 1024, ptr noundef @.str.17, ptr noundef %145) #5
  %147 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  call void @err_msg(ptr noundef %147)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %22) #5
  br label %149

148:                                              ; preds = %139
  call void @im_free(ptr noundef %20)
  store i32 0, ptr %17, align 4
  br label %149

149:                                              ; preds = %148, %143, %138, %133
  call void @llvm.lifetime.end.p0(i64 32, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 104, ptr %20) #5
  %150 = load i32, ptr %17, align 4
  switch i32 %150, label %153 [
    i32 0, label %151
  ]

151:                                              ; preds = %149
  br label %152

152:                                              ; preds = %151, %123
  store i32 0, ptr %3, align 4
  store i32 1, ptr %17, align 4
  br label %153

153:                                              ; preds = %152, %149, %117, %112, %101, %93, %89, %78, %74, %67, %56, %39, %33, %29, %28, %26
  call void @llvm.lifetime.end.p0(i64 128, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 304, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 104, ptr %6) #5
  %154 = load i32, ptr %3, align 4
  ret i32 %154
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @parse_gnu(i32 noundef, ptr noundef) #3

declare i32 @puts(ptr noundef) #3

declare void @print_opts_SIFT3D() #3

; Function Attrs: nounwind uwtable
declare hidden void @err_msgu(ptr noundef) #0

declare i32 @init_SIFT3D(ptr noundef) #3

declare i32 @parse_args_SIFT3D(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @getopt_long(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @err_msg(ptr noundef) #0

declare void @init_Keypoint_store(ptr noundef) #3

declare void @init_SIFT3D_Descriptor_store(ptr noundef) #3

declare void @init_im(ptr noundef) #3

declare i32 @im_read(ptr noundef, ptr noundef) #3

declare i32 @SIFT3D_detect_keypoints(ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @write_Keypoint_store(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @SIFT3D_extract_descriptors(ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @write_SIFT3D_Descriptor_store(ptr noundef, ptr noundef) #3

declare i32 @init_Mat_rm(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @Keypoint_store_to_Mat_rm(ptr noundef, ptr noundef) #3

declare i32 @draw_points(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare i32 @im_write(ptr noundef, ptr noundef) #3

declare void @im_free(ptr noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 "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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%struct.option = type { ptr, i32, ptr, i32 }
%struct._Image = type { ptr, i32, double, i64, i32, i32, i32, double, double, double, i64, i64, i64, i32, i32 }
%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._Keypoint_store = type { ptr, %struct._Slab, i32, i32, i32 }
%struct._Slab = type { ptr, i64, i64 }
%struct._SIFT3D_Descriptor_store = type { ptr, i64, i32, i32, i32 }
%struct._Mat_rm = type { %union.anon, i64, i32, i32, i32, i32 }
%union.anon = type { ptr }

@help_msg = external dso_local constant [617 x i8], align 16
@__const.main.longopts = external hidden unnamed_addr constant [4 x %struct.option], align 16
@.str.3 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@opterr = external local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [1 x i8], align 1
@optarg = external local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1
@optind = external local_unnamed_addr global i32, align 4
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct._Image, align 8
  %4 = alloca %struct._SIFT3D, align 8
  %5 = alloca %struct._Keypoint_store, align 8
  %6 = alloca %struct._SIFT3D_Descriptor_store, align 8
  %7 = alloca [4 x %struct.option], align 16
  %8 = alloca [1024 x i8], align 16
  %9 = alloca [1024 x i8], align 16
  %10 = alloca %struct._Image, align 8
  %11 = alloca %struct._Mat_rm, align 8
  %12 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 304, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %7) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(128) %7, ptr noundef nonnull align 16 dereferenceable(128) @__const.main.longopts, i64 128, i1 false)
  %13 = tail call i32 @parse_gnu(i32 noundef %0, ptr noundef %1) #6
  switch i32 %13, label %16 [
    i32 1, label %14
    i32 2, label %.loopexit
    i32 0, label %17
  ]

14:                                               ; preds = %2
  %15 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @help_msg)
  tail call void @print_opts_SIFT3D() #6
  br label %.loopexit

16:                                               ; preds = %2
  tail call void @err_msgu(ptr noundef nonnull @.str.3)
  br label %.loopexit

17:                                               ; preds = %2
  %18 = call i32 @init_SIFT3D(ptr noundef nonnull %4) #6
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %20, label %19

19:                                               ; preds = %17
  call void @err_msgu(ptr noundef nonnull @.str.4)
  br label %.loopexit

20:                                               ; preds = %17
  %21 = call i32 @parse_args_SIFT3D(ptr noundef nonnull %4, i32 noundef %0, ptr noundef %1, i32 noundef 0) #6
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %.loopexit, label %23

23:                                               ; preds = %20
  store i32 1, ptr @opterr, align 4, !tbaa !5
  br label %.outer

.outer:                                           ; preds = %26, %23
  %.033.ph = phi ptr [ %27, %26 ], [ null, %23 ]
  %.031.ph = phi ptr [ %.031.ph67, %26 ], [ null, %23 ]
  %.029.ph = phi ptr [ %.029, %26 ], [ null, %23 ]
  br label %.outer66

.outer66:                                         ; preds = %.outer, %28
  %.031.ph67 = phi ptr [ %.031.ph, %.outer ], [ %29, %28 ]
  %.029.ph68 = phi ptr [ %.029.ph, %.outer ], [ %.029, %28 ]
  br label %24

24:                                               ; preds = %.outer66, %30
  %.029 = phi ptr [ %31, %30 ], [ %.029.ph68, %.outer66 ]
  %25 = call i32 @getopt_long(i32 noundef %21, ptr noundef %1, ptr noundef nonnull @.str.5, ptr noundef nonnull %7, ptr noundef null) #6
  switch i32 %25, label %.loopexit [
    i32 -1, label %32
    i32 97, label %26
    i32 98, label %28
    i32 99, label %30
  ]

26:                                               ; preds = %24
  %27 = load ptr, ptr @optarg, align 8, !tbaa !9
  br label %.outer, !llvm.loop !11

28:                                               ; preds = %24
  %29 = load ptr, ptr @optarg, align 8, !tbaa !9
  br label %.outer66, !llvm.loop !11

30:                                               ; preds = %24
  %31 = load ptr, ptr @optarg, align 8, !tbaa !9
  br label %24, !llvm.loop !11

32:                                               ; preds = %24
  %33 = icmp eq ptr %.033.ph, null
  %34 = icmp eq ptr %.031.ph67, null
  %or.cond = select i1 %33, i1 %34, i1 false
  %35 = icmp eq ptr %.029, null
  %or.cond3 = select i1 %or.cond, i1 %35, i1 false
  br i1 %or.cond3, label %36, label %37

36:                                               ; preds = %32
  call void @err_msg(ptr noundef nonnull @.str.6)
  br label %.loopexit

37:                                               ; preds = %32
  %38 = load i32, ptr @optind, align 4, !tbaa !5
  %39 = sub nsw i32 %21, %38
  %40 = icmp slt i32 %39, 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  call void @err_msg(ptr noundef nonnull @.str.7)
  br label %.loopexit

42:                                               ; preds = %37
  %.not39 = icmp eq i32 %39, 1
  br i1 %.not39, label %44, label %43

43:                                               ; preds = %42
  call void @err_msg(ptr noundef nonnull @.str.8)
  br label %.loopexit

44:                                               ; preds = %42
  %45 = sext i32 %38 to i64
  %46 = getelementptr inbounds ptr, ptr %1, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  call void @init_Keypoint_store(ptr noundef nonnull %5) #6
  call void @init_SIFT3D_Descriptor_store(ptr noundef nonnull %6) #6
  call void @init_im(ptr noundef nonnull %3) #6
  %48 = call i32 @im_read(ptr noundef %47, ptr noundef nonnull %3) #6
  %.not40 = icmp eq i32 %48, 0
  br i1 %.not40, label %50, label %49

49:                                               ; preds = %44
  call void @err_msg(ptr noundef nonnull @.str.9)
  br label %.loopexit

50:                                               ; preds = %44
  %51 = call i32 @SIFT3D_detect_keypoints(ptr noundef nonnull %4, ptr noundef nonnull %3, ptr noundef nonnull %5) #6
  %.not41 = icmp eq i32 %51, 0
  br i1 %.not41, label %53, label %52

52:                                               ; preds = %50
  call void @err_msgu(ptr noundef nonnull @.str.10)
  br label %.loopexit

53:                                               ; preds = %50
  br i1 %33, label %58, label %54

54:                                               ; preds = %53
  %55 = call i32 @write_Keypoint_store(ptr noundef nonnull %.033.ph, ptr noundef nonnull %5) #6
  %.not43 = icmp eq i32 %55, 0
  br i1 %.not43, label %58, label %56

56:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %8) #6
  %57 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %8, i64 noundef 1024, ptr noundef nonnull @.str.11, ptr noundef nonnull %.033.ph) #6
  call void @err_msg(ptr noundef nonnull %8)
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %8) #6
  br label %.loopexit

58:                                               ; preds = %54, %53
  br i1 %34, label %66, label %59

59:                                               ; preds = %58
  %60 = call i32 @SIFT3D_extract_descriptors(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6) #6
  %.not45 = icmp eq i32 %60, 0
  br i1 %.not45, label %62, label %61

61:                                               ; preds = %59
  call void @err_msgu(ptr noundef nonnull @.str.12)
  br label %.loopexit

62:                                               ; preds = %59
  %63 = call i32 @write_SIFT3D_Descriptor_store(ptr noundef nonnull %.031.ph67, ptr noundef nonnull %6) #6
  %.not46 = icmp eq i32 %63, 0
  br i1 %.not46, label %66, label %64

64:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %9) #6
  %65 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %9, i64 noundef 1024, ptr noundef nonnull @.str.13, ptr noundef nonnull %.031.ph67) #6
  call void @err_msg(ptr noundef nonnull %9)
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %9) #6
  br label %.loopexit

66:                                               ; preds = %62, %58
  br i1 %35, label %.loopexit, label %67

67:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %10) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %11) #6
  call void @init_im(ptr noundef nonnull %10) #6
  %68 = call i32 @init_Mat_rm(ptr noundef nonnull %11, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0) #6
  %.not48 = icmp eq i32 %68, 0
  br i1 %.not48, label %70, label %69

69:                                               ; preds = %67
  call void @err_msgu(ptr noundef nonnull @.str.14)
  br label %70

70:                                               ; preds = %69, %67
  %71 = call i32 @Keypoint_store_to_Mat_rm(ptr noundef nonnull %5, ptr noundef nonnull %11) #6
  %.not49 = icmp eq i32 %71, 0
  br i1 %.not49, label %73, label %72

72:                                               ; preds = %70
  call void @err_msgu(ptr noundef nonnull @.str.15)
  br label %.thread

73:                                               ; preds = %70
  %74 = getelementptr inbounds i8, ptr %3, i64 32
  %75 = call i32 @draw_points(ptr noundef nonnull %11, ptr noundef nonnull %74, i32 noundef 1, ptr noundef nonnull %10) #6
  %.not50 = icmp eq i32 %75, 0
  br i1 %.not50, label %77, label %76

76:                                               ; preds = %73
  call void @err_msgu(ptr noundef nonnull @.str.16)
  br label %.thread

77:                                               ; preds = %73
  %78 = call i32 @im_write(ptr noundef nonnull %.029, ptr noundef nonnull %10) #6
  %.not51 = icmp eq i32 %78, 0
  br i1 %.not51, label %81, label %79

79:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %12) #6
  %80 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %12, i64 noundef 1024, ptr noundef nonnull @.str.17, ptr noundef nonnull %.029) #6
  call void @err_msg(ptr noundef nonnull %12)
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %12) #6
  br label %.thread

.thread:                                          ; preds = %72, %76, %79
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %10) #6
  br label %.loopexit

81:                                               ; preds = %77
  call void @im_free(ptr noundef nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %10) #6
  br label %.loopexit

.loopexit:                                        ; preds = %24, %66, %81, %.thread, %20, %2, %64, %61, %56, %52, %49, %43, %41, %36, %19, %16, %14
  %.1 = phi i32 [ 1, %16 ], [ 1, %19 ], [ 1, %36 ], [ 1, %41 ], [ 1, %43 ], [ 1, %49 ], [ 1, %52 ], [ 1, %56 ], [ 1, %61 ], [ 1, %64 ], [ 0, %14 ], [ 0, %2 ], [ 1, %20 ], [ 1, %.thread ], [ 0, %81 ], [ 0, %66 ], [ 1, %24 ]
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 304, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %3) #6
  ret i32 %.1
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @parse_gnu(i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4

declare void @print_opts_SIFT3D() local_unnamed_addr #3

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

declare i32 @init_SIFT3D(ptr noundef) local_unnamed_addr #3

declare i32 @parse_args_SIFT3D(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @getopt_long(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

declare void @init_Keypoint_store(ptr noundef) local_unnamed_addr #3

declare void @init_SIFT3D_Descriptor_store(ptr noundef) local_unnamed_addr #3

declare void @init_im(ptr noundef) local_unnamed_addr #3

declare i32 @im_read(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @SIFT3D_detect_keypoints(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @write_Keypoint_store(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @SIFT3D_extract_descriptors(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @write_SIFT3D_Descriptor_store(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @init_Mat_rm(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare i32 @Keypoint_store_to_Mat_rm(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @draw_points(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @im_write(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @im_free(ptr noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 #5 = { 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 #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass