; LLVM IR from awawa-dev/HyperHDR :: sources/base (SoundCaptureResult)

; 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.ColorRgb = type { i8, i8, i8 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18SoundCaptureResult17CalculateRgbDeltaE8ColorRgbS0_S0_RiS1_S1_(ptr noundef nonnull align 4 dereferenceable(296) %0, i24 %1, i24 %2, i24 %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6) #0 align 2 {
  %8 = alloca %struct.ColorRgb, align 1
  %9 = alloca %struct.ColorRgb, align 1
  %10 = alloca %struct.ColorRgb, align 1
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store i24 %1, ptr %8, align 1
  store i24 %2, ptr %9, align 1
  store i24 %3, ptr %10, align 1
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  %15 = load ptr, ptr %11, align 8
  %16 = call noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3) %8)
  %17 = mul nsw i32 %16, 2
  %18 = call noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3) %9)
  %19 = add nsw i32 %17, %18
  %20 = sdiv i32 %19, 3
  %21 = call noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3) %10)
  %22 = sub nsw i32 %20, %21
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %22, ptr %23, align 4, !tbaa !9
  %24 = call noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3) %8)
  %25 = mul nsw i32 %24, 2
  %26 = call noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3) %9)
  %27 = add nsw i32 %25, %26
  %28 = sdiv i32 %27, 3
  %29 = call noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3) %10)
  %30 = sub nsw i32 %28, %29
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %30, ptr %31, align 4, !tbaa !9
  %32 = call noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3) %8)
  %33 = mul nsw i32 %32, 2
  %34 = call noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3) %9)
  %35 = add nsw i32 %33, %34
  %36 = sdiv i32 %35, 3
  %37 = call noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3) %10)
  %38 = sub nsw i32 %36, %37
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 %38, ptr %39, align 4, !tbaa !9
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3)) #1 align 2

attributes #0 = { mustprogress 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 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" }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"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"

%struct.ColorRgb = type { i8, i8, i8 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN18SoundCaptureResult17CalculateRgbDeltaE8ColorRgbS0_S0_RiS1_S1_(ptr nocapture noundef nonnull readnone align 4 dereferenceable(296) %0, i24 %1, i24 %2, i24 %3, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %4, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %5, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %6) local_unnamed_addr #0 align 2 {
  %8 = alloca %struct.ColorRgb, align 4
  %9 = alloca %struct.ColorRgb, align 4
  %10 = alloca %struct.ColorRgb, align 4
  store i24 %1, ptr %8, align 4
  store i24 %2, ptr %9, align 4
  store i24 %3, ptr %10, align 4
  %11 = call noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3) %8)
  %12 = shl nsw i32 %11, 1
  %13 = call noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3) %9)
  %14 = add nsw i32 %12, %13
  %15 = sdiv i32 %14, 3
  %16 = call noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3) %10)
  %17 = sub nsw i32 %15, %16
  store i32 %17, ptr %4, align 4, !tbaa !5
  %18 = call noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3) %8)
  %19 = shl nsw i32 %18, 1
  %20 = call noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3) %9)
  %21 = add nsw i32 %19, %20
  %22 = sdiv i32 %21, 3
  %23 = call noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3) %10)
  %24 = sub nsw i32 %22, %23
  store i32 %24, ptr %5, align 4, !tbaa !5
  %25 = call noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3) %8)
  %26 = shl nsw i32 %25, 1
  %27 = call noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3) %9)
  %28 = add nsw i32 %26, %27
  %29 = sdiv i32 %28, 3
  %30 = call noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3) %10)
  %31 = sub nsw i32 %29, %30
  store i32 %31, ptr %6, align 4, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN8ColorRgb3RedEv(ptr noundef nonnull align 1 dereferenceable(3)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN8ColorRgb5GreenEv(ptr noundef nonnull align 1 dereferenceable(3)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN8ColorRgb4BlueEv(ptr noundef nonnull align 1 dereferenceable(3)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: GlobalOptPass,InferAlignmentPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass