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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @decodeSegment(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca double, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 0, ptr %5, align 1, !tbaa !9
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = uitofp i32 %7 to double
  %9 = fcmp une double %8, 0.000000e+00
  br i1 %9, label %10, label %77

10:                                               ; preds = %2
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = uitofp i32 %11 to double
  %13 = fcmp une double %12, 0.000000e+00
  br i1 %13, label %14, label %77

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = uitofp i32 %15 to double
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = uitofp i32 %17 to double
  %19 = call double @atan2(double noundef %16, double noundef %18) #3
  store double %19, ptr %6, align 8, !tbaa !10
  %20 = load double, ptr %6, align 8, !tbaa !10
  %21 = fmul double %20, 0x404CA5DC1A63C1F8
  store double %21, ptr %6, align 8, !tbaa !10
  %22 = load double, ptr %6, align 8, !tbaa !10
  %23 = fcmp ole double %22, 2.250000e+01
  br i1 %23, label %24, label %27

24:                                               ; preds = %14
  %25 = load double, ptr %6, align 8, !tbaa !10
  %26 = fcmp oge double %25, -2.250000e+01
  br i1 %26, label %33, label %27

27:                                               ; preds = %24, %14
  %28 = load double, ptr %6, align 8, !tbaa !10
  %29 = fcmp ole double %28, -1.575000e+02
  br i1 %29, label %33, label %30

30:                                               ; preds = %27
  %31 = load double, ptr %6, align 8, !tbaa !10
  %32 = fcmp oge double %31, 1.575000e+02
  br i1 %32, label %33, label %34

33:                                               ; preds = %30, %27, %24
  store i8 1, ptr %5, align 1, !tbaa !9
  br label %76

34:                                               ; preds = %30
  %35 = load double, ptr %6, align 8, !tbaa !10
  %36 = fcmp ogt double %35, 2.250000e+01
  br i1 %36, label %37, label %40

37:                                               ; preds = %34
  %38 = load double, ptr %6, align 8, !tbaa !10
  %39 = fcmp ole double %38, 6.750000e+01
  br i1 %39, label %46, label %40

40:                                               ; preds = %37, %34
  %41 = load double, ptr %6, align 8, !tbaa !10
  %42 = fcmp ogt double %41, -1.575000e+02
  br i1 %42, label %43, label %47

43:                                               ; preds = %40
  %44 = load double, ptr %6, align 8, !tbaa !10
  %45 = fcmp ole double %44, -1.125000e+02
  br i1 %45, label %46, label %47

46:                                               ; preds = %43, %37
  store i8 2, ptr %5, align 1, !tbaa !9
  br label %75

47:                                               ; preds = %43, %40
  %48 = load double, ptr %6, align 8, !tbaa !10
  %49 = fcmp ogt double %48, 6.750000e+01
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load double, ptr %6, align 8, !tbaa !10
  %52 = fcmp ole double %51, 1.125000e+02
  br i1 %52, label %59, label %53

53:                                               ; preds = %50, %47
  %54 = load double, ptr %6, align 8, !tbaa !10
  %55 = fcmp oge double %54, -1.125000e+02
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load double, ptr %6, align 8, !tbaa !10
  %58 = fcmp olt double %57, -6.750000e+01
  br i1 %58, label %59, label %60

59:                                               ; preds = %56, %50
  store i8 3, ptr %5, align 1, !tbaa !9
  br label %74

60:                                               ; preds = %56, %53
  %61 = load double, ptr %6, align 8, !tbaa !10
  %62 = fcmp oge double %61, -6.750000e+01
  br i1 %62, label %63, label %66

63:                                               ; preds = %60
  %64 = load double, ptr %6, align 8, !tbaa !10
  %65 = fcmp olt double %64, -2.250000e+01
  br i1 %65, label %72, label %66

66:                                               ; preds = %63, %60
  %67 = load double, ptr %6, align 8, !tbaa !10
  %68 = fcmp ogt double %67, 1.125000e+02
  br i1 %68, label %69, label %73

69:                                               ; preds = %66
  %70 = load double, ptr %6, align 8, !tbaa !10
  %71 = fcmp olt double %70, 1.575000e+02
  br i1 %71, label %72, label %73

72:                                               ; preds = %69, %63
  store i8 4, ptr %5, align 1, !tbaa !9
  br label %73

73:                                               ; preds = %72, %69, %66
  br label %74

74:                                               ; preds = %73, %59
  br label %75

75:                                               ; preds = %74, %46
  br label %76

76:                                               ; preds = %75, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %77

77:                                               ; preds = %76, %10, %2
  %78 = load i8, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret i8 %78
}

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !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"

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local zeroext range(i8 0, 5) i8 @decodeSegment(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq i32 %0, 0
  %.not41 = icmp eq i32 %1, 0
  %or.cond42 = or i1 %.not, %.not41
  br i1 %or.cond42, label %29, label %3

3:                                                ; preds = %2
  %4 = uitofp i32 %0 to double
  %5 = uitofp i32 %1 to double
  %6 = tail call double @atan2(double noundef %4, double noundef %5) #3
  %7 = fmul double %6, 0x404CA5DC1A63C1F8
  %8 = tail call double @llvm.fabs.f64(double %7)
  %or.cond = fcmp ole double %8, 2.250000e+01
  %9 = fcmp oge double %8, 1.575000e+02
  %or.cond5 = or i1 %or.cond, %9
  br i1 %or.cond5, label %29, label %10

10:                                               ; preds = %3
  %11 = fcmp ogt double %7, 2.250000e+01
  %12 = fcmp ole double %7, 6.750000e+01
  %or.cond7 = and i1 %11, %12
  br i1 %or.cond7, label %29, label %13

13:                                               ; preds = %10
  %14 = fcmp ogt double %7, -1.575000e+02
  %15 = fcmp ole double %7, -1.125000e+02
  %or.cond9 = and i1 %14, %15
  br i1 %or.cond9, label %29, label %16

16:                                               ; preds = %13
  %17 = fcmp ogt double %7, 6.750000e+01
  %18 = fcmp ole double %7, 1.125000e+02
  %or.cond11 = and i1 %17, %18
  br i1 %or.cond11, label %29, label %19

19:                                               ; preds = %16
  %20 = fcmp oge double %7, -1.125000e+02
  %21 = fcmp olt double %7, -6.750000e+01
  %or.cond13 = and i1 %20, %21
  br i1 %or.cond13, label %29, label %22

22:                                               ; preds = %19
  %23 = fcmp oge double %7, -6.750000e+01
  %24 = fcmp olt double %7, -2.250000e+01
  %or.cond15 = and i1 %23, %24
  br i1 %or.cond15, label %28, label %25

25:                                               ; preds = %22
  %26 = fcmp ogt double %7, 1.125000e+02
  %27 = fcmp olt double %7, 1.575000e+02
  %or.cond17 = and i1 %26, %27
  br i1 %or.cond17, label %28, label %29

28:                                               ; preds = %25, %22
  br label %29

29:                                               ; preds = %28, %25, %3, %13, %10, %19, %16, %2
  %.1 = phi i8 [ 0, %2 ], [ 4, %28 ], [ 0, %25 ], [ 1, %3 ], [ 2, %13 ], [ 2, %10 ], [ 3, %19 ], [ 3, %16 ]
  ret i8 %.1
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) 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 nofree nounwind willreturn memory(write) "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 speculatable willreturn memory(none) }
attributes #3 = { 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