; LLVM IR from arasgungore/filters-and-fractals :: main (convertRGBtoHSL)

; 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @convertRGBtoHSL(double noundef %0, double noundef %1, double noundef %2) #4 {
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  store double %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !5
  %11 = load double, ptr %4, align 8, !tbaa !5
  %12 = fdiv double %11, 2.550000e+02
  store double %12, ptr %4, align 8, !tbaa !5
  %13 = load double, ptr %5, align 8, !tbaa !5
  %14 = fdiv double %13, 2.550000e+02
  store double %14, ptr %5, align 8, !tbaa !5
  %15 = load double, ptr %6, align 8, !tbaa !5
  %16 = fdiv double %15, 2.550000e+02
  store double %16, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %17 = load double, ptr %4, align 8, !tbaa !5
  %18 = load double, ptr %5, align 8, !tbaa !5
  %19 = fcmp olt double %17, %18
  br i1 %19, label %20, label %30

20:                                               ; preds = %3
  %21 = load double, ptr %5, align 8, !tbaa !5
  %22 = load double, ptr %6, align 8, !tbaa !5
  %23 = fcmp olt double %21, %22
  br i1 %23, label %24, label %26

24:                                               ; preds = %20
  %25 = load double, ptr %6, align 8, !tbaa !5
  br label %28

26:                                               ; preds = %20
  %27 = load double, ptr %5, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %26, %24
  %29 = phi double [ %25, %24 ], [ %27, %26 ]
  br label %40

30:                                               ; preds = %3
  %31 = load double, ptr %4, align 8, !tbaa !5
  %32 = load double, ptr %6, align 8, !tbaa !5
  %33 = fcmp olt double %31, %32
  br i1 %33, label %34, label %36

34:                                               ; preds = %30
  %35 = load double, ptr %6, align 8, !tbaa !5
  br label %38

36:                                               ; preds = %30
  %37 = load double, ptr %4, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %36, %34
  %39 = phi double [ %35, %34 ], [ %37, %36 ]
  br label %40

40:                                               ; preds = %38, %28
  %41 = phi double [ %29, %28 ], [ %39, %38 ]
  store double %41, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %42 = load double, ptr %4, align 8, !tbaa !5
  %43 = load double, ptr %5, align 8, !tbaa !5
  %44 = fcmp olt double %42, %43
  br i1 %44, label %45, label %55

45:                                               ; preds = %40
  %46 = load double, ptr %4, align 8, !tbaa !5
  %47 = load double, ptr %6, align 8, !tbaa !5
  %48 = fcmp olt double %46, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %45
  %50 = load double, ptr %4, align 8, !tbaa !5
  br label %53

51:                                               ; preds = %45
  %52 = load double, ptr %6, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %51, %49
  %54 = phi double [ %50, %49 ], [ %52, %51 ]
  br label %65

55:                                               ; preds = %40
  %56 = load double, ptr %5, align 8, !tbaa !5
  %57 = load double, ptr %6, align 8, !tbaa !5
  %58 = fcmp olt double %56, %57
  br i1 %58, label %59, label %61

59:                                               ; preds = %55
  %60 = load double, ptr %5, align 8, !tbaa !5
  br label %63

61:                                               ; preds = %55
  %62 = load double, ptr %6, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %61, %59
  %64 = phi double [ %60, %59 ], [ %62, %61 ]
  br label %65

65:                                               ; preds = %63, %53
  %66 = phi double [ %54, %53 ], [ %64, %63 ]
  store double %66, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %67 = load double, ptr %7, align 8, !tbaa !5
  %68 = load double, ptr %8, align 8, !tbaa !5
  %69 = fsub double %67, %68
  store double %69, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %70 = call noalias ptr @malloc(i64 noundef 24) #6
  store ptr %70, ptr %10, align 8, !tbaa !9
  %71 = load double, ptr %8, align 8, !tbaa !5
  %72 = load double, ptr %7, align 8, !tbaa !5
  %73 = fadd double %71, %72
  %74 = fdiv double %73, 2.000000e+00
  %75 = load ptr, ptr %10, align 8, !tbaa !9
  %76 = getelementptr inbounds double, ptr %75, i64 2
  store double %74, ptr %76, align 8, !tbaa !5
  %77 = load double, ptr %9, align 8, !tbaa !5
  %78 = load ptr, ptr %10, align 8, !tbaa !9
  %79 = getelementptr inbounds double, ptr %78, i64 2
  %80 = load double, ptr %79, align 8, !tbaa !5
  %81 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %80, double -1.000000e+00)
  %82 = call double @llvm.fabs.f64(double %81)
  %83 = fsub double 1.000000e+00, %82
  %84 = fdiv double %77, %83
  %85 = load ptr, ptr %10, align 8, !tbaa !9
  %86 = getelementptr inbounds double, ptr %85, i64 1
  store double %84, ptr %86, align 8, !tbaa !5
  %87 = load double, ptr %9, align 8, !tbaa !5
  %88 = fcmp oeq double %87, 0.000000e+00
  br i1 %88, label %89, label %92

89:                                               ; preds = %65
  %90 = load ptr, ptr %10, align 8, !tbaa !9
  %91 = getelementptr inbounds double, ptr %90, i64 0
  store double 0.000000e+00, ptr %91, align 8, !tbaa !5
  br label %132

92:                                               ; preds = %65
  %93 = load double, ptr %7, align 8, !tbaa !5
  %94 = load double, ptr %4, align 8, !tbaa !5
  %95 = fcmp oeq double %93, %94
  br i1 %95, label %96, label %106

96:                                               ; preds = %92
  %97 = load double, ptr %5, align 8, !tbaa !5
  %98 = load double, ptr %6, align 8, !tbaa !5
  %99 = fsub double %97, %98
  %100 = load double, ptr %9, align 8, !tbaa !5
  %101 = fdiv double %99, %100
  %102 = call double @fmod(double noundef %101, double noundef 6.000000e+00) #5
  %103 = fmul double 6.000000e+01, %102
  %104 = load ptr, ptr %10, align 8, !tbaa !9
  %105 = getelementptr inbounds double, ptr %104, i64 0
  store double %103, ptr %105, align 8, !tbaa !5
  br label %131

106:                                              ; preds = %92
  %107 = load double, ptr %7, align 8, !tbaa !5
  %108 = load double, ptr %5, align 8, !tbaa !5
  %109 = fcmp oeq double %107, %108
  br i1 %109, label %110, label %120

110:                                              ; preds = %106
  %111 = load double, ptr %6, align 8, !tbaa !5
  %112 = load double, ptr %4, align 8, !tbaa !5
  %113 = fsub double %111, %112
  %114 = load double, ptr %9, align 8, !tbaa !5
  %115 = fdiv double %113, %114
  %116 = fadd double 2.000000e+00, %115
  %117 = fmul double 6.000000e+01, %116
  %118 = load ptr, ptr %10, align 8, !tbaa !9
  %119 = getelementptr inbounds double, ptr %118, i64 0
  store double %117, ptr %119, align 8, !tbaa !5
  br label %130

120:                                              ; preds = %106
  %121 = load double, ptr %4, align 8, !tbaa !5
  %122 = load double, ptr %5, align 8, !tbaa !5
  %123 = fsub double %121, %122
  %124 = load double, ptr %9, align 8, !tbaa !5
  %125 = fdiv double %123, %124
  %126 = fadd double 4.000000e+00, %125
  %127 = fmul double 6.000000e+01, %126
  %128 = load ptr, ptr %10, align 8, !tbaa !9
  %129 = getelementptr inbounds double, ptr %128, i64 0
  store double %127, ptr %129, align 8, !tbaa !5
  br label %130

130:                                              ; preds = %120, %110
  br label %131

131:                                              ; preds = %130, %96
  br label %132

132:                                              ; preds = %131, %89
  %133 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret ptr %133
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"double", !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}


; 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 allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @convertRGBtoHSL(double noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #3 {
  %4 = insertelement <2 x double> poison, double %0, i64 0
  %5 = insertelement <2 x double> %4, double %1, i64 1
  %6 = fdiv <2 x double> %5, <double 2.550000e+02, double 2.550000e+02>
  %7 = fdiv double %2, 2.550000e+02
  %8 = extractelement <2 x double> %6, i64 0
  %9 = extractelement <2 x double> %6, i64 1
  %10 = fcmp olt double %8, %9
  %11 = insertelement <2 x i1> poison, i1 %10, i64 0
  %12 = shufflevector <2 x i1> %11, <2 x i1> poison, <2 x i32> zeroinitializer
  %13 = shufflevector <2 x double> %6, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %14 = select <2 x i1> %12, <2 x double> %6, <2 x double> %13
  %15 = insertelement <2 x double> poison, double %7, i64 0
  %16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
  %17 = fcmp olt <2 x double> %14, %16
  %18 = insertelement <2 x double> %14, double %7, i64 1
  %19 = insertelement <2 x double> %14, double %7, i64 0
  %20 = select <2 x i1> %17, <2 x double> %18, <2 x double> %19
  %21 = extractelement <2 x double> %20, i64 0
  %22 = extractelement <2 x double> %20, i64 1
  %23 = fsub double %22, %21
  %24 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #4
  %25 = fadd double %22, %21
  %26 = fmul double %25, 5.000000e-01
  %27 = getelementptr inbounds i8, ptr %24, i64 16
  store double %26, ptr %27, align 8, !tbaa !5
  %28 = tail call double @llvm.fmuladd.f64(double %26, double 2.000000e+00, double -1.000000e+00)
  %29 = tail call double @llvm.fabs.f64(double %28)
  %30 = fsub double 1.000000e+00, %29
  %31 = fdiv double %23, %30
  %32 = getelementptr inbounds i8, ptr %24, i64 8
  store double %31, ptr %32, align 8, !tbaa !5
  %33 = fcmp oeq double %23, 0.000000e+00
  br i1 %33, label %53, label %34

34:                                               ; preds = %3
  %35 = fcmp oeq double %22, %8
  br i1 %35, label %36, label %41

36:                                               ; preds = %34
  %37 = fsub double %9, %7
  %38 = fdiv double %37, %23
  %39 = tail call double @fmod(double noundef %38, double noundef 6.000000e+00) #5
  %40 = fmul double %39, 6.000000e+01
  br label %53

41:                                               ; preds = %34
  %42 = fcmp oeq double %22, %9
  br i1 %42, label %43, label %48

43:                                               ; preds = %41
  %44 = fsub double %7, %8
  %45 = fdiv double %44, %23
  %46 = fadd double %45, 2.000000e+00
  %47 = fmul double %46, 6.000000e+01
  br label %53

48:                                               ; preds = %41
  %49 = fsub double %8, %9
  %50 = fdiv double %49, %23
  %51 = fadd double %50, 4.000000e+00
  %52 = fmul double %51, 6.000000e+01
  br label %53

53:                                               ; preds = %3, %36, %48, %43
  %.sink = phi double [ %40, %36 ], [ %52, %48 ], [ %47, %43 ], [ 0.000000e+00, %3 ]
  store double %.sink, ptr %24, align 8, !tbaa !5
  ret ptr %24
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write, inaccessiblemem: readwrite) 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) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass