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

; 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: nounwind uwtable
define dso_local ptr @convertHSLtoRGB(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
  %11 = alloca i16, align 2
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %12 = load double, ptr %5, align 8, !tbaa !5
  %13 = load double, ptr %6, align 8, !tbaa !5
  %14 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %13, double -1.000000e+00)
  %15 = call double @llvm.fabs.f64(double %14)
  %16 = fsub double 1.000000e+00, %15
  %17 = fmul double %12, %16
  store double %17, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %18 = load double, ptr %7, align 8, !tbaa !5
  %19 = load double, ptr %4, align 8, !tbaa !5
  %20 = fdiv double %19, 6.000000e+01
  %21 = call double @fmod(double noundef %20, double noundef 2.000000e+00) #5
  %22 = fsub double %21, 1.000000e+00
  %23 = call double @llvm.fabs.f64(double %22)
  %24 = fsub double 1.000000e+00, %23
  %25 = fmul double %18, %24
  store double %25, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %26 = load double, ptr %6, align 8, !tbaa !5
  %27 = load double, ptr %7, align 8, !tbaa !5
  %28 = fdiv double %27, 2.000000e+00
  %29 = fsub double %26, %28
  store double %29, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %30 = call noalias ptr @malloc(i64 noundef 24) #6
  store ptr %30, ptr %10, align 8, !tbaa !9
  %31 = load double, ptr %4, align 8, !tbaa !5
  %32 = fcmp olt double %31, 6.000000e+01
  br i1 %32, label %33, label %42

33:                                               ; preds = %3
  %34 = load double, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %10, align 8, !tbaa !9
  %36 = getelementptr inbounds double, ptr %35, i64 0
  store double %34, ptr %36, align 8, !tbaa !5
  %37 = load double, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %10, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %38, i64 1
  store double %37, ptr %39, align 8, !tbaa !5
  %40 = load ptr, ptr %10, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %40, i64 2
  store double 0.000000e+00, ptr %41, align 8, !tbaa !5
  br label %103

42:                                               ; preds = %3
  %43 = load double, ptr %4, align 8, !tbaa !5
  %44 = fcmp olt double %43, 1.200000e+02
  br i1 %44, label %45, label %54

45:                                               ; preds = %42
  %46 = load double, ptr %8, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  %48 = getelementptr inbounds double, ptr %47, i64 0
  store double %46, ptr %48, align 8, !tbaa !5
  %49 = load double, ptr %7, align 8, !tbaa !5
  %50 = load ptr, ptr %10, align 8, !tbaa !9
  %51 = getelementptr inbounds double, ptr %50, i64 1
  store double %49, ptr %51, align 8, !tbaa !5
  %52 = load ptr, ptr %10, align 8, !tbaa !9
  %53 = getelementptr inbounds double, ptr %52, i64 2
  store double 0.000000e+00, ptr %53, align 8, !tbaa !5
  br label %102

54:                                               ; preds = %42
  %55 = load double, ptr %4, align 8, !tbaa !5
  %56 = fcmp olt double %55, 1.800000e+02
  br i1 %56, label %57, label %66

57:                                               ; preds = %54
  %58 = load ptr, ptr %10, align 8, !tbaa !9
  %59 = getelementptr inbounds double, ptr %58, i64 0
  store double 0.000000e+00, ptr %59, align 8, !tbaa !5
  %60 = load double, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %10, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %61, i64 1
  store double %60, ptr %62, align 8, !tbaa !5
  %63 = load double, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !9
  %65 = getelementptr inbounds double, ptr %64, i64 2
  store double %63, ptr %65, align 8, !tbaa !5
  br label %101

66:                                               ; preds = %54
  %67 = load double, ptr %4, align 8, !tbaa !5
  %68 = fcmp olt double %67, 2.400000e+02
  br i1 %68, label %69, label %78

69:                                               ; preds = %66
  %70 = load ptr, ptr %10, align 8, !tbaa !9
  %71 = getelementptr inbounds double, ptr %70, i64 0
  store double 0.000000e+00, ptr %71, align 8, !tbaa !5
  %72 = load double, ptr %8, align 8, !tbaa !5
  %73 = load ptr, ptr %10, align 8, !tbaa !9
  %74 = getelementptr inbounds double, ptr %73, i64 1
  store double %72, ptr %74, align 8, !tbaa !5
  %75 = load double, ptr %7, align 8, !tbaa !5
  %76 = load ptr, ptr %10, align 8, !tbaa !9
  %77 = getelementptr inbounds double, ptr %76, i64 2
  store double %75, ptr %77, align 8, !tbaa !5
  br label %100

78:                                               ; preds = %66
  %79 = load double, ptr %4, align 8, !tbaa !5
  %80 = fcmp olt double %79, 3.000000e+02
  br i1 %80, label %81, label %90

81:                                               ; preds = %78
  %82 = load double, ptr %8, align 8, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !9
  %84 = getelementptr inbounds double, ptr %83, i64 0
  store double %82, ptr %84, align 8, !tbaa !5
  %85 = load ptr, ptr %10, align 8, !tbaa !9
  %86 = getelementptr inbounds double, ptr %85, i64 1
  store double 0.000000e+00, ptr %86, align 8, !tbaa !5
  %87 = load double, ptr %7, align 8, !tbaa !5
  %88 = load ptr, ptr %10, align 8, !tbaa !9
  %89 = getelementptr inbounds double, ptr %88, i64 2
  store double %87, ptr %89, align 8, !tbaa !5
  br label %99

90:                                               ; preds = %78
  %91 = load double, ptr %7, align 8, !tbaa !5
  %92 = load ptr, ptr %10, align 8, !tbaa !9
  %93 = getelementptr inbounds double, ptr %92, i64 0
  store double %91, ptr %93, align 8, !tbaa !5
  %94 = load ptr, ptr %10, align 8, !tbaa !9
  %95 = getelementptr inbounds double, ptr %94, i64 1
  store double 0.000000e+00, ptr %95, align 8, !tbaa !5
  %96 = load double, ptr %8, align 8, !tbaa !5
  %97 = load ptr, ptr %10, align 8, !tbaa !9
  %98 = getelementptr inbounds double, ptr %97, i64 2
  store double %96, ptr %98, align 8, !tbaa !5
  br label %99

99:                                               ; preds = %90, %81
  br label %100

100:                                              ; preds = %99, %69
  br label %101

101:                                              ; preds = %100, %57
  br label %102

102:                                              ; preds = %101, %45
  br label %103

103:                                              ; preds = %102, %33
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #5
  store i16 0, ptr %11, align 2, !tbaa !11
  br label %104

104:                                              ; preds = %121, %103
  %105 = load i16, ptr %11, align 2, !tbaa !11
  %106 = zext i16 %105 to i32
  %107 = icmp slt i32 %106, 3
  br i1 %107, label %108, label %124

108:                                              ; preds = %104
  %109 = load ptr, ptr %10, align 8, !tbaa !9
  %110 = load i16, ptr %11, align 2, !tbaa !11
  %111 = zext i16 %110 to i64
  %112 = getelementptr inbounds double, ptr %109, i64 %111
  %113 = load double, ptr %112, align 8, !tbaa !5
  %114 = load double, ptr %9, align 8, !tbaa !5
  %115 = fadd double %113, %114
  %116 = fmul double %115, 2.550000e+02
  %117 = load ptr, ptr %10, align 8, !tbaa !9
  %118 = load i16, ptr %11, align 2, !tbaa !11
  %119 = zext i16 %118 to i64
  %120 = getelementptr inbounds double, ptr %117, i64 %119
  store double %116, ptr %120, align 8, !tbaa !5
  br label %121

121:                                              ; preds = %108
  %122 = load i16, ptr %11, align 2, !tbaa !11
  %123 = add i16 %122, 1
  store i16 %123, ptr %11, align 2, !tbaa !11
  br label %104, !llvm.loop !13

124:                                              ; preds = %104
  %125 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #5
  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 %125
}

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

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}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; 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 nofree nounwind willreturn memory(write, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @convertHSLtoRGB(double noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #3 {
  %4 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double -1.000000e+00)
  %5 = tail call double @llvm.fabs.f64(double %4)
  %6 = fsub double 1.000000e+00, %5
  %7 = fmul double %6, %1
  %8 = fdiv double %0, 6.000000e+01
  %9 = tail call double @fmod(double noundef %8, double noundef 2.000000e+00) #4
  %10 = fadd double %9, -1.000000e+00
  %11 = tail call double @llvm.fabs.f64(double %10)
  %12 = fsub double 1.000000e+00, %11
  %13 = fmul double %7, %12
  %14 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #5
  %15 = fcmp olt double %0, 6.000000e+01
  br i1 %15, label %25, label %16

16:                                               ; preds = %3
  %17 = fcmp olt double %0, 1.200000e+02
  br i1 %17, label %25, label %18

18:                                               ; preds = %16
  %19 = fcmp olt double %0, 1.800000e+02
  br i1 %19, label %25, label %20

20:                                               ; preds = %18
  %21 = fcmp olt double %0, 2.400000e+02
  br i1 %21, label %25, label %22

22:                                               ; preds = %20
  %23 = fcmp olt double %0, 3.000000e+02
  br i1 %23, label %25, label %24

24:                                               ; preds = %22
  store double %7, ptr %14, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %22, %20, %18, %16, %3, %24
  %26 = phi double [ %13, %24 ], [ 0.000000e+00, %3 ], [ 0.000000e+00, %16 ], [ %13, %18 ], [ %7, %20 ], [ %7, %22 ]
  %27 = phi double [ 0.000000e+00, %24 ], [ %13, %3 ], [ %7, %16 ], [ %7, %18 ], [ %13, %20 ], [ 0.000000e+00, %22 ]
  %28 = phi double [ %7, %24 ], [ %7, %3 ], [ %13, %16 ], [ 0.000000e+00, %18 ], [ 0.000000e+00, %20 ], [ %13, %22 ]
  %29 = fmul double %7, 5.000000e-01
  %30 = fsub double %2, %29
  %31 = fadd double %30, %28
  %32 = fmul double %31, 2.550000e+02
  store double %32, ptr %14, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %14, i64 8
  %34 = fadd double %30, %27
  %35 = fmul double %34, 2.550000e+02
  store double %35, ptr %33, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %14, i64 16
  %37 = fadd double %30, %26
  %38 = fmul double %37, 2.550000e+02
  store double %38, ptr %36, align 8, !tbaa !5
  ret ptr %14
}

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

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 }
attributes #5 = { 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"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass