; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/tests (test-libsignaletic)

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

%struct.sig_Allocator = type { ptr, ptr }
%struct.sig_dsp_Oscillator = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Oscillator_Inputs, %struct.sig_dsp_Oscillator_Outputs, float }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Oscillator_Inputs = type { ptr, ptr, ptr, ptr }
%struct.sig_dsp_Oscillator_Outputs = type { ptr, ptr }

@allocator = external dso_local global %struct.sig_Allocator, align 8
@context = external dso_local global ptr, align 8
@.str.27 = external hidden unnamed_addr constant [109 x i8], align 1

; 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: nounwind uwtable
declare dso_local void @createOscInputs(ptr noundef, ptr noundef, float noundef, float noundef, float noundef, float noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @destroyOscInputs(ptr noundef, ptr noundef) #1

declare ptr @sig_dsp_Sine_new(ptr noundef, ptr noundef) #2

declare void @sig_dsp_Sine_destroy(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @test_sig_dsp_Sine_phaseWrapsAt2PI() #1 {
  %1 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %2 = load ptr, ptr @context, align 8, !tbaa !5
  %3 = call ptr @sig_dsp_Sine_new(ptr noundef @allocator, ptr noundef %2)
  store ptr %3, ptr %1, align 8, !tbaa !5
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  call void @createOscInputs(ptr noundef @allocator, ptr noundef %4, float noundef 4.400000e+02, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %5, i32 0, i32 0
  %7 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  call void %8(ptr noundef %9)
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  call void %13(ptr noundef %14)
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = load ptr, ptr %1, align 8, !tbaa !5
  call void %18(ptr noundef %19)
  br label %20

20:                                               ; preds = %0
  %21 = load ptr, ptr %1, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %21, i32 0, i32 3
  %23 = load float, ptr %22, align 8, !tbaa !15
  %24 = fpext float %23 to double
  %25 = fcmp ole double %24, 1.000000e+00
  br i1 %25, label %26, label %33

26:                                               ; preds = %20
  %27 = load ptr, ptr %1, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %27, i32 0, i32 3
  %29 = load float, ptr %28, align 8, !tbaa !15
  %30 = fpext float %29 to double
  %31 = fcmp oge double %30, 0.000000e+00
  br i1 %31, label %32, label %33

32:                                               ; preds = %26
  br label %34

33:                                               ; preds = %26, %20
  call void @UnityFail(ptr noundef @.str.27, i64 noundef 695) #5
  unreachable

34:                                               ; preds = %32
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %1, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %37, i32 0, i32 1
  call void @destroyOscInputs(ptr noundef @allocator, ptr noundef %38)
  %39 = load ptr, ptr %1, align 8, !tbaa !5
  call void @sig_dsp_Sine_destroy(ptr noundef @allocator, ptr noundef %39)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

; Function Attrs: noreturn
declare void @UnityFail(ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { noreturn "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 }
attributes #5 = { noreturn }

!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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"sig_dsp_Oscillator", !11, i64 0, !12, i64 16, !13, i64 48, !14, i64 64}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_Oscillator_Inputs", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"sig_dsp_Oscillator_Outputs", !6, i64 0, !6, i64 8}
!14 = !{!"float", !7, i64 0}
!15 = !{!10, !14, i64 64}


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

%struct.sig_Allocator = type { ptr, ptr }

@allocator = external dso_local global %struct.sig_Allocator, align 8
@context = external dso_local local_unnamed_addr global ptr, align 8
@.str.27 = external hidden unnamed_addr constant [109 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @createOscInputs(ptr noundef, ptr noundef, float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @destroyOscInputs(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @sig_dsp_Sine_new(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @sig_dsp_Sine_destroy(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_sig_dsp_Sine_phaseWrapsAt2PI() local_unnamed_addr #0 {
  %1 = load ptr, ptr @context, align 8, !tbaa !5
  %2 = tail call ptr @sig_dsp_Sine_new(ptr noundef nonnull @allocator, ptr noundef %1) #3
  tail call void @createOscInputs(ptr noundef nonnull @allocator, ptr noundef %2, float noundef 4.400000e+02, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %3 = getelementptr inbounds i8, ptr %2, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !9
  tail call void %4(ptr noundef %2) #3
  %5 = load ptr, ptr %3, align 8, !tbaa !9
  tail call void %5(ptr noundef %2) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !9
  tail call void %6(ptr noundef %2) #3
  %7 = getelementptr inbounds i8, ptr %2, i64 64
  %8 = load float, ptr %7, align 8, !tbaa !15
  %9 = fcmp ugt float %8, 1.000000e+00
  %10 = fcmp ult float %8, 0.000000e+00
  %or.cond = or i1 %9, %10
  br i1 %or.cond, label %11, label %12

11:                                               ; preds = %0
  tail call void @UnityFail(ptr noundef nonnull @.str.27, i64 noundef 695) #4
  unreachable

12:                                               ; preds = %0
  %13 = getelementptr inbounds i8, ptr %2, i64 16
  tail call void @destroyOscInputs(ptr noundef nonnull @allocator, ptr noundef nonnull %13)
  tail call void @sig_dsp_Sine_destroy(ptr noundef nonnull @allocator, ptr noundef nonnull %2) #3
  ret void
}

; Function Attrs: noreturn
declare void @UnityFail(ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 = { "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 = { noreturn "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 = { nounwind }
attributes #4 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"sig_dsp_Oscillator", !11, i64 0, !12, i64 16, !13, i64 48, !14, i64 64}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_Oscillator_Inputs", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"sig_dsp_Oscillator_Outputs", !6, i64 0, !6, i64 8}
!14 = !{!"float", !7, i64 0}
!15 = !{!10, !14, i64 64}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass