; LLVM IR from Try/Tempest :: Engine/thirdparty/openal-soft/core/ambidefs.ll (ZN9AmbiScale16GetHFOrderScalesEjjb)

; 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.std::array.5" = type { [4 x %"struct.std::array.4"] }
%"struct.std::array.4" = type { [4 x float] }

@_ZN12_GLOBAL__N_18HFScalesE = external hidden constant %"struct.std::array.5", align 4
@_ZN12_GLOBAL__N_110HFScales2DE = external hidden constant %"struct.std::array.5", align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN9AmbiScale16GetHFOrderScalesEjjb(i32 noundef %0, i32 noundef %1, i1 noundef zeroext %2) #0 align 2 {
  %4 = alloca %"struct.std::array.4", align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  %10 = zext i1 %2 to i8
  store i8 %10, ptr %7, align 1, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 4 %4, i8 0, i64 16, i1 false)
  %11 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %12 = trunc i8 %11 to i1
  br i1 %12, label %38, label %13

13:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !13
  br label %14

14:                                               ; preds = %34, %13
  %15 = load i64, ptr %8, align 8, !tbaa !13
  %16 = icmp ult i64 %15, 4
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %37

18:                                               ; preds = %14
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = zext i32 %19 to i64
  %21 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) @_ZN12_GLOBAL__N_18HFScalesE, i64 noundef %20) #3
  %22 = load i64, ptr %8, align 8, !tbaa !13
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %21, i64 noundef %22) #3
  %24 = load float, ptr %23, align 4, !tbaa !15
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) @_ZN12_GLOBAL__N_18HFScalesE, i64 noundef %26) #3
  %28 = load i64, ptr %8, align 8, !tbaa !13
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %27, i64 noundef %28) #3
  %30 = load float, ptr %29, align 4, !tbaa !15
  %31 = fdiv float %24, %30
  %32 = load i64, ptr %8, align 8, !tbaa !13
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %4, i64 noundef %32) #3
  store float %31, ptr %33, align 4, !tbaa !15
  br label %34

34:                                               ; preds = %18
  %35 = load i64, ptr %8, align 8, !tbaa !13
  %36 = add i64 %35, 1
  store i64 %36, ptr %8, align 8, !tbaa !13
  br label %14, !llvm.loop !17

37:                                               ; preds = %17
  br label %63

38:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !13
  br label %39

39:                                               ; preds = %59, %38
  %40 = load i64, ptr %9, align 8, !tbaa !13
  %41 = icmp ult i64 %40, 4
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %62

43:                                               ; preds = %39
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = zext i32 %44 to i64
  %46 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) @_ZN12_GLOBAL__N_110HFScales2DE, i64 noundef %45) #3
  %47 = load i64, ptr %9, align 8, !tbaa !13
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %46, i64 noundef %47) #3
  %49 = load float, ptr %48, align 4, !tbaa !15
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = zext i32 %50 to i64
  %52 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) @_ZN12_GLOBAL__N_110HFScales2DE, i64 noundef %51) #3
  %53 = load i64, ptr %9, align 8, !tbaa !13
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %52, i64 noundef %53) #3
  %55 = load float, ptr %54, align 4, !tbaa !15
  %56 = fdiv float %49, %55
  %57 = load i64, ptr %9, align 8, !tbaa !13
  %58 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %4, i64 noundef %57) #3
  store float %56, ptr %58, align 4, !tbaa !15
  br label %59

59:                                               ; preds = %43
  %60 = load i64, ptr %9, align 8, !tbaa !13
  %61 = add i64 %60, 1
  store i64 %61, ptr %9, align 8, !tbaa !13
  br label %39, !llvm.loop !19

62:                                               ; preds = %42
  br label %63

63:                                               ; preds = %62, %37
  %64 = getelementptr inbounds %"struct.std::array.4", ptr %4, i32 0, i32 0
  %65 = load { <2 x float>, <2 x float> }, ptr %64, align 4
  ret { <2 x float>, <2 x float> } %65
}

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16), i64 noundef) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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.std::array.5" = type { [4 x %"struct.std::array.4"] }
%"struct.std::array.4" = type { [4 x float] }

@_ZN12_GLOBAL__N_18HFScalesE = external hidden constant %"struct.std::array.5", align 4
@_ZN12_GLOBAL__N_110HFScales2DE = external hidden constant %"struct.std::array.5", align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN9AmbiScale16GetHFOrderScalesEjjb(i32 noundef %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
.loopexit:
  %3 = alloca %"struct.std::array.4", align 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  %4 = zext i32 %0 to i64
  %5 = zext i32 %1 to i64
  %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE = select i1 %2, ptr @_ZN12_GLOBAL__N_110HFScales2DE, ptr @_ZN12_GLOBAL__N_18HFScalesE
  %6 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %4) #2
  %7 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %6, i64 noundef 0) #2
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %5) #2
  %10 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %9, i64 noundef 0) #2
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fdiv float %8, %11
  %13 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %3, i64 noundef 0) #2
  store float %12, ptr %13, align 4, !tbaa !5
  %14 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %4) #2
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %14, i64 noundef 1) #2
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %5) #2
  %18 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %17, i64 noundef 1) #2
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = fdiv float %16, %19
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %3, i64 noundef 1) #2
  store float %20, ptr %21, align 4, !tbaa !5
  %22 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %4) #2
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %22, i64 noundef 2) #2
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %5) #2
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %25, i64 noundef 2) #2
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = fdiv float %24, %27
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %3, i64 noundef 2) #2
  store float %28, ptr %29, align 4, !tbaa !5
  %30 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %4) #2
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %30, i64 noundef 3) #2
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64) %_ZN12_GLOBAL__N_110HFScales2DE._ZN12_GLOBAL__N_18HFScalesE, i64 noundef %5) #2
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %33, i64 noundef 3) #2
  %35 = load float, ptr %34, align 4, !tbaa !5
  %36 = fdiv float %32, %35
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16) %3, i64 noundef 3) #2
  store float %36, ptr %37, align 4, !tbaa !5
  %.fca.0.load = load <2 x float>, ptr %3, align 8
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds i8, ptr %3, i64 8
  %.fca.1.load = load <2 x float>, ptr %.fca.1.gep, align 8
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.fca.1.load, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt5arrayIS_IfLm4EELm4EEixEm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm4EEixEm(ptr noundef nonnull align 4 dereferenceable(16), i64 noundef) 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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass