; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/tests (gamma)

; 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.nk_colorf = 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
define dso_local void @nk_colorf_hsva_f(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, <2 x float> %4, <2 x float> %5) #2 {
  %7 = alloca %struct.nk_colorf, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 0
  store <2 x float> %4, ptr %16, align 4
  %17 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 1
  store <2 x float> %5, ptr %17, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store float 0.000000e+00, ptr %13, align 4, !tbaa !9
  %18 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %19 = load float, ptr %18, align 4, !tbaa !11
  %20 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  %21 = load float, ptr %20, align 4, !tbaa !13
  %22 = fcmp olt float %19, %21
  br i1 %22, label %23, label %31

23:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %24 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !11
  store float %25, ptr %14, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  %27 = load float, ptr %26, align 4, !tbaa !13
  %28 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  store float %27, ptr %28, align 4, !tbaa !11
  %29 = load float, ptr %14, align 4, !tbaa !9
  %30 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  store float %29, ptr %30, align 4, !tbaa !13
  store float -1.000000e+00, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %31

31:                                               ; preds = %23, %6
  %32 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 0
  %33 = load float, ptr %32, align 4, !tbaa !14
  %34 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %35 = load float, ptr %34, align 4, !tbaa !11
  %36 = fcmp olt float %33, %35
  br i1 %36, label %37, label %47

37:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %38 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !14
  store float %39, ptr %15, align 4, !tbaa !9
  %40 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !11
  %42 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 0
  store float %41, ptr %42, align 4, !tbaa !14
  %43 = load float, ptr %15, align 4, !tbaa !9
  %44 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  store float %43, ptr %44, align 4, !tbaa !11
  %45 = load float, ptr %13, align 4, !tbaa !9
  %46 = fsub float 0xBFD5555560000000, %45
  store float %46, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %47

47:                                               ; preds = %37, %31
  %48 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 0
  %49 = load float, ptr %48, align 4, !tbaa !14
  %50 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !11
  %52 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  %53 = load float, ptr %52, align 4, !tbaa !13
  %54 = fcmp olt float %51, %53
  br i1 %54, label %55, label %58

55:                                               ; preds = %47
  %56 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %57 = load float, ptr %56, align 4, !tbaa !11
  br label %61

58:                                               ; preds = %47
  %59 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  %60 = load float, ptr %59, align 4, !tbaa !13
  br label %61

61:                                               ; preds = %58, %55
  %62 = phi float [ %57, %55 ], [ %60, %58 ]
  %63 = fsub float %49, %62
  store float %63, ptr %12, align 4, !tbaa !9
  %64 = load float, ptr %13, align 4, !tbaa !9
  %65 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %66 = load float, ptr %65, align 4, !tbaa !11
  %67 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  %68 = load float, ptr %67, align 4, !tbaa !13
  %69 = fsub float %66, %68
  %70 = load float, ptr %12, align 4, !tbaa !9
  %71 = call float @llvm.fmuladd.f32(float 6.000000e+00, float %70, float 0x3BC79CA100000000)
  %72 = fdiv float %69, %71
  %73 = fadd float %64, %72
  %74 = fcmp olt float %73, 0.000000e+00
  br i1 %74, label %75, label %87

75:                                               ; preds = %61
  %76 = load float, ptr %13, align 4, !tbaa !9
  %77 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %78 = load float, ptr %77, align 4, !tbaa !11
  %79 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  %80 = load float, ptr %79, align 4, !tbaa !13
  %81 = fsub float %78, %80
  %82 = load float, ptr %12, align 4, !tbaa !9
  %83 = call float @llvm.fmuladd.f32(float 6.000000e+00, float %82, float 0x3BC79CA100000000)
  %84 = fdiv float %81, %83
  %85 = fadd float %76, %84
  %86 = fneg float %85
  br label %98

87:                                               ; preds = %61
  %88 = load float, ptr %13, align 4, !tbaa !9
  %89 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 1
  %90 = load float, ptr %89, align 4, !tbaa !11
  %91 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 2
  %92 = load float, ptr %91, align 4, !tbaa !13
  %93 = fsub float %90, %92
  %94 = load float, ptr %12, align 4, !tbaa !9
  %95 = call float @llvm.fmuladd.f32(float 6.000000e+00, float %94, float 0x3BC79CA100000000)
  %96 = fdiv float %93, %95
  %97 = fadd float %88, %96
  br label %98

98:                                               ; preds = %87, %75
  %99 = phi float [ %86, %75 ], [ %97, %87 ]
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  store float %99, ptr %100, align 4, !tbaa !9
  %101 = load float, ptr %12, align 4, !tbaa !9
  %102 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 0
  %103 = load float, ptr %102, align 4, !tbaa !14
  %104 = fadd float %103, 0x3BC79CA100000000
  %105 = fdiv float %101, %104
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  store float %105, ptr %106, align 4, !tbaa !9
  %107 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 0
  %108 = load float, ptr %107, align 4, !tbaa !14
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  store float %108, ptr %109, align 4, !tbaa !9
  %110 = getelementptr inbounds %struct.nk_colorf, ptr %7, i32 0, i32 3
  %111 = load float, ptr %110, align 4, !tbaa !15
  %112 = load ptr, ptr %11, align 8, !tbaa !5
  store float %111, ptr %112, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"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 4}
!12 = !{!"nk_colorf", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 0}
!15 = !{!12, !10, 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"

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @nk_colorf_hsva_f(ptr nocapture noundef writeonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, <2 x float> %4, <2 x float> %5) local_unnamed_addr #1 {
  %.sroa.0.4.vec.extract = extractelement <2 x float> %4, i64 1
  %.sroa.18.8.vec.extract = extractelement <2 x float> %5, i64 0
  %7 = fcmp olt float %.sroa.0.4.vec.extract, %.sroa.18.8.vec.extract
  %.sroa.0.4.vec.insert = shufflevector <2 x float> %4, <2 x float> %5, <2 x i32> <i32 0, i32 2>
  %.sroa.18.8.vec.insert = shufflevector <2 x float> %5, <2 x float> %4, <2 x i32> <i32 3, i32 1>
  %.0 = select i1 %7, float -1.000000e+00, float 0.000000e+00
  %.sroa.0.0 = select i1 %7, <2 x float> %.sroa.0.4.vec.insert, <2 x float> %4
  %.sroa.18.0 = select i1 %7, <2 x float> %.sroa.18.8.vec.insert, <2 x float> %5
  %.sroa.0.0.vec.extract = extractelement <2 x float> %.sroa.0.0, i64 0
  %.sroa.0.4.vec.extract27 = extractelement <2 x float> %.sroa.0.0, i64 1
  %8 = fcmp olt float %.sroa.0.0.vec.extract, %.sroa.0.4.vec.extract27
  %.sroa.0.4.vec.insert31 = shufflevector <2 x float> %.sroa.0.0, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %9 = fsub float 0xBFD5555560000000, %.0
  %.1 = select i1 %8, float %9, float %.0
  %.sroa.0.1 = select i1 %8, <2 x float> %.sroa.0.4.vec.insert31, <2 x float> %.sroa.0.0
  %.sroa.0.0.vec.extract18 = extractelement <2 x float> %.sroa.0.1, i64 0
  %.sroa.0.4.vec.extract33 = extractelement <2 x float> %.sroa.0.1, i64 1
  %.sroa.18.8.vec.extract46 = extractelement <2 x float> %.sroa.18.0, i64 0
  %10 = fcmp olt float %.sroa.0.4.vec.extract33, %.sroa.18.8.vec.extract46
  %11 = select i1 %10, float %.sroa.0.4.vec.extract33, float %.sroa.18.8.vec.extract46
  %12 = fsub float %.sroa.0.0.vec.extract18, %11
  %13 = fsub float %.sroa.0.4.vec.extract33, %.sroa.18.8.vec.extract46
  %14 = tail call float @llvm.fmuladd.f32(float %12, float 6.000000e+00, float 0x3BC79CA100000000)
  %15 = fdiv float %13, %14
  %16 = fadd float %.1, %15
  %17 = fcmp olt float %16, 0.000000e+00
  %18 = fneg float %16
  %19 = select i1 %17, float %18, float %16
  store float %19, ptr %0, align 4, !tbaa !5
  %20 = fadd float %.sroa.0.0.vec.extract18, 0x3BC79CA100000000
  %21 = fdiv float %12, %20
  store float %21, ptr %1, align 4, !tbaa !5
  store float %.sroa.0.0.vec.extract18, ptr %2, align 4, !tbaa !5
  %.sroa.18.12.vec.extract = extractelement <2 x float> %.sroa.18.0, i64 1
  store float %.sroa.18.12.vec.extract, ptr %3, align 4, !tbaa !5
  ret void
}

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

!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"}


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