; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/vic/soloud_vic.ll (ZN6SoLoud3VicC2Ev)

; 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"

%"class.SoLoud::AudioSource" = type { ptr, i32, float, float, i32, i32, float, float, float, i32, float, [8 x ptr], ptr, ptr, ptr, i32, double }
%"class.SoLoud::Vic" = type { %"class.SoLoud::AudioSource", i32, [4 x float], [4 x i8], [8192 x i8] }

@_ZTVN6SoLoud3VicE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8

; 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: mustprogress uwtable
define dso_local void @_ZN6SoLoud3VicC2Ev(ptr noundef nonnull align 8 dereferenceable(8368) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @_ZN6SoLoud11AudioSourceC2Ev(ptr noundef nonnull align 8 dereferenceable(152) %9)
  store ptr getelementptr inbounds inrange(-16, 32) ({ [6 x ptr] }, ptr @_ZTVN6SoLoud3VicE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %9, i32 0, i32 2
  store float 4.410000e+04, ptr %10, align 4, !tbaa !11
  invoke void @_ZN6SoLoud3Vic8setModelEi(ptr noundef nonnull align 8 dereferenceable(8368) %9, i32 noundef 0)
          to label %11 unwind label %16

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !16
  br label %12

12:                                               ; preds = %25, %11
  %13 = load i32, ptr %5, align 4, !tbaa !16
  %14 = icmp slt i32 %13, 4
  br i1 %14, label %20, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %28

16:                                               ; preds = %1
  %17 = landingpad { ptr, i32 }
          cleanup
  %18 = extractvalue { ptr, i32 } %17, 0
  store ptr %18, ptr %3, align 8
  %19 = extractvalue { ptr, i32 } %17, 1
  store i32 %19, ptr %4, align 4
  call void @_ZN6SoLoud11AudioSourceD2Ev(ptr noundef nonnull align 8 dereferenceable(152) %9) #5
  br label %64

20:                                               ; preds = %12
  %21 = getelementptr inbounds %"class.SoLoud::Vic", ptr %9, i32 0, i32 3
  %22 = load i32, ptr %5, align 4, !tbaa !16
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [4 x i8], ptr %21, i64 0, i64 %23
  store i8 0, ptr %24, align 1, !tbaa !17
  br label %25

25:                                               ; preds = %20
  %26 = load i32, ptr %5, align 4, !tbaa !16
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %5, align 4, !tbaa !16
  br label %12, !llvm.loop !18

28:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #5
  store i16 -21279, ptr %6, align 2, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !16
  br label %29

29:                                               ; preds = %60, %28
  %30 = load i32, ptr %7, align 4, !tbaa !16
  %31 = icmp slt i32 %30, 8192
  br i1 %31, label %33, label %32

32:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %63

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %34 = load i16, ptr %6, align 2, !tbaa !20
  %35 = zext i16 %34 to i32
  %36 = and i32 %35, 1
  store i32 %36, ptr %8, align 4, !tbaa !16
  %37 = load i16, ptr %6, align 2, !tbaa !20
  %38 = zext i16 %37 to i32
  %39 = ashr i32 %38, 1
  %40 = trunc i32 %39 to i16
  store i16 %40, ptr %6, align 2, !tbaa !20
  %41 = load i32, ptr %8, align 4, !tbaa !16
  %42 = sub nsw i32 0, %41
  %43 = and i32 %42, 46080
  %44 = load i16, ptr %6, align 2, !tbaa !20
  %45 = zext i16 %44 to i32
  %46 = xor i32 %45, %43
  %47 = trunc i32 %46 to i16
  store i16 %47, ptr %6, align 2, !tbaa !20
  %48 = load i16, ptr %6, align 2, !tbaa !20
  %49 = zext i16 %48 to i32
  %50 = and i32 %49, 255
  %51 = load i16, ptr %6, align 2, !tbaa !20
  %52 = zext i16 %51 to i32
  %53 = ashr i32 %52, 8
  %54 = xor i32 %50, %53
  %55 = trunc i32 %54 to i8
  %56 = getelementptr inbounds %"class.SoLoud::Vic", ptr %9, i32 0, i32 4
  %57 = load i32, ptr %7, align 4, !tbaa !16
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [8192 x i8], ptr %56, i64 0, i64 %58
  store i8 %55, ptr %59, align 1, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %60

60:                                               ; preds = %33
  %61 = load i32, ptr %7, align 4, !tbaa !16
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %7, align 4, !tbaa !16
  br label %29, !llvm.loop !22

63:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #5
  ret void

64:                                               ; preds = %16
  %65 = load ptr, ptr %3, align 8
  %66 = load i32, ptr %4, align 4
  %67 = insertvalue { ptr, i32 } poison, ptr %65, 0
  %68 = insertvalue { ptr, i32 } %67, i32 %66, 1
  resume { ptr, i32 } %68
}

declare void @_ZN6SoLoud11AudioSourceC2Ev(ptr noundef nonnull align 8 dereferenceable(152)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6SoLoud3Vic8setModelEi(ptr noundef nonnull align 8 dereferenceable(8368), i32 noundef) #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN6SoLoud11AudioSourceD2Ev(ptr noundef nonnull align 8 dereferenceable(152)) unnamed_addr #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 #4 = { nounwind "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 #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 = !{!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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !14, i64 12}
!12 = !{!"_ZTSN6SoLoud11AudioSourceE", !13, i64 8, !14, i64 12, !14, i64 16, !13, i64 20, !13, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !13, i64 40, !14, i64 44, !7, i64 48, !6, i64 112, !6, i64 120, !6, i64 128, !13, i64 136, !15, i64 144}
!13 = !{!"int", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !21, i64 0}
!21 = !{!"short", !7, i64 0}
!22 = distinct !{!22, !19}


; 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"

@_ZTVN6SoLoud3VicE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud3VicC2Ev(ptr noundef nonnull align 8 dereferenceable(8368) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
.preheader:
  tail call void @_ZN6SoLoud11AudioSourceC2Ev(ptr noundef nonnull align 8 dereferenceable(152) %0)
  store ptr getelementptr inbounds inrange(-16, 32) (i8, ptr @_ZTVN6SoLoud3VicE, i64 16), ptr %0, align 8, !tbaa !5
  %1 = getelementptr inbounds i8, ptr %0, i64 12
  store float 4.410000e+04, ptr %1, align 4, !tbaa !8
  tail call void @_ZN6SoLoud3Vic8setModelEi(ptr noundef nonnull align 8 dereferenceable(8368) %0, i32 noundef 0)
  %2 = getelementptr inbounds i8, ptr %0, i64 172
  store i32 0, ptr %2, align 4
  %3 = getelementptr inbounds i8, ptr %0, i64 176
  br label %5

4:                                                ; preds = %5
  ret void

5:                                                ; preds = %5, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next.1, %5 ]
  %.01315 = phi i32 [ 44257, %.preheader ], [ %20, %5 ]
  %6 = and i32 %.01315, 1
  %7 = lshr i32 %.01315, 1
  %8 = icmp eq i32 %6, 0
  %9 = select i1 %8, i32 0, i32 46080
  %10 = and i32 %7, 32767
  %11 = xor i32 %9, %10
  %12 = lshr i32 %11, 8
  %13 = xor i32 %12, %7
  %14 = trunc i32 %13 to i8
  %15 = getelementptr inbounds [8192 x i8], ptr %3, i64 0, i64 %indvars.iv
  store i8 %14, ptr %15, align 2, !tbaa !15
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %16 = lshr i32 %11, 1
  %17 = and i32 %.01315, 2
  %18 = icmp eq i32 %17, 0
  %19 = select i1 %18, i32 0, i32 46080
  %20 = xor i32 %19, %16
  %21 = lshr i32 %20, 8
  %22 = xor i32 %21, %16
  %23 = trunc i32 %22 to i8
  %24 = getelementptr inbounds [8192 x i8], ptr %3, i64 0, i64 %indvars.iv.next
  store i8 %23, ptr %24, align 1, !tbaa !15
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 8192
  br i1 %exitcond.not.1, label %4, label %5, !llvm.loop !16
}

declare void @_ZN6SoLoud11AudioSourceC2Ev(ptr noundef nonnull align 8 dereferenceable(152)) unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6SoLoud3Vic8setModelEi(ptr noundef nonnull align 8 dereferenceable(8368), i32 noundef) local_unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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 = { "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 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 12}
!9 = !{!"_ZTSN6SoLoud11AudioSourceE", !10, i64 8, !12, i64 12, !12, i64 16, !10, i64 20, !10, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !10, i64 40, !12, i64 44, !11, i64 48, !13, i64 112, !13, i64 120, !13, i64 128, !10, i64 136, !14, i64 144}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"float", !11, i64 0}
!13 = !{!"any pointer", !11, i64 0}
!14 = !{!"double", !11, i64 0}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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