; LLVM IR from NotManyIdeasDev/double-pendulum-sim :: double-pendulum-sim/Libraries/raygui-2.8/examples/controls_test_suite (GuiColorPicker)

; 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.Color = type { i8, i8, i8, i8 }
%struct.Rectangle = type { float, float, float, float }
%struct.Vector3 = type { float, float, float }

; 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) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, float } @ConvertRGBtoHSV(<2 x float>, float) #3

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, float } @ConvertHSVtoRGB(<2 x float>, float) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @GuiColorPanel(<2 x float>, <2 x float>, i32) #3

; Function Attrs: nounwind uwtable
declare dso_local float @GuiColorBarHue(<2 x float>, <2 x float>, float noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @GuiColorPicker(<2 x float> %0, <2 x float> %1, i32 %2) #3 {
  %4 = alloca %struct.Color, align 1
  %5 = alloca %struct.Rectangle, align 4
  %6 = alloca %struct.Color, align 1
  %7 = alloca %struct.Color, align 1
  %8 = alloca %struct.Rectangle, align 4
  %9 = alloca %struct.Vector3, align 4
  %10 = alloca %struct.Vector3, align 4
  %11 = alloca { <2 x float>, float }, align 4
  %12 = alloca { <2 x float>, float }, align 8
  %13 = alloca %struct.Vector3, align 4
  %14 = alloca { <2 x float>, float }, align 4
  %15 = alloca { <2 x float>, float }, align 8
  %16 = alloca %struct.Color, align 1
  %17 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  store <2 x float> %0, ptr %17, align 4
  %18 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  store <2 x float> %1, ptr %18, align 4
  store i32 %2, ptr %6, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %19 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  %20 = load <2 x float>, ptr %19, align 4
  %21 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  %22 = load <2 x float>, ptr %21, align 4
  %23 = load i32, ptr %6, align 1
  %24 = call i32 @GuiColorPanel(<2 x float> %20, <2 x float> %22, i32 %23)
  store i32 %24, ptr %7, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 %7, i64 4, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %25 = getelementptr inbounds %struct.Rectangle, ptr %8, i32 0, i32 0
  %26 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  %27 = load float, ptr %26, align 4, !tbaa !9
  %28 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 2
  %29 = load float, ptr %28, align 4, !tbaa !12
  %30 = fadd float %27, %29
  %31 = call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 18)
  %32 = sitofp i32 %31 to float
  %33 = fadd float %30, %32
  store float %33, ptr %25, align 4, !tbaa !9
  %34 = getelementptr inbounds %struct.Rectangle, ptr %8, i32 0, i32 1
  %35 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !13
  store float %36, ptr %34, align 4, !tbaa !13
  %37 = getelementptr inbounds %struct.Rectangle, ptr %8, i32 0, i32 2
  %38 = call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 17)
  %39 = sitofp i32 %38 to float
  store float %39, ptr %37, align 4, !tbaa !12
  %40 = getelementptr inbounds %struct.Rectangle, ptr %8, i32 0, i32 3
  %41 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 3
  %42 = load float, ptr %41, align 4, !tbaa !14
  store float %42, ptr %40, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #5
  %43 = getelementptr inbounds %struct.Vector3, ptr %10, i32 0, i32 0
  %44 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 0
  %45 = load i8, ptr %44, align 1, !tbaa !15
  %46 = zext i8 %45 to i32
  %47 = sitofp i32 %46 to float
  %48 = fdiv float %47, 2.550000e+02
  store float %48, ptr %43, align 4, !tbaa !17
  %49 = getelementptr inbounds %struct.Vector3, ptr %10, i32 0, i32 1
  %50 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 1
  %51 = load i8, ptr %50, align 1, !tbaa !19
  %52 = zext i8 %51 to i32
  %53 = sitofp i32 %52 to float
  %54 = fdiv float %53, 2.550000e+02
  store float %54, ptr %49, align 4, !tbaa !20
  %55 = getelementptr inbounds %struct.Vector3, ptr %10, i32 0, i32 2
  %56 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 2
  %57 = load i8, ptr %56, align 1, !tbaa !21
  %58 = zext i8 %57 to i32
  %59 = sitofp i32 %58 to float
  %60 = fdiv float %59, 2.550000e+02
  store float %60, ptr %55, align 4, !tbaa !22
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %10, i64 12, i1 false)
  %61 = getelementptr inbounds { <2 x float>, float }, ptr %11, i32 0, i32 0
  %62 = load <2 x float>, ptr %61, align 4
  %63 = getelementptr inbounds { <2 x float>, float }, ptr %11, i32 0, i32 1
  %64 = load float, ptr %63, align 4
  %65 = call { <2 x float>, float } @ConvertRGBtoHSV(<2 x float> %62, float %64)
  store { <2 x float>, float } %65, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 8 %12, i64 12, i1 false)
  %66 = getelementptr inbounds %struct.Vector3, ptr %9, i32 0, i32 0
  %67 = load float, ptr %66, align 4, !tbaa !17
  %68 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 0
  %69 = load <2 x float>, ptr %68, align 4
  %70 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 1
  %71 = load <2 x float>, ptr %70, align 4
  %72 = call float @GuiColorBarHue(<2 x float> %69, <2 x float> %71, float noundef %67)
  %73 = getelementptr inbounds %struct.Vector3, ptr %9, i32 0, i32 0
  store float %72, ptr %73, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %9, i64 12, i1 false)
  %74 = getelementptr inbounds { <2 x float>, float }, ptr %14, i32 0, i32 0
  %75 = load <2 x float>, ptr %74, align 4
  %76 = getelementptr inbounds { <2 x float>, float }, ptr %14, i32 0, i32 1
  %77 = load float, ptr %76, align 4
  %78 = call { <2 x float>, float } @ConvertHSVtoRGB(<2 x float> %75, float %77)
  store { <2 x float>, float } %78, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 8 %15, i64 12, i1 false)
  %79 = getelementptr inbounds %struct.Color, ptr %16, i32 0, i32 0
  %80 = getelementptr inbounds %struct.Vector3, ptr %13, i32 0, i32 0
  %81 = load float, ptr %80, align 4, !tbaa !17
  %82 = fmul float %81, 2.550000e+02
  %83 = call float @llvm.round.f32(float %82)
  %84 = fptoui float %83 to i8
  store i8 %84, ptr %79, align 1, !tbaa !15
  %85 = getelementptr inbounds %struct.Color, ptr %16, i32 0, i32 1
  %86 = getelementptr inbounds %struct.Vector3, ptr %13, i32 0, i32 1
  %87 = load float, ptr %86, align 4, !tbaa !20
  %88 = fmul float %87, 2.550000e+02
  %89 = call float @llvm.round.f32(float %88)
  %90 = fptoui float %89 to i8
  store i8 %90, ptr %85, align 1, !tbaa !19
  %91 = getelementptr inbounds %struct.Color, ptr %16, i32 0, i32 2
  %92 = getelementptr inbounds %struct.Vector3, ptr %13, i32 0, i32 2
  %93 = load float, ptr %92, align 4, !tbaa !22
  %94 = fmul float %93, 2.550000e+02
  %95 = call float @llvm.round.f32(float %94)
  %96 = fptoui float %95 to i8
  store i8 %96, ptr %91, align 1, !tbaa !21
  %97 = getelementptr inbounds %struct.Color, ptr %16, i32 0, i32 3
  %98 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 3
  %99 = load i8, ptr %98, align 1, !tbaa !23
  store i8 %99, ptr %97, align 1, !tbaa !23
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 %16, i64 4, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %4, ptr align 1 %6, i64 4, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  %100 = load i32, ptr %4, align 1
  ret i32 %100
}

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{i64 0, i64 1, !6, i64 1, i64 1, !6, i64 2, i64 1, !6, i64 3, i64 1, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Rectangle", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 12}
!15 = !{!16, !7, i64 0}
!16 = !{!"Color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!17 = !{!18, !11, i64 0}
!18 = !{!"Vector3", !11, i64 0, !11, i64 4, !11, i64 8}
!19 = !{!16, !7, i64 1}
!20 = !{!18, !11, i64 4}
!21 = !{!16, !7, i64 2}
!22 = !{!18, !11, i64 8}
!23 = !{!16, !7, i64 3}


; 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 dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, float } @ConvertRGBtoHSV(<2 x float>, float) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, float } @ConvertHSVtoRGB(<2 x float>, float) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @GuiColorPanel(<2 x float>, <2 x float>, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local float @GuiColorBarHue(<2 x float>, <2 x float>, float noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @GuiColorPicker(<2 x float> %0, <2 x float> %1, i32 %2) local_unnamed_addr #1 {
  %4 = tail call i32 @GuiColorPanel(<2 x float> %0, <2 x float> %1, i32 %2)
  %.sroa.626.0.extract.shift27 = lshr i32 %4, 8
  %.sroa.8.0.extract.shift29 = lshr i32 %4, 16
  %.sroa.10.0.extract.shift31 = and i32 %4, -16777216
  %5 = fadd <2 x float> %0, %1
  %6 = extractelement <2 x float> %5, i64 0
  %7 = tail call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 18)
  %8 = sitofp i32 %7 to float
  %9 = fadd float %6, %8
  %.sroa.018.4.vec.insert = insertelement <2 x float> %0, float %9, i64 0
  %10 = tail call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 17)
  %11 = sitofp i32 %10 to float
  %.sroa.520.12.vec.insert = insertelement <2 x float> %1, float %11, i64 0
  %12 = insertelement <2 x i32> poison, i32 %4, i64 0
  %13 = insertelement <2 x i32> %12, i32 %.sroa.626.0.extract.shift27, i64 1
  %14 = and <2 x i32> %13, <i32 255, i32 255>
  %15 = uitofp nneg <2 x i32> %14 to <2 x float>
  %16 = fdiv <2 x float> %15, <float 2.550000e+02, float 2.550000e+02>
  %17 = and i32 %.sroa.8.0.extract.shift29, 255
  %18 = uitofp nneg i32 %17 to float
  %19 = fdiv float %18, 2.550000e+02
  %20 = tail call { <2 x float>, float } @ConvertRGBtoHSV(<2 x float> %16, float %19)
  %.fca.0.extract6 = extractvalue { <2 x float>, float } %20, 0
  %.fca.1.extract7 = extractvalue { <2 x float>, float } %20, 1
  %.sroa.015.0.vec.extract = extractelement <2 x float> %.fca.0.extract6, i64 0
  %21 = tail call float @GuiColorBarHue(<2 x float> %.sroa.018.4.vec.insert, <2 x float> %.sroa.520.12.vec.insert, float noundef %.sroa.015.0.vec.extract)
  %.sroa.015.0.vec.insert = insertelement <2 x float> %.fca.0.extract6, float %21, i64 0
  %22 = tail call { <2 x float>, float } @ConvertHSVtoRGB(<2 x float> %.sroa.015.0.vec.insert, float %.fca.1.extract7)
  %.fca.0.extract = extractvalue { <2 x float>, float } %22, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %22, 1
  %.sroa.05.0.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 0
  %23 = fmul float %.sroa.05.0.vec.extract, 2.550000e+02
  %24 = tail call float @llvm.round.f32(float %23)
  %25 = fptoui float %24 to i8
  %.sroa.05.4.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 1
  %26 = fmul float %.sroa.05.4.vec.extract, 2.550000e+02
  %27 = tail call float @llvm.round.f32(float %26)
  %28 = fptoui float %27 to i8
  %29 = fmul float %.fca.1.extract, 2.550000e+02
  %30 = tail call float @llvm.round.f32(float %29)
  %31 = fptoui float %30 to i8
  %.sroa.339.0.insert.ext = zext i8 %31 to i32
  %.sroa.339.0.insert.shift = shl nuw nsw i32 %.sroa.339.0.insert.ext, 16
  %.sroa.339.0.insert.insert = or disjoint i32 %.sroa.339.0.insert.shift, %.sroa.10.0.extract.shift31
  %.sroa.238.0.insert.ext = zext i8 %28 to i32
  %.sroa.238.0.insert.shift = shl nuw nsw i32 %.sroa.238.0.insert.ext, 8
  %.sroa.238.0.insert.insert = or disjoint i32 %.sroa.339.0.insert.insert, %.sroa.238.0.insert.shift
  %.sroa.037.0.insert.ext = zext i8 %25 to i32
  %.sroa.037.0.insert.insert = or disjoint i32 %.sroa.238.0.insert.insert, %.sroa.037.0.insert.ext
  ret i32 %.sroa.037.0.insert.insert
}

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

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 = { 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 = { 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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass