; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/tedsid/ted.ll (ZN3TED14oscillatorInitEv)

; 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.TED = type { i32, i32, i32, i32, i32, i32, i16, i16, i32, [2 x i32], [2 x i32], [2 x i32], [2 x i32], [2 x i32], i32, i32, [256 x i8], [3 x i32], i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352), i32 noundef, i1 noundef zeroext) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3TED15oscillatorResetEv(ptr noundef nonnull align 4 dereferenceable(352)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3TED14oscillatorInitEv(ptr noundef nonnull align 4 dereferenceable(352) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @_ZN3TED15oscillatorResetEv(ptr noundef nonnull align 4 dereferenceable(352) %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 168, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %37, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp ult i32 %7, 256
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %40

10:                                               ; preds = %6
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = and i32 %11, 1
  %13 = trunc i32 %12 to i8
  %14 = getelementptr inbounds %class.TED, ptr %5, i32 0, i32 16
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 %16
  store i8 %13, ptr %17, align 1, !tbaa !11
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = shl i32 %18, 1
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = ashr i32 %20, 7
  %22 = and i32 %21, 1
  %23 = xor i32 1, %22
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = ashr i32 %24, 5
  %26 = and i32 %25, 1
  %27 = xor i32 %23, %26
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = ashr i32 %28, 4
  %30 = and i32 %29, 1
  %31 = xor i32 %27, %30
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = ashr i32 %32, 1
  %34 = and i32 %33, 1
  %35 = xor i32 %31, %34
  %36 = add nsw i32 %19, %35
  store i32 %36, ptr %3, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %10
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = add i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !12

40:                                               ; preds = %9
  %41 = getelementptr inbounds %class.TED, ptr %5, i32 0, i32 14
  store i32 1, ptr %41, align 4, !tbaa !14
  %42 = getelementptr inbounds %class.TED, ptr %5, i32 0, i32 13
  %43 = getelementptr inbounds [2 x i32], ptr %42, i64 0, i64 1
  store i32 1, ptr %43, align 4, !tbaa !9
  %44 = getelementptr inbounds %class.TED, ptr %5, i32 0, i32 13
  %45 = getelementptr inbounds [2 x i32], ptr %44, i64 0, i64 0
  store i32 1, ptr %45, align 4, !tbaa !9
  %46 = getelementptr inbounds %class.TED, ptr %5, i32 0, i32 0
  store i32 8, ptr %46, align 4, !tbaa !17
  call void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352) %5, i32 noundef 0, i1 noundef zeroext true)
  call void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352) %5, i32 noundef 1, i1 noundef zeroext true)
  call void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352) %5, i32 noundef 2, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 72}
!15 = !{!"_ZTS3TED", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !16, i64 24, !16, i64 26, !10, i64 28, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72, !10, i64 76, !7, i64 80, !7, i64 336, !10, i64 348}
!16 = !{!"short", !7, i64 0}
!17 = !{!15, !10, 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 nounwind uwtable
declare dso_local void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352), i32 noundef, i1 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3TED15oscillatorResetEv(ptr noundef nonnull align 4 dereferenceable(352)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3TED14oscillatorInitEv(ptr noundef nonnull align 4 dereferenceable(352) %0) local_unnamed_addr #0 align 2 {
  tail call void @_ZN3TED15oscillatorResetEv(ptr noundef nonnull align 4 dereferenceable(352) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  br label %7

3:                                                ; preds = %7
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 1, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = getelementptr inbounds i8, ptr %0, i64 68
  store i32 1, ptr %6, align 4, !tbaa !11
  store i32 1, ptr %5, align 4, !tbaa !11
  store i32 8, ptr %0, align 4, !tbaa !12
  tail call void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352) %0, i32 noundef 0, i1 noundef zeroext true)
  tail call void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352) %0, i32 noundef 1, i1 noundef zeroext true)
  tail call void @_ZN3TED13enableChannelEjb(ptr noundef nonnull align 4 dereferenceable(352) %0, i32 noundef 2, i1 noundef zeroext true)
  ret void

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

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, !7, i64 72}
!6 = !{!"_ZTS3TED", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 26, !7, i64 28, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !7, i64 72, !7, i64 76, !8, i64 80, !8, i64 336, !7, i64 348}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!8, !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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