; LLVM IR from hasseily/SuperDuperDisplay :: Ayumi.ll (ZN5Ayumi11UpdateNoiseEv)

; 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.Ayumi = type <{ i8, [7 x i8], [3 x %"struct.Ayumi::tone_channel"], i32, i32, i32, i32, i32, i32, i32, i32, ptr, double, double, %"struct.Ayumi::interpolator", %"struct.Ayumi::interpolator", [384 x double], [384 x double], i32, [4 x i8], %"struct.Ayumi::dc_filter", %"struct.Ayumi::dc_filter", i32, [4 x i8], double, double, i8, [7 x i8] }>
%"struct.Ayumi::tone_channel" = type { i32, i32, i32, i8, i8, i8, i32, double, double }
%"struct.Ayumi::interpolator" = type { [4 x double], [4 x double] }
%"struct.Ayumi::dc_filter" = type { double, [1024 x double] }

; 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 nounwind uwtable
define dso_local noundef i32 @_ZN5Ayumi11UpdateNoiseEv(ptr noundef nonnull align 8 dereferenceable(22889) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %5 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 4
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr %5, align 4, !tbaa !9
  %8 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 4
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 3
  %11 = load i32, ptr %10, align 8, !tbaa !16
  %12 = shl i32 %11, 1
  %13 = icmp sge i32 %9, %12
  br i1 %13, label %14, label %30

14:                                               ; preds = %1
  %15 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 4
  store i32 0, ptr %15, align 4, !tbaa !9
  %16 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 5
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 5
  %19 = load i32, ptr %18, align 8, !tbaa !17
  %20 = ashr i32 %19, 3
  %21 = xor i32 %17, %20
  %22 = and i32 %21, 1
  store i32 %22, ptr %3, align 4, !tbaa !18
  %23 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 5
  %24 = load i32, ptr %23, align 8, !tbaa !17
  %25 = ashr i32 %24, 1
  %26 = load i32, ptr %3, align 4, !tbaa !18
  %27 = shl i32 %26, 16
  %28 = or i32 %25, %27
  %29 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 5
  store i32 %28, ptr %29, align 8, !tbaa !17
  br label %30

30:                                               ; preds = %14, %1
  %31 = getelementptr inbounds %class.Ayumi, ptr %4, i32 0, i32 5
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %33 = and i32 %32, 1
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %33
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 132}
!10 = !{!"_ZTS5Ayumi", !7, i64 0, !7, i64 8, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !6, i64 160, !12, i64 168, !12, i64 176, !13, i64 184, !13, i64 248, !7, i64 312, !7, i64 3384, !11, i64 6456, !14, i64 6464, !14, i64 14664, !11, i64 22864, !12, i64 22872, !12, i64 22880, !15, i64 22888}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTSN5Ayumi12interpolatorE", !7, i64 0, !7, i64 32}
!14 = !{!"_ZTSN5Ayumi9dc_filterE", !12, i64 0, !7, i64 8}
!15 = !{!"bool", !7, i64 0}
!16 = !{!10, !11, i64 128}
!17 = !{!10, !11, i64 136}
!18 = !{!11, !11, 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN5Ayumi11UpdateNoiseEv(ptr nocapture noundef nonnull align 8 dereferenceable(22889) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 132
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = add nsw i32 %3, 1
  store i32 %4, ptr %2, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 128
  %6 = load i32, ptr %5, align 8, !tbaa !15
  %7 = shl i32 %6, 1
  %.not = icmp slt i32 %4, %7
  br i1 %.not, label %._crit_edge, label %8

._crit_edge:                                      ; preds = %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 136
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !16
  br label %17

8:                                                ; preds = %1
  store i32 0, ptr %2, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 136
  %10 = load i32, ptr %9, align 8, !tbaa !16
  %11 = lshr i32 %10, 3
  %12 = xor i32 %11, %10
  %13 = ashr i32 %10, 1
  %14 = shl i32 %12, 16
  %15 = and i32 %14, 65536
  %16 = or i32 %15, %13
  store i32 %16, ptr %9, align 8, !tbaa !16
  br label %17

17:                                               ; preds = %._crit_edge, %8
  %18 = phi i32 [ %.pre, %._crit_edge ], [ %16, %8 ]
  %19 = and i32 %18, 1
  ret i32 %19
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !9, i64 132}
!6 = !{!"_ZTS5Ayumi", !7, i64 0, !7, i64 8, !9, i64 128, !9, i64 132, !9, i64 136, !9, i64 140, !9, i64 144, !9, i64 148, !9, i64 152, !9, i64 156, !10, i64 160, !11, i64 168, !11, i64 176, !12, i64 184, !12, i64 248, !7, i64 312, !7, i64 3384, !9, i64 6456, !13, i64 6464, !13, i64 14664, !9, i64 22864, !11, i64 22872, !11, i64 22880, !14, i64 22888}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"double", !7, i64 0}
!12 = !{!"_ZTSN5Ayumi12interpolatorE", !7, i64 0, !7, i64 32}
!13 = !{!"_ZTSN5Ayumi9dc_filterE", !11, i64 0, !7, i64 8}
!14 = !{!"bool", !7, i64 0}
!15 = !{!6, !9, i64 128}
!16 = !{!6, !9, i64 136}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass