; 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 { <2 x float>, <2 x float> } @nk_hsva_colorf(float noundef %0, float noundef %1, float noundef %2, float noundef %3) #2 {
  %5 = alloca %struct.nk_colorf, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca i32, 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 float %3, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.memset.p0.i64(ptr align 4 %5, i8 0, i64 16, i1 false)
  %16 = load float, ptr %7, align 4, !tbaa !5
  %17 = fcmp ole float %16, 0.000000e+00
  br i1 %17, label %18, label %27

18:                                               ; preds = %4
  %19 = load float, ptr %8, align 4, !tbaa !5
  %20 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 0
  store float %19, ptr %20, align 4, !tbaa !9
  %21 = load float, ptr %8, align 4, !tbaa !5
  %22 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 1
  store float %21, ptr %22, align 4, !tbaa !11
  %23 = load float, ptr %8, align 4, !tbaa !5
  %24 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 2
  store float %23, ptr %24, align 4, !tbaa !12
  %25 = load float, ptr %9, align 4, !tbaa !5
  %26 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 3
  store float %25, ptr %26, align 4, !tbaa !13
  store i32 1, ptr %15, align 4
  br label %100

27:                                               ; preds = %4
  %28 = load float, ptr %6, align 4, !tbaa !5
  %29 = fdiv float %28, 0x3FC5555560000000
  store float %29, ptr %6, align 4, !tbaa !5
  %30 = load float, ptr %6, align 4, !tbaa !5
  %31 = fptosi float %30 to i32
  store i32 %31, ptr %10, align 4, !tbaa !14
  %32 = load float, ptr %6, align 4, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !14
  %34 = sitofp i32 %33 to float
  %35 = fsub float %32, %34
  store float %35, ptr %14, align 4, !tbaa !5
  %36 = load float, ptr %8, align 4, !tbaa !5
  %37 = load float, ptr %7, align 4, !tbaa !5
  %38 = fsub float 1.000000e+00, %37
  %39 = fmul float %36, %38
  store float %39, ptr %11, align 4, !tbaa !5
  %40 = load float, ptr %8, align 4, !tbaa !5
  %41 = load float, ptr %7, align 4, !tbaa !5
  %42 = load float, ptr %14, align 4, !tbaa !5
  %43 = fneg float %41
  %44 = call float @llvm.fmuladd.f32(float %43, float %42, float 1.000000e+00)
  %45 = fmul float %40, %44
  store float %45, ptr %12, align 4, !tbaa !5
  %46 = load float, ptr %8, align 4, !tbaa !5
  %47 = load float, ptr %7, align 4, !tbaa !5
  %48 = load float, ptr %14, align 4, !tbaa !5
  %49 = fsub float 1.000000e+00, %48
  %50 = fneg float %47
  %51 = call float @llvm.fmuladd.f32(float %50, float %49, float 1.000000e+00)
  %52 = fmul float %46, %51
  store float %52, ptr %13, align 4, !tbaa !5
  %53 = load i32, ptr %10, align 4, !tbaa !14
  switch i32 %53, label %55 [
    i32 0, label %54
    i32 1, label %62
    i32 2, label %69
    i32 3, label %76
    i32 4, label %83
    i32 5, label %90
  ]

54:                                               ; preds = %27
  br label %55

55:                                               ; preds = %54, %27
  %56 = load float, ptr %8, align 4, !tbaa !5
  %57 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 0
  store float %56, ptr %57, align 4, !tbaa !9
  %58 = load float, ptr %13, align 4, !tbaa !5
  %59 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 1
  store float %58, ptr %59, align 4, !tbaa !11
  %60 = load float, ptr %11, align 4, !tbaa !5
  %61 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 2
  store float %60, ptr %61, align 4, !tbaa !12
  br label %97

62:                                               ; preds = %27
  %63 = load float, ptr %12, align 4, !tbaa !5
  %64 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 0
  store float %63, ptr %64, align 4, !tbaa !9
  %65 = load float, ptr %8, align 4, !tbaa !5
  %66 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 1
  store float %65, ptr %66, align 4, !tbaa !11
  %67 = load float, ptr %11, align 4, !tbaa !5
  %68 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 2
  store float %67, ptr %68, align 4, !tbaa !12
  br label %97

69:                                               ; preds = %27
  %70 = load float, ptr %11, align 4, !tbaa !5
  %71 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 0
  store float %70, ptr %71, align 4, !tbaa !9
  %72 = load float, ptr %8, align 4, !tbaa !5
  %73 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 1
  store float %72, ptr %73, align 4, !tbaa !11
  %74 = load float, ptr %13, align 4, !tbaa !5
  %75 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 2
  store float %74, ptr %75, align 4, !tbaa !12
  br label %97

76:                                               ; preds = %27
  %77 = load float, ptr %11, align 4, !tbaa !5
  %78 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 0
  store float %77, ptr %78, align 4, !tbaa !9
  %79 = load float, ptr %12, align 4, !tbaa !5
  %80 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 1
  store float %79, ptr %80, align 4, !tbaa !11
  %81 = load float, ptr %8, align 4, !tbaa !5
  %82 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 2
  store float %81, ptr %82, align 4, !tbaa !12
  br label %97

83:                                               ; preds = %27
  %84 = load float, ptr %13, align 4, !tbaa !5
  %85 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 0
  store float %84, ptr %85, align 4, !tbaa !9
  %86 = load float, ptr %11, align 4, !tbaa !5
  %87 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 1
  store float %86, ptr %87, align 4, !tbaa !11
  %88 = load float, ptr %8, align 4, !tbaa !5
  %89 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 2
  store float %88, ptr %89, align 4, !tbaa !12
  br label %97

90:                                               ; preds = %27
  %91 = load float, ptr %8, align 4, !tbaa !5
  %92 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 0
  store float %91, ptr %92, align 4, !tbaa !9
  %93 = load float, ptr %11, align 4, !tbaa !5
  %94 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 1
  store float %93, ptr %94, align 4, !tbaa !11
  %95 = load float, ptr %12, align 4, !tbaa !5
  %96 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 2
  store float %95, ptr %96, align 4, !tbaa !12
  br label %97

97:                                               ; preds = %90, %83, %76, %69, %62, %55
  %98 = load float, ptr %9, align 4, !tbaa !5
  %99 = getelementptr inbounds %struct.nk_colorf, ptr %5, i32 0, i32 3
  store float %98, ptr %99, align 4, !tbaa !13
  store i32 1, ptr %15, align 4
  br label %100

100:                                              ; preds = %97, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %101 = load { <2 x float>, <2 x float> }, ptr %5, align 4
  ret { <2 x float>, <2 x float> } %101
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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"="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 nounwind willreturn memory(argmem: write) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"nk_colorf", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !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: 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(none) uwtable
define dso_local { <2 x float>, <2 x float> } @nk_hsva_colorf(float noundef %0, float noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #1 {
  %5 = fcmp ugt float %1, 0.000000e+00
  br i1 %5, label %7, label %6

6:                                                ; preds = %4
  %.sroa.0.0.vec.insert = insertelement <2 x float> <float poison, float 0.000000e+00>, float %2, i64 0
  %.sroa.0.4.vec.insert = shufflevector <2 x float> %.sroa.0.0.vec.insert, <2 x float> poison, <2 x i32> zeroinitializer
  br label %26

7:                                                ; preds = %4
  %8 = fdiv float %0, 0x3FC5555560000000
  %9 = fptosi float %8 to i32
  %10 = sitofp i32 %9 to float
  %11 = fsub float %8, %10
  %12 = fsub float 1.000000e+00, %1
  %13 = fmul float %12, %2
  %14 = fneg float %1
  %15 = tail call float @llvm.fmuladd.f32(float %14, float %11, float 1.000000e+00)
  %16 = fmul float %15, %2
  %17 = fsub float 1.000000e+00, %11
  %18 = tail call float @llvm.fmuladd.f32(float %14, float %17, float 1.000000e+00)
  %19 = fmul float %18, %2
  switch i32 %9, label %25 [
    i32 5, label %24
    i32 1, label %20
    i32 2, label %21
    i32 3, label %22
    i32 4, label %23
  ]

20:                                               ; preds = %7
  br label %25

21:                                               ; preds = %7
  br label %25

22:                                               ; preds = %7
  br label %25

23:                                               ; preds = %7
  br label %25

24:                                               ; preds = %7
  br label %25

25:                                               ; preds = %7, %24, %23, %22, %21, %20
  %.sink77 = phi float [ %2, %24 ], [ %19, %23 ], [ %13, %22 ], [ %13, %21 ], [ %16, %20 ], [ %2, %7 ]
  %.sink76 = phi float [ %13, %24 ], [ %13, %23 ], [ %16, %22 ], [ %2, %21 ], [ %2, %20 ], [ %19, %7 ]
  %.sink = phi float [ %16, %24 ], [ %2, %23 ], [ %2, %22 ], [ %19, %21 ], [ %13, %20 ], [ %13, %7 ]
  %.sroa.0.0.vec.insert48 = insertelement <2 x float> poison, float %.sink77, i64 0
  %.sroa.0.4.vec.insert60 = insertelement <2 x float> %.sroa.0.0.vec.insert48, float %.sink76, i64 1
  %.sroa.16.8.vec.insert73 = insertelement <2 x float> <float poison, float 0.000000e+00>, float %.sink, i64 0
  br label %26

26:                                               ; preds = %25, %6
  %.sroa.16.8.vec.insert73.sink = phi <2 x float> [ %.sroa.16.8.vec.insert73, %25 ], [ %.sroa.0.0.vec.insert, %6 ]
  %.sroa.0.1 = phi <2 x float> [ %.sroa.0.4.vec.insert60, %25 ], [ %.sroa.0.4.vec.insert, %6 ]
  %.sroa.16.12.vec.insert75 = insertelement <2 x float> %.sroa.16.8.vec.insert73.sink, float %3, i64 1
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.sroa.0.1, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.sroa.16.12.vec.insert75, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

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