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

; 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] }

@_ZL9Envelopes = external hidden constant [16 x [2 x ptr]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5Ayumi12ResetSegmentEv(ptr noundef nonnull align 8 dereferenceable(22889) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.Ayumi, ptr %3, i32 0, i32 8
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [16 x [2 x ptr]], ptr @_ZL9Envelopes, i64 0, i64 %6
  %8 = getelementptr inbounds %class.Ayumi, ptr %3, i32 0, i32 9
  %9 = load i32, ptr %8, align 8, !tbaa !16
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [2 x ptr], ptr %7, i64 0, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = icmp eq ptr %12, @_ZL10slide_downP5Ayumi
  br i1 %13, label %25, label %14

14:                                               ; preds = %1
  %15 = getelementptr inbounds %class.Ayumi, ptr %3, i32 0, i32 8
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [16 x [2 x ptr]], ptr @_ZL9Envelopes, i64 0, i64 %17
  %19 = getelementptr inbounds %class.Ayumi, ptr %3, i32 0, i32 9
  %20 = load i32, ptr %19, align 8, !tbaa !16
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [2 x ptr], ptr %18, i64 0, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = icmp eq ptr %23, @_ZL8hold_topP5Ayumi
  br i1 %24, label %25, label %27

25:                                               ; preds = %14, %1
  %26 = getelementptr inbounds %class.Ayumi, ptr %3, i32 0, i32 10
  store i32 31, ptr %26, align 4, !tbaa !17
  br label %29

27:                                               ; preds = %14
  %28 = getelementptr inbounds %class.Ayumi, ptr %3, i32 0, i32 10
  store i32 0, ptr %28, align 4, !tbaa !17
  br label %29

29:                                               ; preds = %27, %25
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL10slide_downP5Ayumi(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8hold_topP5Ayumi(ptr noundef) #0

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 148}
!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 152}
!17 = !{!10, !11, i64 156}


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

@_ZL9Envelopes = external hidden local_unnamed_addr constant [16 x [2 x ptr]], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN5Ayumi12ResetSegmentEv(ptr nocapture noundef nonnull align 8 dereferenceable(22889) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 148
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds i8, ptr %0, i64 152
  %6 = load i32, ptr %5, align 8, !tbaa !15
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [16 x [2 x ptr]], ptr @_ZL9Envelopes, i64 0, i64 %4, i64 %7
  %9 = load ptr, ptr %8, align 8, !tbaa !16
  %10 = icmp eq ptr %9, @_ZL10slide_downP5Ayumi
  %11 = icmp eq ptr %9, @_ZL8hold_topP5Ayumi
  %or.cond = or i1 %10, %11
  %spec.select = select i1 %or.cond, i32 31, i32 0
  %12 = getelementptr inbounds i8, ptr %0, i64 156
  store i32 %spec.select, ptr %12, align 4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL10slide_downP5Ayumi(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8hold_topP5Ayumi(ptr noundef) #1

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" }
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, !9, i64 148}
!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 152}
!16 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass