; LLVM IR from achilles288/robot-monitor-graphics :: src/base/color.ll (ZNK3rmg9ColorHSLAcvNS_9ColorRGBAEEv)

; 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.rmg::ColorRGBA" = type { float, float, float, float }
%"struct.rmg::ColorHSLA" = type { float, float, float, float }

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_ZNK3rmg9ColorHSLAcvNS_9ColorRGBAEEv(ptr noundef nonnull align 4 dereferenceable(16) %0) #3 align 2 {
  %2 = alloca %"struct.rmg::ColorRGBA", align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16) %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %8 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 2
  %9 = load float, ptr %8, align 4, !tbaa !9
  %10 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %9, float -1.000000e+00)
  %11 = fpext float %10 to double
  %12 = call double @llvm.fabs.f64(double %11)
  %13 = fsub double 1.000000e+00, %12
  %14 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 1
  %15 = load float, ptr %14, align 4, !tbaa !12
  %16 = fpext float %15 to double
  %17 = fmul double %13, %16
  %18 = fptrunc double %17 to float
  store float %18, ptr %4, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %19 = load float, ptr %4, align 4, !tbaa !13
  %20 = fpext float %19 to double
  %21 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %22 = load float, ptr %21, align 4, !tbaa !14
  %23 = fdiv float %22, 6.000000e+01
  %24 = fpext float %23 to double
  %25 = call double @fmod(double noundef %24, double noundef 2.000000e+00) #4
  %26 = fsub double %25, 1.000000e+00
  %27 = call double @llvm.fabs.f64(double %26)
  %28 = fsub double 1.000000e+00, %27
  %29 = fmul double %20, %28
  %30 = fptrunc double %29 to float
  store float %30, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %31 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 2
  %32 = load float, ptr %31, align 4, !tbaa !9
  %33 = load float, ptr %4, align 4, !tbaa !13
  %34 = fdiv float %33, 2.000000e+00
  %35 = fsub float %32, %34
  store float %35, ptr %6, align 4, !tbaa !13
  %36 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !14
  %38 = fcmp oge float %37, 0.000000e+00
  br i1 %38, label %39, label %49

39:                                               ; preds = %1
  %40 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %41 = load float, ptr %40, align 4, !tbaa !14
  %42 = fcmp olt float %41, 6.000000e+01
  br i1 %42, label %43, label %49

43:                                               ; preds = %39
  %44 = load float, ptr %4, align 4, !tbaa !13
  %45 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 0
  store float %44, ptr %45, align 4, !tbaa !15
  %46 = load float, ptr %5, align 4, !tbaa !13
  %47 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 1
  store float %46, ptr %47, align 4, !tbaa !17
  %48 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 2
  store float 0.000000e+00, ptr %48, align 4, !tbaa !18
  br label %115

49:                                               ; preds = %39, %1
  %50 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %51 = load float, ptr %50, align 4, !tbaa !14
  %52 = fcmp oge float %51, 6.000000e+01
  br i1 %52, label %53, label %63

53:                                               ; preds = %49
  %54 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %55 = load float, ptr %54, align 4, !tbaa !14
  %56 = fcmp olt float %55, 1.200000e+02
  br i1 %56, label %57, label %63

57:                                               ; preds = %53
  %58 = load float, ptr %5, align 4, !tbaa !13
  %59 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 0
  store float %58, ptr %59, align 4, !tbaa !15
  %60 = load float, ptr %4, align 4, !tbaa !13
  %61 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 1
  store float %60, ptr %61, align 4, !tbaa !17
  %62 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 2
  store float 0.000000e+00, ptr %62, align 4, !tbaa !18
  br label %114

63:                                               ; preds = %53, %49
  %64 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %65 = load float, ptr %64, align 4, !tbaa !14
  %66 = fcmp oge float %65, 1.200000e+02
  br i1 %66, label %67, label %77

67:                                               ; preds = %63
  %68 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %69 = load float, ptr %68, align 4, !tbaa !14
  %70 = fcmp olt float %69, 1.800000e+02
  br i1 %70, label %71, label %77

71:                                               ; preds = %67
  %72 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 0
  store float 0.000000e+00, ptr %72, align 4, !tbaa !15
  %73 = load float, ptr %4, align 4, !tbaa !13
  %74 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 1
  store float %73, ptr %74, align 4, !tbaa !17
  %75 = load float, ptr %5, align 4, !tbaa !13
  %76 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 2
  store float %75, ptr %76, align 4, !tbaa !18
  br label %113

77:                                               ; preds = %67, %63
  %78 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %79 = load float, ptr %78, align 4, !tbaa !14
  %80 = fcmp oge float %79, 1.800000e+02
  br i1 %80, label %81, label %91

81:                                               ; preds = %77
  %82 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %83 = load float, ptr %82, align 4, !tbaa !14
  %84 = fcmp olt float %83, 2.400000e+02
  br i1 %84, label %85, label %91

85:                                               ; preds = %81
  %86 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 0
  store float 0.000000e+00, ptr %86, align 4, !tbaa !15
  %87 = load float, ptr %5, align 4, !tbaa !13
  %88 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 1
  store float %87, ptr %88, align 4, !tbaa !17
  %89 = load float, ptr %4, align 4, !tbaa !13
  %90 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 2
  store float %89, ptr %90, align 4, !tbaa !18
  br label %112

91:                                               ; preds = %81, %77
  %92 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %93 = load float, ptr %92, align 4, !tbaa !14
  %94 = fcmp oge float %93, 2.400000e+02
  br i1 %94, label %95, label %105

95:                                               ; preds = %91
  %96 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 0
  %97 = load float, ptr %96, align 4, !tbaa !14
  %98 = fcmp olt float %97, 3.000000e+02
  br i1 %98, label %99, label %105

99:                                               ; preds = %95
  %100 = load float, ptr %5, align 4, !tbaa !13
  %101 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 0
  store float %100, ptr %101, align 4, !tbaa !15
  %102 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 1
  store float 0.000000e+00, ptr %102, align 4, !tbaa !17
  %103 = load float, ptr %4, align 4, !tbaa !13
  %104 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 2
  store float %103, ptr %104, align 4, !tbaa !18
  br label %111

105:                                              ; preds = %95, %91
  %106 = load float, ptr %4, align 4, !tbaa !13
  %107 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 0
  store float %106, ptr %107, align 4, !tbaa !15
  %108 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 1
  store float 0.000000e+00, ptr %108, align 4, !tbaa !17
  %109 = load float, ptr %5, align 4, !tbaa !13
  %110 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 2
  store float %109, ptr %110, align 4, !tbaa !18
  br label %111

111:                                              ; preds = %105, %99
  br label %112

112:                                              ; preds = %111, %85
  br label %113

113:                                              ; preds = %112, %71
  br label %114

114:                                              ; preds = %113, %57
  br label %115

115:                                              ; preds = %114, %43
  %116 = getelementptr inbounds %"struct.rmg::ColorHSLA", ptr %7, i32 0, i32 3
  %117 = load float, ptr %116, align 4, !tbaa !19
  %118 = getelementptr inbounds %"struct.rmg::ColorRGBA", ptr %2, i32 0, i32 3
  store float %117, ptr %118, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %119 = load { <2 x float>, <2 x float> }, ptr %2, align 4
  ret { <2 x float>, <2 x float> } %119
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 speculatable willreturn memory(none) }
attributes #3 = { mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTSN3rmg9ColorHSLAE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!16, !11, i64 0}
!16 = !{!"_ZTSN3rmg9ColorRGBAE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!17 = !{!16, !11, i64 4}
!18 = !{!16, !11, i64 8}
!19 = !{!10, !11, i64 12}
!20 = !{!16, !11, i64 12}


; 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.rmg::ColorRGBA" = type { float, float, float, float }

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_ZNK3rmg9ColorHSLAcvNS_9ColorRGBAEEv(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca %"struct.rmg::ColorRGBA", align 8
  call void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16) %2) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load float, ptr %3, align 4, !tbaa !5
  %5 = call float @llvm.fmuladd.f32(float %4, float 2.000000e+00, float -1.000000e+00)
  %6 = call float @llvm.fabs.f32(float %5)
  %7 = fpext float %6 to double
  %8 = fsub double 1.000000e+00, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load float, ptr %9, align 4, !tbaa !10
  %11 = fpext float %10 to double
  %12 = fmul double %8, %11
  %13 = fptrunc double %12 to float
  %14 = fpext float %13 to double
  %15 = load float, ptr %0, align 4, !tbaa !11
  %16 = fdiv float %15, 6.000000e+01
  %17 = fpext float %16 to double
  %18 = call double @fmod(double noundef %17, double noundef 2.000000e+00) #4
  %19 = fadd double %18, -1.000000e+00
  %20 = call double @llvm.fabs.f64(double %19)
  %21 = fsub double 1.000000e+00, %20
  %22 = fmul double %21, %14
  %23 = fptrunc double %22 to float
  %24 = load float, ptr %0, align 4, !tbaa !11
  %25 = fcmp oge float %24, 0.000000e+00
  %26 = fcmp olt float %24, 6.000000e+01
  %or.cond = and i1 %25, %26
  br i1 %or.cond, label %27, label %30

27:                                               ; preds = %1
  store float %13, ptr %2, align 8, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %2, i64 4
  store float %23, ptr %28, align 4, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %2, i64 8
  store float 0.000000e+00, ptr %29, align 8, !tbaa !15
  br label %55

30:                                               ; preds = %1
  %31 = fcmp oge float %24, 6.000000e+01
  %32 = fcmp olt float %24, 1.200000e+02
  %or.cond19 = and i1 %31, %32
  br i1 %or.cond19, label %33, label %36

33:                                               ; preds = %30
  store float %23, ptr %2, align 8, !tbaa !12
  %34 = getelementptr inbounds i8, ptr %2, i64 4
  store float %13, ptr %34, align 4, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %2, i64 8
  store float 0.000000e+00, ptr %35, align 8, !tbaa !15
  br label %55

36:                                               ; preds = %30
  %37 = fcmp oge float %24, 1.200000e+02
  %38 = fcmp olt float %24, 1.800000e+02
  %or.cond20 = and i1 %37, %38
  br i1 %or.cond20, label %39, label %42

39:                                               ; preds = %36
  store float 0.000000e+00, ptr %2, align 8, !tbaa !12
  %40 = getelementptr inbounds i8, ptr %2, i64 4
  store float %13, ptr %40, align 4, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %2, i64 8
  store float %23, ptr %41, align 8, !tbaa !15
  br label %55

42:                                               ; preds = %36
  %43 = fcmp oge float %24, 1.800000e+02
  %44 = fcmp olt float %24, 2.400000e+02
  %or.cond21 = and i1 %43, %44
  br i1 %or.cond21, label %45, label %48

45:                                               ; preds = %42
  store float 0.000000e+00, ptr %2, align 8, !tbaa !12
  %46 = getelementptr inbounds i8, ptr %2, i64 4
  store float %23, ptr %46, align 4, !tbaa !14
  %47 = getelementptr inbounds i8, ptr %2, i64 8
  store float %13, ptr %47, align 8, !tbaa !15
  br label %55

48:                                               ; preds = %42
  %49 = fcmp oge float %24, 2.400000e+02
  %50 = fcmp olt float %24, 3.000000e+02
  %or.cond22 = and i1 %49, %50
  %51 = getelementptr inbounds i8, ptr %2, i64 4
  %52 = getelementptr inbounds i8, ptr %2, i64 8
  br i1 %or.cond22, label %53, label %54

53:                                               ; preds = %48
  store float %23, ptr %2, align 8, !tbaa !12
  store float 0.000000e+00, ptr %51, align 4, !tbaa !14
  store float %13, ptr %52, align 8, !tbaa !15
  br label %55

54:                                               ; preds = %48
  store float %13, ptr %2, align 8, !tbaa !12
  store float 0.000000e+00, ptr %51, align 4, !tbaa !14
  store float %23, ptr %52, align 8, !tbaa !15
  br label %55

55:                                               ; preds = %33, %45, %54, %53, %39, %27
  %56 = getelementptr inbounds i8, ptr %0, i64 12
  %57 = load float, ptr %56, align 4, !tbaa !16
  %58 = getelementptr inbounds i8, ptr %2, i64 12
  store float %57, ptr %58, align 4, !tbaa !17
  %.fca.0.load = load <2 x float>, ptr %2, align 8
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds i8, ptr %2, i64 8
  %.fca.1.load = load <2 x float>, ptr %.fca.1.gep, align 8
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.fca.1.load, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !7, i64 8}
!6 = !{!"_ZTSN3rmg9ColorHSLAE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTSN3rmg9ColorRGBAE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!14 = !{!13, !7, i64 4}
!15 = !{!13, !7, i64 8}
!16 = !{!6, !7, i64 12}
!17 = !{!13, !7, i64 12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass