; LLVM IR from sp-nitech/SPTK :: src/generation (periodic_waveform_generation)

; 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.sptk::PeriodicWaveformGeneration" = type <{ ptr, double, i8, [7 x i8], ptr, i8, [7 x i8], double, double, i8, [7 x i8] }>

@_ZTVN4sptk26PeriodicWaveformGenerationE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk26PeriodicWaveformGenerationC2EdbPNS_39InputSourceInterpolationWithMagicNumberE(ptr noundef nonnull align 8 dereferenceable(57) %0, double noundef %1, i1 noundef zeroext %2, ptr noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  %9 = zext i1 %2 to i8
  store i8 %9, ptr %7, align 1, !tbaa !11
  store ptr %3, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk26PeriodicWaveformGenerationE, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 1
  %12 = load double, ptr %6, align 8, !tbaa !9
  store double %12, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 2
  %14 = load i8, ptr %7, align 1, !tbaa !11, !range !17, !noundef !18
  %15 = trunc i8 %14 to i1
  %16 = zext i1 %15 to i8
  store i8 %16, ptr %13, align 8, !tbaa !19
  %17 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 4
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %18, ptr %17, align 8, !tbaa !20
  %19 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 5
  store i8 1, ptr %19, align 8, !tbaa !21
  %20 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 7
  store double 0.000000e+00, ptr %20, align 8, !tbaa !22
  %21 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 8
  store double 0.000000e+00, ptr %21, align 8, !tbaa !23
  %22 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 9
  store i8 0, ptr %22, align 8, !tbaa !24
  %23 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 4
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %25 = icmp eq ptr null, %24
  br i1 %25, label %33, label %26

26:                                               ; preds = %4
  %27 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds ptr, ptr %29, i64 3
  %31 = load ptr, ptr %30, align 8
  %32 = call noundef zeroext i1 %31(ptr noundef nonnull align 8 dereferenceable(136) %28)
  br i1 %32, label %35, label %33

33:                                               ; preds = %26, %4
  %34 = getelementptr inbounds %"class.sptk::PeriodicWaveformGeneration", ptr %10, i32 0, i32 5
  store i8 0, ptr %34, align 8, !tbaa !21
  br label %35

35:                                               ; preds = %33, %26
  ret void
}

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

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !10, i64 8}
!16 = !{!"_ZTSN4sptk26PeriodicWaveformGenerationE", !10, i64 8, !12, i64 16, !6, i64 24, !12, i64 32, !10, i64 40, !10, i64 48, !12, i64 56}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!16, !12, i64 16}
!20 = !{!16, !6, i64 24}
!21 = !{!16, !12, i64 32}
!22 = !{!16, !10, i64 40}
!23 = !{!16, !10, i64 48}
!24 = !{!16, !12, i64 56}


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

@_ZTVN4sptk26PeriodicWaveformGenerationE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk26PeriodicWaveformGenerationC2EdbPNS_39InputSourceInterpolationWithMagicNumberE(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(57) %0, double noundef %1, i1 noundef zeroext %2, ptr noundef %3) unnamed_addr #0 align 2 {
  %5 = zext i1 %2 to i8
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk26PeriodicWaveformGenerationE, i64 16), ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store double %1, ptr %6, align 8, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 %5, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %3, ptr %8, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  store i8 1, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = icmp eq ptr %3, null
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %10, i8 0, i64 17, i1 false)
  br i1 %11, label %17, label %12

12:                                               ; preds = %4
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 24
  %15 = load ptr, ptr %14, align 8
  %16 = tail call noundef zeroext i1 %15(ptr noundef nonnull align 8 dereferenceable(136) %3)
  br i1 %16, label %18, label %17

17:                                               ; preds = %12, %4
  store i8 0, ptr %9, align 8, !tbaa !16
  br label %18

18:                                               ; preds = %17, %12
  ret void
}

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !10, i64 8}
!9 = !{!"_ZTSN4sptk26PeriodicWaveformGenerationE", !10, i64 8, !12, i64 16, !13, i64 24, !12, i64 32, !10, i64 40, !10, i64 48, !12, i64 56}
!10 = !{!"double", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"bool", !11, i64 0}
!13 = !{!"any pointer", !11, i64 0}
!14 = !{!9, !12, i64 16}
!15 = !{!9, !13, i64 24}
!16 = !{!9, !12, i64 32}


; Effective O3 passes: EarlyCSEPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass