; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/examples/console/src (print-sine)

; 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_AudioSettings = type { float, i64, i64 }
%struct.sig_AllocatorImpl = type { ptr, ptr, ptr }
%struct.sig_dsp_ConstantValue = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Signal_SingleMonoOutput }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Signal_SingleMonoOutput = type { ptr }
%struct.sig_dsp_Oscillator = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Oscillator_Inputs, %struct.sig_dsp_Oscillator_Outputs, float }
%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
@__const.main.audioSettings = external hidden unnamed_addr constant %struct.sig_AudioSettings, align 8
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

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

; 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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.sig_AudioSettings, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 @__const.main.audioSettings, i64 24, i1 false)
  %12 = load ptr, ptr @allocator, align 8, !tbaa !11
  %13 = getelementptr inbounds %struct.sig_AllocatorImpl, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  call void %14(ptr noundef @allocator)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %15 = call ptr @sig_SignalContext_new(ptr noundef @allocator, ptr noundef %6)
  store ptr %15, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %16 = load ptr, ptr %7, align 8, !tbaa !9
  %17 = call ptr @sig_dsp_Sine_new(ptr noundef @allocator, ptr noundef %16)
  store ptr %17, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %18 = load ptr, ptr %7, align 8, !tbaa !9
  %19 = call ptr @sig_dsp_ConstantValue_new(ptr noundef @allocator, ptr noundef %18, float noundef 4.400000e+02)
  store ptr %19, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %20 = load ptr, ptr %7, align 8, !tbaa !9
  %21 = call ptr @sig_dsp_ConstantValue_new(ptr noundef @allocator, ptr noundef %20, float noundef 1.000000e+00)
  store ptr %21, ptr %10, align 8, !tbaa !9
  %22 = load ptr, ptr %9, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.sig_dsp_ConstantValue, ptr %22, i32 0, i32 1
  %24 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.sig_dsp_Oscillator_Inputs, ptr %27, i32 0, i32 0
  store ptr %25, ptr %28, align 8, !tbaa !19
  %29 = load ptr, ptr %10, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.sig_dsp_ConstantValue, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = load ptr, ptr %8, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %struct.sig_dsp_Oscillator_Inputs, ptr %34, i32 0, i32 2
  store ptr %32, ptr %35, align 8, !tbaa !24
  %36 = call i32 @puts(ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %53, %2
  %38 = load i32, ptr %11, align 4, !tbaa !5
  %39 = icmp slt i32 %38, 3
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %56

41:                                               ; preds = %37
  %42 = load ptr, ptr %8, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !25
  %46 = load ptr, ptr %8, align 8, !tbaa !9
  call void %45(ptr noundef %46)
  %47 = load ptr, ptr %8, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %47, i32 0, i32 2
  %49 = getelementptr inbounds %struct.sig_dsp_Oscillator_Outputs, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !26
  %51 = getelementptr inbounds %struct.sig_AudioSettings, ptr %6, i32 0, i32 2
  %52 = load i64, ptr %51, align 8, !tbaa !27
  call void @printBuffer(ptr noundef %50, i64 noundef %52)
  br label %53

53:                                               ; preds = %41
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %11, align 4, !tbaa !5
  br label %37, !llvm.loop !30

56:                                               ; preds = %40
  %57 = load ptr, ptr %9, align 8, !tbaa !9
  call void @sig_dsp_ConstantValue_destroy(ptr noundef @allocator, ptr noundef %57)
  %58 = load ptr, ptr %10, align 8, !tbaa !9
  call void @sig_dsp_ConstantValue_destroy(ptr noundef @allocator, ptr noundef %58)
  %59 = load ptr, ptr %8, align 8, !tbaa !9
  call void @sig_dsp_Sine_destroy(ptr noundef @allocator, ptr noundef %59)
  %60 = load ptr, ptr %7, align 8, !tbaa !9
  call void @sig_SignalContext_destroy(ptr noundef @allocator, ptr noundef %60)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @sig_SignalContext_new(ptr noundef, ptr noundef) #3

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

declare ptr @sig_dsp_ConstantValue_new(ptr noundef, ptr noundef, float noundef) #3

declare i32 @puts(ptr noundef) #3

declare void @sig_dsp_ConstantValue_destroy(ptr noundef, ptr noundef) #3

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

declare void @sig_SignalContext_destroy(ptr noundef, ptr noundef) #3

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"sig_Allocator", !10, i64 0, !10, i64 8}
!13 = !{!14, !10, i64 0}
!14 = !{!"sig_AllocatorImpl", !10, i64 0, !10, i64 8, !10, i64 16}
!15 = !{!16, !10, i64 16}
!16 = !{!"sig_dsp_ConstantValue", !17, i64 0, !18, i64 16}
!17 = !{!"sig_dsp_Signal", !10, i64 0, !10, i64 8}
!18 = !{!"sig_dsp_Signal_SingleMonoOutput", !10, i64 0}
!19 = !{!20, !10, i64 16}
!20 = !{!"sig_dsp_Oscillator", !17, i64 0, !21, i64 16, !22, i64 48, !23, i64 64}
!21 = !{!"sig_dsp_Oscillator_Inputs", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!22 = !{!"sig_dsp_Oscillator_Outputs", !10, i64 0, !10, i64 8}
!23 = !{!"float", !7, i64 0}
!24 = !{!20, !10, i64 32}
!25 = !{!20, !10, i64 8}
!26 = !{!20, !10, i64 48}
!27 = !{!28, !29, i64 16}
!28 = !{!"sig_AudioSettings", !23, i64 0, !29, i64 8, !29, i64 16}
!29 = !{!"long", !7, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; 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 }
%struct.sig_AudioSettings = type { float, i64, i64 }

@allocator = external dso_local global %struct.sig_Allocator, align 8
@__const.main.audioSettings = external hidden unnamed_addr constant %struct.sig_AudioSettings, align 8
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.sig_AudioSettings, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) @__const.main.audioSettings, i64 24, i1 false)
  %4 = load ptr, ptr @allocator, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !10
  tail call void %5(ptr noundef nonnull @allocator) #5
  %6 = call ptr @sig_SignalContext_new(ptr noundef nonnull @allocator, ptr noundef nonnull %3) #5
  %7 = call ptr @sig_dsp_Sine_new(ptr noundef nonnull @allocator, ptr noundef %6) #5
  %8 = call ptr @sig_dsp_ConstantValue_new(ptr noundef nonnull @allocator, ptr noundef %6, float noundef 4.400000e+02) #5
  %9 = call ptr @sig_dsp_ConstantValue_new(ptr noundef nonnull @allocator, ptr noundef %6, float noundef 1.000000e+00) #5
  %10 = getelementptr inbounds i8, ptr %8, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %7, i64 16
  store ptr %11, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %9, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %7, i64 32
  store ptr %14, ptr %15, align 8, !tbaa !21
  %16 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %17 = getelementptr inbounds i8, ptr %7, i64 8
  %18 = getelementptr inbounds i8, ptr %7, i64 48
  %19 = getelementptr inbounds i8, ptr %3, i64 16
  %20 = load ptr, ptr %17, align 8, !tbaa !22
  call void %20(ptr noundef nonnull %7) #5
  %21 = load ptr, ptr %18, align 8, !tbaa !23
  %22 = load i64, ptr %19, align 8, !tbaa !24
  call void @printBuffer(ptr noundef %21, i64 noundef %22)
  %23 = load ptr, ptr %17, align 8, !tbaa !22
  call void %23(ptr noundef nonnull %7) #5
  %24 = load ptr, ptr %18, align 8, !tbaa !23
  %25 = load i64, ptr %19, align 8, !tbaa !24
  call void @printBuffer(ptr noundef %24, i64 noundef %25)
  %26 = load ptr, ptr %17, align 8, !tbaa !22
  call void %26(ptr noundef nonnull %7) #5
  %27 = load ptr, ptr %18, align 8, !tbaa !23
  %28 = load i64, ptr %19, align 8, !tbaa !24
  call void @printBuffer(ptr noundef %27, i64 noundef %28)
  call void @sig_dsp_ConstantValue_destroy(ptr noundef nonnull @allocator, ptr noundef %8) #5
  call void @sig_dsp_ConstantValue_destroy(ptr noundef nonnull @allocator, ptr noundef %9) #5
  call void @sig_dsp_Sine_destroy(ptr noundef nonnull @allocator, ptr noundef nonnull %7) #5
  call void @sig_SignalContext_destroy(ptr noundef nonnull @allocator, ptr noundef %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @sig_SignalContext_new(ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare ptr @sig_dsp_ConstantValue_new(ptr noundef, ptr noundef, float noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4

declare void @sig_dsp_ConstantValue_destroy(ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare void @sig_SignalContext_destroy(ptr noundef, ptr noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { nofree nounwind "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 #5 = { 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, !7, i64 0}
!6 = !{!"sig_Allocator", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"sig_AllocatorImpl", !7, i64 0, !7, i64 8, !7, i64 16}
!12 = !{!13, !7, i64 16}
!13 = !{!"sig_dsp_ConstantValue", !14, i64 0, !15, i64 16}
!14 = !{!"sig_dsp_Signal", !7, i64 0, !7, i64 8}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !7, i64 0}
!16 = !{!17, !7, i64 16}
!17 = !{!"sig_dsp_Oscillator", !14, i64 0, !18, i64 16, !19, i64 48, !20, i64 64}
!18 = !{!"sig_dsp_Oscillator_Inputs", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!19 = !{!"sig_dsp_Oscillator_Outputs", !7, i64 0, !7, i64 8}
!20 = !{!"float", !8, i64 0}
!21 = !{!17, !7, i64 32}
!22 = !{!17, !7, i64 8}
!23 = !{!17, !7, i64 48}
!24 = !{!25, !26, i64 16}
!25 = !{!"sig_AudioSettings", !20, i64 0, !26, i64 8, !26, i64 16}
!26 = !{!"long", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass