; LLVM IR from Dragons-Lake/REI :: sources/REI_Integration/3rdParty/nanovg (nanovg)

; 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.NVGcolor = type { %union.anon }
%union.anon = type { [4 x float] }
%struct.anon = 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden float @nvg__clampf(float noundef, float noundef, float noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @nvgHSLA(float noundef %0, float noundef %1, float noundef %2, i8 noundef zeroext %3) #1 {
  %5 = alloca %struct.NVGcolor, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca i8, align 1
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  store float %0, ptr %6, align 4, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !5
  store i8 %3, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %12 = load float, ptr %6, align 4, !tbaa !5
  %13 = call float @nvg__modf(float noundef %12, float noundef 1.000000e+00)
  store float %13, ptr %6, align 4, !tbaa !5
  %14 = load float, ptr %6, align 4, !tbaa !5
  %15 = fcmp olt float %14, 0.000000e+00
  br i1 %15, label %16, label %19

16:                                               ; preds = %4
  %17 = load float, ptr %6, align 4, !tbaa !5
  %18 = fadd float %17, 1.000000e+00
  store float %18, ptr %6, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %16, %4
  %20 = load float, ptr %7, align 4, !tbaa !5
  %21 = call float @nvg__clampf(float noundef %20, float noundef 0.000000e+00, float noundef 1.000000e+00)
  store float %21, ptr %7, align 4, !tbaa !5
  %22 = load float, ptr %8, align 4, !tbaa !5
  %23 = call float @nvg__clampf(float noundef %22, float noundef 0.000000e+00, float noundef 1.000000e+00)
  store float %23, ptr %8, align 4, !tbaa !5
  %24 = load float, ptr %8, align 4, !tbaa !5
  %25 = fcmp ole float %24, 5.000000e-01
  br i1 %25, label %26, label %31

26:                                               ; preds = %19
  %27 = load float, ptr %8, align 4, !tbaa !5
  %28 = load float, ptr %7, align 4, !tbaa !5
  %29 = fadd float 1.000000e+00, %28
  %30 = fmul float %27, %29
  br label %39

31:                                               ; preds = %19
  %32 = load float, ptr %8, align 4, !tbaa !5
  %33 = load float, ptr %7, align 4, !tbaa !5
  %34 = fadd float %32, %33
  %35 = load float, ptr %8, align 4, !tbaa !5
  %36 = load float, ptr %7, align 4, !tbaa !5
  %37 = fneg float %35
  %38 = call float @llvm.fmuladd.f32(float %37, float %36, float %34)
  br label %39

39:                                               ; preds = %31, %26
  %40 = phi float [ %30, %26 ], [ %38, %31 ]
  store float %40, ptr %11, align 4, !tbaa !5
  %41 = load float, ptr %8, align 4, !tbaa !5
  %42 = load float, ptr %11, align 4, !tbaa !5
  %43 = fneg float %42
  %44 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %41, float %43)
  store float %44, ptr %10, align 4, !tbaa !5
  %45 = load float, ptr %6, align 4, !tbaa !5
  %46 = fadd float %45, 0x3FD5555560000000
  %47 = load float, ptr %10, align 4, !tbaa !5
  %48 = load float, ptr %11, align 4, !tbaa !5
  %49 = call float @nvg__hue(float noundef %46, float noundef %47, float noundef %48)
  %50 = call float @nvg__clampf(float noundef %49, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %51 = getelementptr inbounds %struct.NVGcolor, ptr %5, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 0
  store float %50, ptr %52, align 4, !tbaa !9
  %53 = load float, ptr %6, align 4, !tbaa !5
  %54 = load float, ptr %10, align 4, !tbaa !5
  %55 = load float, ptr %11, align 4, !tbaa !5
  %56 = call float @nvg__hue(float noundef %53, float noundef %54, float noundef %55)
  %57 = call float @nvg__clampf(float noundef %56, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %58 = getelementptr inbounds %struct.NVGcolor, ptr %5, i32 0, i32 0
  %59 = getelementptr inbounds %struct.anon, ptr %58, i32 0, i32 1
  store float %57, ptr %59, align 4, !tbaa !9
  %60 = load float, ptr %6, align 4, !tbaa !5
  %61 = fsub float %60, 0x3FD5555560000000
  %62 = load float, ptr %10, align 4, !tbaa !5
  %63 = load float, ptr %11, align 4, !tbaa !5
  %64 = call float @nvg__hue(float noundef %61, float noundef %62, float noundef %63)
  %65 = call float @nvg__clampf(float noundef %64, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %66 = getelementptr inbounds %struct.NVGcolor, ptr %5, i32 0, i32 0
  %67 = getelementptr inbounds %struct.anon, ptr %66, i32 0, i32 2
  store float %65, ptr %67, align 4, !tbaa !9
  %68 = load i8, ptr %9, align 1, !tbaa !9
  %69 = zext i8 %68 to i32
  %70 = sitofp i32 %69 to float
  %71 = fdiv float %70, 2.550000e+02
  %72 = getelementptr inbounds %struct.NVGcolor, ptr %5, i32 0, i32 0
  %73 = getelementptr inbounds %struct.anon, ptr %72, i32 0, i32 3
  store float %71, ptr %73, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %74 = getelementptr inbounds %struct.NVGcolor, ptr %5, i32 0, i32 0
  %75 = getelementptr inbounds %union.anon, ptr %74, i32 0, i32 0
  %76 = load { <2 x float>, <2 x float> }, ptr %75, align 4
  ret { <2 x float>, <2 x float> } %76
}

; Function Attrs: nounwind uwtable
declare hidden float @nvg__modf(float noundef, float noundef) #1

; Function Attrs: nounwind uwtable
declare hidden float @nvg__hue(float noundef, float noundef, float noundef) #1

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 = { 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !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: nounwind uwtable
declare hidden float @nvg__clampf(float noundef, float noundef, float 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: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @nvgHSLA(float noundef %0, float noundef %1, float noundef %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = tail call float @nvg__modf(float noundef %0, float noundef 1.000000e+00)
  %6 = tail call float @nvg__clampf(float noundef %1, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %7 = tail call float @nvg__clampf(float noundef %2, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %8 = fcmp ugt float %7, 5.000000e-01
  br i1 %8, label %12, label %9

9:                                                ; preds = %4
  %10 = fadd float %6, 1.000000e+00
  %11 = fmul float %7, %10
  br label %16

12:                                               ; preds = %4
  %13 = fadd float %6, %7
  %14 = fneg float %7
  %15 = tail call float @llvm.fmuladd.f32(float %14, float %6, float %13)
  br label %16

16:                                               ; preds = %12, %9
  %17 = phi float [ %11, %9 ], [ %15, %12 ]
  %18 = fcmp olt float %5, 0.000000e+00
  %19 = fadd float %5, 1.000000e+00
  %.0 = select i1 %18, float %19, float %5
  %20 = fneg float %17
  %21 = tail call float @llvm.fmuladd.f32(float %7, float 2.000000e+00, float %20)
  %22 = fadd float %.0, 0x3FD5555560000000
  %23 = tail call float @nvg__hue(float noundef %22, float noundef %21, float noundef %17)
  %24 = tail call float @nvg__clampf(float noundef %23, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %.sroa.0.0.vec.insert = insertelement <2 x float> poison, float %24, i64 0
  %25 = tail call float @nvg__hue(float noundef %.0, float noundef %21, float noundef %17)
  %26 = tail call float @nvg__clampf(float noundef %25, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %.sroa.0.4.vec.insert = insertelement <2 x float> %.sroa.0.0.vec.insert, float %26, i64 1
  %27 = fadd float %.0, 0xBFD5555560000000
  %28 = tail call float @nvg__hue(float noundef %27, float noundef %21, float noundef %17)
  %29 = tail call float @nvg__clampf(float noundef %28, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %.sroa.3.8.vec.insert = insertelement <2 x float> poison, float %29, i64 0
  %30 = uitofp i8 %3 to float
  %31 = fdiv float %30, 2.550000e+02
  %.sroa.3.12.vec.insert = insertelement <2 x float> %.sroa.3.8.vec.insert, float %31, i64 1
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.sroa.0.4.vec.insert, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.sroa.3.12.vec.insert, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

; Function Attrs: nounwind uwtable
declare hidden float @nvg__modf(float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden float @nvg__hue(float noundef, float noundef, float noundef) local_unnamed_addr #0

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

!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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass