; 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.NVGpaint = type { [6 x float], [2 x float], float, float, %struct.NVGcolor, %struct.NVGcolor, i32 }
%struct.NVGcolor = type { %union.anon }
%union.anon = type { [4 x 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @nvgLinearGradient(ptr dead_on_unwind noalias writable sret(%struct.NVGpaint) align 4 %0, ptr noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, <2 x float> %6, <2 x float> %7, <2 x float> %8, <2 x float> %9) #4 {
  %11 = alloca %struct.NVGcolor, align 4
  %12 = alloca %struct.NVGcolor, align 4
  %13 = alloca ptr, align 8
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 0
  store <2 x float> %6, ptr %22, align 4
  %23 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 1
  store <2 x float> %7, ptr %23, align 4
  %24 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %12, i32 0, i32 0
  store <2 x float> %8, ptr %24, align 4
  %25 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %12, i32 0, i32 1
  store <2 x float> %9, ptr %25, align 4
  store ptr %1, ptr %13, align 8, !tbaa !5
  store float %2, ptr %14, align 4, !tbaa !9
  store float %3, ptr %15, align 4, !tbaa !9
  store float %4, ptr %16, align 4, !tbaa !9
  store float %5, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store float 1.000000e+05, ptr %21, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %10
  br label %27

27:                                               ; preds = %26
  call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 76, i1 false)
  %28 = load float, ptr %16, align 4, !tbaa !9
  %29 = load float, ptr %14, align 4, !tbaa !9
  %30 = fsub float %28, %29
  store float %30, ptr %18, align 4, !tbaa !9
  %31 = load float, ptr %17, align 4, !tbaa !9
  %32 = load float, ptr %15, align 4, !tbaa !9
  %33 = fsub float %31, %32
  store float %33, ptr %19, align 4, !tbaa !9
  %34 = load float, ptr %18, align 4, !tbaa !9
  %35 = load float, ptr %18, align 4, !tbaa !9
  %36 = load float, ptr %19, align 4, !tbaa !9
  %37 = load float, ptr %19, align 4, !tbaa !9
  %38 = fmul float %36, %37
  %39 = call float @llvm.fmuladd.f32(float %34, float %35, float %38)
  %40 = call float @sqrtf(float noundef %39) #7
  store float %40, ptr %20, align 4, !tbaa !9
  %41 = load float, ptr %20, align 4, !tbaa !9
  %42 = fcmp ogt float %41, 0x3F1A36E2E0000000
  br i1 %42, label %43, label %50

43:                                               ; preds = %27
  %44 = load float, ptr %20, align 4, !tbaa !9
  %45 = load float, ptr %18, align 4, !tbaa !9
  %46 = fdiv float %45, %44
  store float %46, ptr %18, align 4, !tbaa !9
  %47 = load float, ptr %20, align 4, !tbaa !9
  %48 = load float, ptr %19, align 4, !tbaa !9
  %49 = fdiv float %48, %47
  store float %49, ptr %19, align 4, !tbaa !9
  br label %51

50:                                               ; preds = %27
  store float 0.000000e+00, ptr %18, align 4, !tbaa !9
  store float 1.000000e+00, ptr %19, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %50, %43
  %52 = load float, ptr %19, align 4, !tbaa !9
  %53 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 0
  %54 = getelementptr inbounds [6 x float], ptr %53, i64 0, i64 0
  store float %52, ptr %54, align 4, !tbaa !9
  %55 = load float, ptr %18, align 4, !tbaa !9
  %56 = fneg float %55
  %57 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 0
  %58 = getelementptr inbounds [6 x float], ptr %57, i64 0, i64 1
  store float %56, ptr %58, align 4, !tbaa !9
  %59 = load float, ptr %18, align 4, !tbaa !9
  %60 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 0
  %61 = getelementptr inbounds [6 x float], ptr %60, i64 0, i64 2
  store float %59, ptr %61, align 4, !tbaa !9
  %62 = load float, ptr %19, align 4, !tbaa !9
  %63 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 0
  %64 = getelementptr inbounds [6 x float], ptr %63, i64 0, i64 3
  store float %62, ptr %64, align 4, !tbaa !9
  %65 = load float, ptr %14, align 4, !tbaa !9
  %66 = load float, ptr %18, align 4, !tbaa !9
  %67 = fneg float %66
  %68 = call float @llvm.fmuladd.f32(float %67, float 1.000000e+05, float %65)
  %69 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 0
  %70 = getelementptr inbounds [6 x float], ptr %69, i64 0, i64 4
  store float %68, ptr %70, align 4, !tbaa !9
  %71 = load float, ptr %15, align 4, !tbaa !9
  %72 = load float, ptr %19, align 4, !tbaa !9
  %73 = fneg float %72
  %74 = call float @llvm.fmuladd.f32(float %73, float 1.000000e+05, float %71)
  %75 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 0
  %76 = getelementptr inbounds [6 x float], ptr %75, i64 0, i64 5
  store float %74, ptr %76, align 4, !tbaa !9
  %77 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 1
  %78 = getelementptr inbounds [2 x float], ptr %77, i64 0, i64 0
  store float 1.000000e+05, ptr %78, align 4, !tbaa !9
  %79 = load float, ptr %20, align 4, !tbaa !9
  %80 = call float @llvm.fmuladd.f32(float %79, float 5.000000e-01, float 1.000000e+05)
  %81 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 1
  %82 = getelementptr inbounds [2 x float], ptr %81, i64 0, i64 1
  store float %80, ptr %82, align 4, !tbaa !9
  %83 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 2
  store float 0.000000e+00, ptr %83, align 4, !tbaa !11
  %84 = load float, ptr %20, align 4, !tbaa !9
  %85 = call float @nvg__maxf(float noundef 1.000000e+00, float noundef %84)
  %86 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 3
  store float %85, ptr %86, align 4, !tbaa !15
  %87 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %87, ptr align 4 %11, i64 16, i1 false), !tbaa.struct !16
  %88 = getelementptr inbounds %struct.NVGpaint, ptr %0, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %88, ptr align 4 %12, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  ret void
}

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #5

; Function Attrs: nounwind uwtable
declare hidden float @nvg__maxf(float noundef, float noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="64" "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 "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 #6 = { 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 #7 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"NVGpaint", !7, i64 0, !7, i64 24, !10, i64 32, !10, i64 36, !13, i64 40, !13, i64 56, !14, i64 72}
!13 = !{!"NVGcolor", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !10, i64 36}
!16 = !{i64 0, i64 16, !17}
!17 = !{!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"

%struct.NVGpaint = type { [6 x float], [2 x float], float, float, %struct.NVGcolor, %struct.NVGcolor, i32 }
%struct.NVGcolor = type { %union.anon }
%union.anon = type { [4 x float] }

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

; Function Attrs: nounwind uwtable
define dso_local void @nvgLinearGradient(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.NVGpaint) align 4 %0, ptr nocapture noundef readnone %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, <2 x float> %6, <2 x float> %7, <2 x float> %8, <2 x float> %9) local_unnamed_addr #1 {
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 0, ptr %11, align 4
  %12 = insertelement <2 x float> poison, float %4, i64 0
  %13 = insertelement <2 x float> %12, float %5, i64 1
  %14 = insertelement <2 x float> poison, float %2, i64 0
  %15 = insertelement <2 x float> %14, float %3, i64 1
  %16 = fsub <2 x float> %13, %15
  %17 = fmul <2 x float> %16, %16
  %18 = extractelement <2 x float> %17, i64 1
  %19 = extractelement <2 x float> %16, i64 0
  %20 = tail call float @llvm.fmuladd.f32(float %19, float %19, float %18)
  %sqrt = tail call float @llvm.sqrt.f32(float %20)
  %21 = fcmp ogt float %sqrt, 0x3F1A36E2E0000000
  %22 = getelementptr inbounds i8, ptr %0, i64 4
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = insertelement <2 x float> poison, float %sqrt, i64 0
  %26 = shufflevector <2 x float> %25, <2 x float> poison, <2 x i32> zeroinitializer
  %27 = fdiv <2 x float> %16, %26
  %28 = insertelement <2 x i1> poison, i1 %21, i64 0
  %29 = shufflevector <2 x i1> %28, <2 x i1> poison, <2 x i32> zeroinitializer
  %30 = select <2 x i1> %29, <2 x float> %27, <2 x float> <float 0.000000e+00, float 1.000000e+00>
  %31 = extractelement <2 x float> %30, i64 1
  store float %31, ptr %0, align 4, !tbaa !5
  %32 = fneg <2 x float> %30
  %33 = extractelement <2 x float> %32, i64 0
  store float %33, ptr %22, align 4, !tbaa !5
  store <2 x float> %30, ptr %23, align 4, !tbaa !5
  %34 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %32, <2 x float> <float 1.000000e+05, float 1.000000e+05>, <2 x float> %15)
  store <2 x float> %34, ptr %24, align 4, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 24
  store float 1.000000e+05, ptr %35, align 4, !tbaa !5
  %36 = tail call float @llvm.fmuladd.f32(float %sqrt, float 5.000000e-01, float 1.000000e+05)
  %37 = getelementptr inbounds i8, ptr %0, i64 28
  store float %36, ptr %37, align 4, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %0, i64 32
  store float 0.000000e+00, ptr %38, align 4, !tbaa !9
  %39 = tail call float @nvg__maxf(float noundef 1.000000e+00, float noundef %sqrt)
  %40 = getelementptr inbounds i8, ptr %0, i64 36
  store float %39, ptr %40, align 4, !tbaa !13
  %41 = getelementptr inbounds i8, ptr %0, i64 40
  store <2 x float> %6, ptr %41, align 4
  %.sroa.224.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 48
  store <2 x float> %7, ptr %.sroa.224.0..sroa_idx, align 4, !tbaa !14
  %42 = getelementptr inbounds i8, ptr %0, i64 56
  store <2 x float> %8, ptr %42, align 4
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 64
  store <2 x float> %9, ptr %.sroa.2.0..sroa_idx, align 4, !tbaa !14
  ret void
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 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) }

!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 = !{!10, !6, i64 32}
!10 = !{!"NVGpaint", !7, i64 0, !7, i64 24, !6, i64 32, !6, i64 36, !11, i64 40, !11, i64 56, !12, i64 72}
!11 = !{!"NVGcolor", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 36}
!14 = !{!7, !7, i64 0}


; Effective O3 passes: AggressiveInstCombinePass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass