; LLVM IR from casensiom/fast-image-processing :: src (edges)

; 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.SImage = type { i32, i32, i32, i32, ptr }
%struct.SPolar = type { float, float }

@input_filename = external dso_local global ptr, align 8
@hough_threshold = external dso_local global i32, align 4
@canny_min_threshold = external dso_local global i32, align 4
@canny_max_threshold = external dso_local global i32, align 4
@apply_canny = external dso_local global i32, align 4
@max_lines = external dso_local global i32, align 4
@verbose = external dso_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [31 x i8], align 1

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

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @print_help() #0

declare i32 @printf(ptr noundef, ...) #2

; 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 i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca %struct.SImage, align 8
  %10 = alloca %struct.SImage, align 8
  %11 = alloca %struct.SImage, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.SImage, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %struct.SImage, align 8
  %19 = alloca i32, align 4
  %20 = alloca %struct.SImage, align 8
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  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
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !9
  %25 = call i32 @get_args(i32 noundef %23, ptr noundef %24)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %2
  call void @print_help()
  store i32 0, ptr %3, align 4
  br label %161

28:                                               ; preds = %2
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  %30 = load ptr, ptr @input_filename, align 8, !tbaa !9
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.23, ptr noundef @.str.6, ptr noundef %30)
  %32 = load i32, ptr @hough_threshold, align 4, !tbaa !5
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.24, ptr noundef @.str.2, i32 noundef %32)
  %34 = load i32, ptr @canny_min_threshold, align 4, !tbaa !5
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.24, ptr noundef @.str.3, i32 noundef %34)
  %36 = load i32, ptr @canny_max_threshold, align 4, !tbaa !5
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.24, ptr noundef @.str.4, i32 noundef %36)
  %38 = load i32, ptr @max_lines, align 4, !tbaa !5
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.24, ptr noundef @.str.5, i32 noundef %38)
  %40 = load i32, ptr @apply_canny, align 4, !tbaa !5
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %28
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.25, ptr noundef @.str.1)
  br label %44

44:                                               ; preds = %42, %28
  %45 = load i32, ptr @verbose, align 4, !tbaa !5
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %47, label %49

47:                                               ; preds = %44
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.25, ptr noundef @.str.7)
  br label %49

49:                                               ; preds = %47, %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %50 = load i32, ptr @max_lines, align 4, !tbaa !5
  store i32 %50, ptr %6, align 4, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = zext i32 %51 to i64
  %53 = call ptr @llvm.stacksave.p0()
  store ptr %53, ptr %7, align 8
  %54 = alloca %struct.SPolar, i64 %52, align 16
  store i64 %52, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #5
  call void @reset_image(ptr noundef %9)
  call void @reset_image(ptr noundef %10)
  call void @reset_image(ptr noundef %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %55 = load ptr, ptr @input_filename, align 8, !tbaa !9
  %56 = call i32 @load_image(ptr noundef %55, ptr noundef %9)
  store i32 %56, ptr %12, align 4, !tbaa !5
  %57 = load i32, ptr %12, align 4, !tbaa !5
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %99

59:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 350, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #5
  %60 = load i32, ptr %13, align 4, !tbaa !5
  %61 = load i32, ptr %13, align 4, !tbaa !5
  call void @create_image(ptr dead_on_unwind writable sret(%struct.SImage) align 8 %14, i32 noundef %60, i32 noundef %61, i32 noundef 1)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %14, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %93, %59
  %63 = load i32, ptr %15, align 4, !tbaa !5
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = icmp ult i32 %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  store i32 2, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %96

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %89, %67
  %69 = load i32, ptr %17, align 4, !tbaa !5
  %70 = load i32, ptr %13, align 4, !tbaa !5
  %71 = icmp ult i32 %69, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %68
  store i32 5, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %92

73:                                               ; preds = %68
  %74 = load i32, ptr %17, align 4, !tbaa !5
  %75 = urem i32 %74, 255
  %76 = load i32, ptr %15, align 4, !tbaa !5
  %77 = urem i32 %76, 255
  %78 = xor i32 %75, %77
  %79 = trunc i32 %78 to i8
  %80 = getelementptr inbounds %struct.SImage, ptr %9, i32 0, i32 4
  %81 = load ptr, ptr %80, align 8, !tbaa !12
  %82 = load i32, ptr %17, align 4, !tbaa !5
  %83 = load i32, ptr %15, align 4, !tbaa !5
  %84 = load i32, ptr %13, align 4, !tbaa !5
  %85 = mul i32 %83, %84
  %86 = add i32 %82, %85
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %81, i64 %87
  store i8 %79, ptr %88, align 1, !tbaa !14
  br label %89

89:                                               ; preds = %73
  %90 = load i32, ptr %17, align 4, !tbaa !5
  %91 = add i32 %90, 1
  store i32 %91, ptr %17, align 4, !tbaa !5
  br label %68, !llvm.loop !15

92:                                               ; preds = %72
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %15, align 4, !tbaa !5
  %95 = add i32 %94, 1
  store i32 %95, ptr %15, align 4, !tbaa !5
  br label %62, !llvm.loop !17

96:                                               ; preds = %66
  %97 = load ptr, ptr @input_filename, align 8, !tbaa !9
  %98 = call i32 @save_image(ptr noundef %97, ptr noundef %9)
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %99

99:                                               ; preds = %96, %49
  %100 = load i32, ptr %12, align 4, !tbaa !5
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %148

102:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #5
  call void @convertToGray(ptr dead_on_unwind writable sret(%struct.SImage) align 8 %18, ptr noundef byval(%struct.SImage) align 8 %9)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %18, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #5
  call void @copy_image(ptr noundef %10, ptr noundef %11)
  %103 = load i32, ptr @apply_canny, align 4, !tbaa !5
  %104 = icmp eq i32 %103, 1
  br i1 %104, label %105, label %114

105:                                              ; preds = %102
  %106 = getelementptr inbounds %struct.SImage, ptr %11, i32 0, i32 4
  %107 = load ptr, ptr %106, align 8, !tbaa !12
  %108 = getelementptr inbounds %struct.SImage, ptr %11, i32 0, i32 0
  %109 = load i32, ptr %108, align 8, !tbaa !18
  %110 = getelementptr inbounds %struct.SImage, ptr %11, i32 0, i32 1
  %111 = load i32, ptr %110, align 4, !tbaa !19
  %112 = load i32, ptr @canny_min_threshold, align 4, !tbaa !5
  %113 = load i32, ptr @canny_max_threshold, align 4, !tbaa !5
  call void @canny(ptr noundef %107, i32 noundef %109, i32 noundef %111, i32 noundef %112, i32 noundef %113)
  br label %114

114:                                              ; preds = %105, %102
  %115 = call i32 @save_image(ptr noundef @.str.26, ptr noundef %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %116 = getelementptr inbounds %struct.SImage, ptr %11, i32 0, i32 4
  %117 = load ptr, ptr %116, align 8, !tbaa !12
  %118 = getelementptr inbounds %struct.SImage, ptr %11, i32 0, i32 0
  %119 = load i32, ptr %118, align 8, !tbaa !18
  %120 = getelementptr inbounds %struct.SImage, ptr %11, i32 0, i32 1
  %121 = load i32, ptr %120, align 4, !tbaa !19
  %122 = load i32, ptr @hough_threshold, align 4, !tbaa !5
  %123 = load i32, ptr %6, align 4, !tbaa !5
  %124 = call i32 @hough(ptr noundef %117, i32 noundef %119, i32 noundef %121, i32 noundef %122, ptr noundef %54, i32 noundef %123)
  store i32 %124, ptr %19, align 4, !tbaa !5
  call void @save_hough_workspace(ptr noundef @.str.27)
  %125 = load i32, ptr %19, align 4, !tbaa !5
  %126 = call i32 (ptr, ...) @printf(ptr noundef @.str.28, i32 noundef %125)
  %127 = call i32 (ptr, ...) @printf(ptr noundef @.str.29)
  call void @release_image(ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 24, ptr %20) #5
  call void @convertToARGB(ptr dead_on_unwind writable sret(%struct.SImage) align 8 %20, ptr noundef byval(%struct.SImage) align 8 %11)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %20, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  store i32 0, ptr %21, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %143, %114
  %129 = load i32, ptr %21, align 4, !tbaa !5
  %130 = load i32, ptr %19, align 4, !tbaa !5
  %131 = icmp ult i32 %129, %130
  br i1 %131, label %132, label %146

132:                                              ; preds = %128
  %133 = load i32, ptr %21, align 4, !tbaa !5
  %134 = zext i32 %133 to i64
  %135 = getelementptr inbounds %struct.SPolar, ptr %54, i64 %134
  %136 = getelementptr inbounds %struct.SPolar, ptr %135, i32 0, i32 1
  %137 = load float, ptr %136, align 4, !tbaa !20
  %138 = load i32, ptr %21, align 4, !tbaa !5
  %139 = zext i32 %138 to i64
  %140 = getelementptr inbounds %struct.SPolar, ptr %54, i64 %139
  %141 = getelementptr inbounds %struct.SPolar, ptr %140, i32 0, i32 0
  %142 = load float, ptr %141, align 8, !tbaa !23
  call void @draw(ptr noundef %9, float noundef %137, float noundef %142)
  br label %143

143:                                              ; preds = %132
  %144 = load i32, ptr %21, align 4, !tbaa !5
  %145 = add i32 %144, 1
  store i32 %145, ptr %21, align 4, !tbaa !5
  br label %128, !llvm.loop !24

146:                                              ; preds = %128
  %147 = call i32 @save_image(ptr noundef @.str.30, ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %159

148:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  store ptr @.str.31, ptr %22, align 8, !tbaa !9
  %149 = load i32, ptr %12, align 4, !tbaa !5
  switch i32 %149, label %155 [
    i32 0, label %150
    i32 1, label %151
    i32 2, label %152
    i32 3, label %153
    i32 4, label %154
  ]

150:                                              ; preds = %148
  store ptr @.str.32, ptr %22, align 8, !tbaa !9
  br label %155

151:                                              ; preds = %148
  store ptr @.str.33, ptr %22, align 8, !tbaa !9
  br label %155

152:                                              ; preds = %148
  store ptr @.str.34, ptr %22, align 8, !tbaa !9
  br label %155

153:                                              ; preds = %148
  store ptr @.str.35, ptr %22, align 8, !tbaa !9
  br label %155

154:                                              ; preds = %148
  store ptr @.str.36, ptr %22, align 8, !tbaa !9
  br label %155

155:                                              ; preds = %154, %153, %152, %151, %150, %148
  %156 = load ptr, ptr %22, align 8, !tbaa !9
  %157 = load ptr, ptr @input_filename, align 8, !tbaa !9
  %158 = call i32 (ptr, ...) @printf(ptr noundef @.str.37, ptr noundef %156, ptr noundef %157)
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  br label %159

159:                                              ; preds = %155, %146
  call void @release_image(ptr noundef %9)
  call void @release_image(ptr noundef %10)
  call void @release_image(ptr noundef %11)
  call void (...) @release_canny()
  call void (...) @release_hough()
  store i32 0, ptr %3, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #5
  %160 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %160)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %161

161:                                              ; preds = %159, %27
  %162 = load i32, ptr %3, align 4
  ret i32 %162
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

declare void @reset_image(ptr noundef) #2

declare i32 @load_image(ptr noundef, ptr noundef) #2

declare void @create_image(ptr dead_on_unwind writable sret(%struct.SImage) align 8, i32 noundef, i32 noundef, i32 noundef) #2

; 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) #4

declare i32 @save_image(ptr noundef, ptr noundef) #2

declare void @convertToGray(ptr dead_on_unwind writable sret(%struct.SImage) align 8, ptr noundef byval(%struct.SImage) align 8) #2

declare void @copy_image(ptr noundef, ptr noundef) #2

declare void @canny(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

declare i32 @hough(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #2

declare void @save_hough_workspace(ptr noundef) #2

declare void @release_image(ptr noundef) #2

declare void @convertToARGB(ptr dead_on_unwind writable sret(%struct.SImage) align 8, ptr noundef byval(%struct.SImage) align 8) #2

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

declare void @release_canny(...) #2

declare void @release_hough(...) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { "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 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 12, i64 4, !5, i64 16, i64 8, !9}
!12 = !{!13, !10, i64 16}
!13 = !{!"SImage", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!13, !6, i64 0}
!19 = !{!13, !6, i64 4}
!20 = !{!21, !22, i64 4}
!21 = !{!"SPolar", !22, i64 0, !22, i64 4}
!22 = !{!"float", !7, i64 0}
!23 = !{!21, !22, i64 0}
!24 = distinct !{!24, !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.SImage = type { i32, i32, i32, i32, ptr }
%struct.SPolar = type { float, float }

@input_filename = external dso_local local_unnamed_addr global ptr, align 8
@hough_threshold = external dso_local local_unnamed_addr global i32, align 4
@canny_min_threshold = external dso_local local_unnamed_addr global i32, align 4
@canny_max_threshold = external dso_local local_unnamed_addr global i32, align 4
@apply_canny = external dso_local local_unnamed_addr global i32, align 4
@max_lines = external dso_local local_unnamed_addr global i32, align 4
@verbose = external dso_local local_unnamed_addr global i32, align 4
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [14 x i8], align 1

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

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @print_help() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.SImage, align 8
  %4 = alloca %struct.SImage, align 8
  %5 = alloca %struct.SImage, align 8
  %6 = alloca %struct.SImage, align 8
  %7 = alloca %struct.SImage, align 8
  %8 = alloca %struct.SImage, align 8
  %9 = tail call i32 @get_args(i32 noundef %0, ptr noundef %1)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %11, label %10

10:                                               ; preds = %2
  tail call void @print_help()
  br label %90

11:                                               ; preds = %2
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22)
  %13 = load ptr, ptr @input_filename, align 8, !tbaa !5
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.23, ptr noundef nonnull @.str.6, ptr noundef %13)
  %15 = load i32, ptr @hough_threshold, align 4, !tbaa !9
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24, ptr noundef nonnull @.str.2, i32 noundef %15)
  %17 = load i32, ptr @canny_min_threshold, align 4, !tbaa !9
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24, ptr noundef nonnull @.str.3, i32 noundef %17)
  %19 = load i32, ptr @canny_max_threshold, align 4, !tbaa !9
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24, ptr noundef nonnull @.str.4, i32 noundef %19)
  %21 = load i32, ptr @max_lines, align 4, !tbaa !9
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24, ptr noundef nonnull @.str.5, i32 noundef %21)
  %23 = load i32, ptr @apply_canny, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %11
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.25, ptr noundef nonnull @.str.1)
  br label %27

27:                                               ; preds = %25, %11
  %28 = load i32, ptr @verbose, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.25, ptr noundef nonnull @.str.7)
  br label %32

32:                                               ; preds = %30, %27
  %33 = load i32, ptr @max_lines, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = tail call ptr @llvm.stacksave.p0()
  %36 = alloca %struct.SPolar, i64 %34, align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  call void @reset_image(ptr noundef nonnull %3) #6
  call void @reset_image(ptr noundef nonnull %4) #6
  call void @reset_image(ptr noundef nonnull %5) #6
  %37 = load ptr, ptr @input_filename, align 8, !tbaa !5
  %38 = call i32 @load_image(ptr noundef %37, ptr noundef nonnull %3) #6
  %.not34 = icmp eq i32 %38, 0
  br i1 %.not34, label %63, label %39

39:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #6
  call void @create_image(ptr dead_on_unwind nonnull writable sret(%struct.SImage) align 8 %6, i32 noundef 350, i32 noundef 350, i32 noundef 1) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %6, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #6
  %40 = getelementptr inbounds i8, ptr %3, i64 16
  br label %.preheader

.preheader:                                       ; preds = %39, %47
  %indvars.iv40 = phi i64 [ 0, %39 ], [ %indvars.iv.next41, %47 ]
  %41 = trunc nuw nsw i64 %indvars.iv40 to i32
  %42 = urem i32 %41, 255
  %43 = mul nuw nsw i64 %indvars.iv40, 350
  br label %48

44:                                               ; preds = %47
  %45 = load ptr, ptr @input_filename, align 8, !tbaa !5
  %46 = call i32 @save_image(ptr noundef %45, ptr noundef nonnull %3) #6
  br label %63

47:                                               ; preds = %48
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next41, 350
  br i1 %exitcond43.not, label %44, label %.preheader, !llvm.loop !12

48:                                               ; preds = %48, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next.1, %48 ]
  %.cmp = icmp ugt i64 %indvars.iv, 254
  %.urem = zext i1 %.cmp to i32
  %49 = trunc nuw nsw i64 %indvars.iv to i32
  %50 = or disjoint i32 %49, %.urem
  %51 = xor i32 %50, %42
  %52 = trunc i32 %51 to i8
  %53 = load ptr, ptr %40, align 8, !tbaa !14
  %54 = getelementptr inbounds i8, ptr %53, i64 %indvars.iv
  %55 = getelementptr inbounds i8, ptr %54, i64 %43
  store i8 %52, ptr %55, align 1, !tbaa !16
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %.cmp.1 = icmp ugt i64 %indvars.iv, 253
  %.urem.1 = zext i1 %.cmp.1 to i32
  %56 = trunc nuw nsw i64 %indvars.iv.next to i32
  %57 = add nuw nsw i32 %56, %.urem.1
  %58 = xor i32 %57, %42
  %59 = trunc i32 %58 to i8
  %60 = load ptr, ptr %40, align 8, !tbaa !14
  %61 = getelementptr inbounds i8, ptr %60, i64 %indvars.iv.next
  %62 = getelementptr inbounds i8, ptr %61, i64 %43
  store i8 %59, ptr %62, align 1, !tbaa !16
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 350
  br i1 %exitcond.not.1, label %47, label %48, !llvm.loop !17

63:                                               ; preds = %32, %44
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #6
  call void @convertToGray(ptr dead_on_unwind nonnull writable sret(%struct.SImage) align 8 %7, ptr noundef nonnull byval(%struct.SImage) align 8 %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %7, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #6
  call void @copy_image(ptr noundef nonnull %4, ptr noundef nonnull %5) #6
  %64 = load i32, ptr @apply_canny, align 4, !tbaa !9
  %65 = icmp eq i32 %64, 1
  br i1 %65, label %66, label %74

66:                                               ; preds = %63
  %67 = getelementptr inbounds i8, ptr %5, i64 16
  %68 = load ptr, ptr %67, align 8, !tbaa !14
  %69 = load i32, ptr %5, align 8, !tbaa !18
  %70 = getelementptr inbounds i8, ptr %5, i64 4
  %71 = load i32, ptr %70, align 4, !tbaa !19
  %72 = load i32, ptr @canny_min_threshold, align 4, !tbaa !9
  %73 = load i32, ptr @canny_max_threshold, align 4, !tbaa !9
  call void @canny(ptr noundef %68, i32 noundef %69, i32 noundef %71, i32 noundef %72, i32 noundef %73) #6
  br label %74

74:                                               ; preds = %66, %63
  %75 = call i32 @save_image(ptr noundef nonnull @.str.26, ptr noundef nonnull %5) #6
  %76 = getelementptr inbounds i8, ptr %5, i64 16
  %77 = load ptr, ptr %76, align 8, !tbaa !14
  %78 = load i32, ptr %5, align 8, !tbaa !18
  %79 = getelementptr inbounds i8, ptr %5, i64 4
  %80 = load i32, ptr %79, align 4, !tbaa !19
  %81 = load i32, ptr @hough_threshold, align 4, !tbaa !9
  %82 = call i32 @hough(ptr noundef %77, i32 noundef %78, i32 noundef %80, i32 noundef %81, ptr noundef nonnull %36, i32 noundef %33) #6
  call void @save_hough_workspace(ptr noundef nonnull @.str.27) #6
  %83 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.28, i32 noundef %82)
  %84 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.29)
  call void @release_image(ptr noundef nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #6
  call void @convertToARGB(ptr dead_on_unwind nonnull writable sret(%struct.SImage) align 8 %8, ptr noundef nonnull byval(%struct.SImage) align 8 %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %8, i64 24, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #6
  %.not38 = icmp eq i32 %82, 0
  br i1 %.not38, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %74
  %wide.trip.count = zext i32 %82 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv44 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next45, %.lr.ph ]
  %85 = getelementptr inbounds %struct.SPolar, ptr %36, i64 %indvars.iv44
  %86 = getelementptr inbounds i8, ptr %85, i64 4
  %87 = load float, ptr %86, align 4, !tbaa !20
  %88 = load float, ptr %85, align 8, !tbaa !23
  call void @draw(ptr noundef nonnull %3, float noundef %87, float noundef %88)
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond47.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count
  br i1 %exitcond47.not, label %._crit_edge, label %.lr.ph, !llvm.loop !24

._crit_edge:                                      ; preds = %.lr.ph, %74
  %89 = call i32 @save_image(ptr noundef nonnull @.str.30, ptr noundef nonnull %3) #6
  call void @release_image(ptr noundef nonnull %3) #6
  call void @release_image(ptr noundef nonnull %4) #6
  call void @release_image(ptr noundef nonnull %5) #6
  call void (...) @release_canny() #6
  call void (...) @release_hough() #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.stackrestore.p0(ptr %35)
  br label %90

90:                                               ; preds = %._crit_edge, %10
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

declare void @reset_image(ptr noundef) local_unnamed_addr #4

declare i32 @load_image(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @create_image(ptr dead_on_unwind writable sret(%struct.SImage) align 8, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

; 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) #5

declare i32 @save_image(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @convertToGray(ptr dead_on_unwind writable sret(%struct.SImage) align 8, ptr noundef byval(%struct.SImage) align 8) local_unnamed_addr #4

declare void @copy_image(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @canny(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

declare i32 @hough(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare void @save_hough_workspace(ptr noundef) local_unnamed_addr #4

declare void @release_image(ptr noundef) local_unnamed_addr #4

declare void @convertToARGB(ptr dead_on_unwind writable sret(%struct.SImage) align 8, ptr noundef byval(%struct.SImage) align 8) local_unnamed_addr #4

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

declare void @release_canny(...) local_unnamed_addr #4

declare void @release_hough(...) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 8, !5}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !6, i64 16}
!15 = !{!"SImage", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !13}
!18 = !{!15, !10, i64 0}
!19 = !{!15, !10, i64 4}
!20 = !{!21, !22, i64 4}
!21 = !{!"SPolar", !22, i64 0, !22, i64 4}
!22 = !{!"float", !7, i64 0}
!23 = !{!21, !22, i64 0}
!24 = distinct !{!24, !13}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass