; LLVM IR from ljm941004/HYPERCV_PUBLIC :: modules/process/src/c_src (filter)

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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @hypercv_medianblur(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %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 i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %3
  br label %26

22:                                               ; preds = %3
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #5
  unreachable

26:                                               ; preds = %21
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = srem i32 %27, 2
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  br label %35

31:                                               ; preds = %26
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #5
  unreachable

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !11
  store i32 %38, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !13
  store i32 %41, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 8, !tbaa !14
  store i32 %44, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %45, i32 0, i32 3
  %47 = load i32, ptr %46, align 4, !tbaa !15
  store i32 %47, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %48, i32 0, i32 5
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  store ptr %50, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %51, i32 0, i32 5
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  store ptr %53, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = mul nsw i32 %54, %55
  %57 = sext i32 %56 to i64
  %58 = mul i64 %57, 1
  %59 = call noalias ptr @malloc(i64 noundef %58) #7
  store ptr %59, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %187, %35
  %61 = load i32, ptr %14, align 4, !tbaa !9
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 2, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %190

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %183, %65
  %67 = load i32, ptr %16, align 4, !tbaa !9
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

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

71:                                               ; preds = %66
  %72 = load i32, ptr %14, align 4, !tbaa !9
  %73 = load i32, ptr %6, align 4, !tbaa !9
  %74 = sdiv i32 %73, 2
  %75 = sub nsw i32 %72, %74
  %76 = icmp sge i32 %75, 0
  br i1 %76, label %77, label %164

77:                                               ; preds = %71
  %78 = load i32, ptr %14, align 4, !tbaa !9
  %79 = load i32, ptr %6, align 4, !tbaa !9
  %80 = sdiv i32 %79, 2
  %81 = add nsw i32 %78, %80
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = icmp slt i32 %81, %82
  br i1 %83, label %84, label %164

84:                                               ; preds = %77
  %85 = load i32, ptr %16, align 4, !tbaa !9
  %86 = load i32, ptr %6, align 4, !tbaa !9
  %87 = sdiv i32 %86, 2
  %88 = sub nsw i32 %85, %87
  %89 = icmp sge i32 %88, 0
  br i1 %89, label %90, label %164

90:                                               ; preds = %84
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = load i32, ptr %6, align 4, !tbaa !9
  %93 = sdiv i32 %92, 2
  %94 = add nsw i32 %91, %93
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = icmp slt i32 %94, %95
  br i1 %96, label %97, label %164

97:                                               ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %98 = load i32, ptr %6, align 4, !tbaa !9
  %99 = sub nsw i32 0, %98
  %100 = sdiv i32 %99, 2
  store i32 %100, ptr %17, align 4, !tbaa !9
  br label %101

101:                                              ; preds = %149, %97
  %102 = load i32, ptr %17, align 4, !tbaa !9
  %103 = load i32, ptr %6, align 4, !tbaa !9
  %104 = sdiv i32 %103, 2
  %105 = icmp sle i32 %102, %104
  br i1 %105, label %107, label %106

106:                                              ; preds = %101
  store i32 8, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %152

107:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %108 = load i32, ptr %6, align 4, !tbaa !9
  %109 = sub nsw i32 0, %108
  %110 = sdiv i32 %109, 2
  store i32 %110, ptr %18, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %145, %107
  %112 = load i32, ptr %18, align 4, !tbaa !9
  %113 = load i32, ptr %6, align 4, !tbaa !9
  %114 = sdiv i32 %113, 2
  %115 = icmp sle i32 %112, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %111
  store i32 11, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %148

117:                                              ; preds = %111
  %118 = load ptr, ptr %11, align 8, !tbaa !5
  %119 = load i32, ptr %14, align 4, !tbaa !9
  %120 = load i32, ptr %17, align 4, !tbaa !9
  %121 = add nsw i32 %119, %120
  %122 = load i32, ptr %8, align 4, !tbaa !9
  %123 = mul nsw i32 %121, %122
  %124 = load i32, ptr %16, align 4, !tbaa !9
  %125 = add nsw i32 %123, %124
  %126 = load i32, ptr %18, align 4, !tbaa !9
  %127 = add nsw i32 %125, %126
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds i8, ptr %118, i64 %128
  %130 = load i8, ptr %129, align 1, !tbaa !17
  %131 = load ptr, ptr %13, align 8, !tbaa !5
  %132 = load i32, ptr %17, align 4, !tbaa !9
  %133 = load i32, ptr %6, align 4, !tbaa !9
  %134 = sdiv i32 %133, 2
  %135 = add nsw i32 %132, %134
  %136 = load i32, ptr %6, align 4, !tbaa !9
  %137 = mul nsw i32 %135, %136
  %138 = load i32, ptr %18, align 4, !tbaa !9
  %139 = add nsw i32 %137, %138
  %140 = load i32, ptr %6, align 4, !tbaa !9
  %141 = sdiv i32 %140, 2
  %142 = add nsw i32 %139, %141
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds i8, ptr %131, i64 %143
  store i8 %130, ptr %144, align 1, !tbaa !17
  br label %145

145:                                              ; preds = %117
  %146 = load i32, ptr %18, align 4, !tbaa !9
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %18, align 4, !tbaa !9
  br label %111, !llvm.loop !18

148:                                              ; preds = %116
  br label %149

149:                                              ; preds = %148
  %150 = load i32, ptr %17, align 4, !tbaa !9
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %17, align 4, !tbaa !9
  br label %101, !llvm.loop !20

152:                                              ; preds = %106
  %153 = load ptr, ptr %13, align 8, !tbaa !5
  %154 = load i32, ptr %6, align 4, !tbaa !9
  %155 = call zeroext i8 @median_member(ptr noundef %153, i32 noundef %154)
  %156 = load ptr, ptr %12, align 8, !tbaa !5
  %157 = load i32, ptr %14, align 4, !tbaa !9
  %158 = load i32, ptr %8, align 4, !tbaa !9
  %159 = mul nsw i32 %157, %158
  %160 = load i32, ptr %16, align 4, !tbaa !9
  %161 = add nsw i32 %159, %160
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds i8, ptr %156, i64 %162
  store i8 %155, ptr %163, align 1, !tbaa !17
  br label %182

164:                                              ; preds = %90, %84, %77, %71
  %165 = load ptr, ptr %11, align 8, !tbaa !5
  %166 = load i32, ptr %14, align 4, !tbaa !9
  %167 = load i32, ptr %8, align 4, !tbaa !9
  %168 = mul nsw i32 %166, %167
  %169 = load i32, ptr %16, align 4, !tbaa !9
  %170 = add nsw i32 %168, %169
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds i8, ptr %165, i64 %171
  %173 = load i8, ptr %172, align 1, !tbaa !17
  %174 = load ptr, ptr %12, align 8, !tbaa !5
  %175 = load i32, ptr %14, align 4, !tbaa !9
  %176 = load i32, ptr %8, align 4, !tbaa !9
  %177 = mul nsw i32 %175, %176
  %178 = load i32, ptr %16, align 4, !tbaa !9
  %179 = add nsw i32 %177, %178
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds i8, ptr %174, i64 %180
  store i8 %173, ptr %181, align 1, !tbaa !17
  br label %182

182:                                              ; preds = %164, %152
  br label %183

183:                                              ; preds = %182
  %184 = load i32, ptr %16, align 4, !tbaa !9
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %16, align 4, !tbaa !9
  br label %66, !llvm.loop !21

186:                                              ; preds = %70
  br label %187

187:                                              ; preds = %186
  %188 = load i32, ptr %14, align 4, !tbaa !9
  %189 = add nsw i32 %188, 1
  store i32 %189, ptr %14, align 4, !tbaa !9
  br label %60, !llvm.loop !22

190:                                              ; preds = %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @median_member(ptr noundef, i32 noundef) #3

attributes #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 = { noreturn 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind allocsize(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 #5 = { noreturn nounwind }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{!12, !6, i64 24}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}
!22 = distinct !{!22, !19}


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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @hypercv_medianblur(ptr noundef readnone %0, ptr nocapture noundef readnone %1, i32 noundef %2) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %8, label %4

4:                                                ; preds = %3
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #3
  unreachable

8:                                                ; preds = %3
  %9 = and i32 %2, -2147483647
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %15, label %11

11:                                               ; preds = %8
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #3
  unreachable

15:                                               ; preds = %8
  ret void
}

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 = { noreturn 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 #2 = { 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 #3 = { noreturn 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)"}


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