; LLVM IR from InductiveComputerScience/infracore :: examples/audio-demo1 (program)

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

; Function Attrs: nounwind uwtable
define dso_local void @Program(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  call void @AudioSamplesMinDelay(ptr noundef %13, ptr noundef %4, ptr noundef %5)
  %14 = load double, ptr %4, align 8, !tbaa !9
  %15 = fmul double %14, 2.000000e+00
  %16 = fptosi double %15 to i32
  store i32 %16, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %17 = load i32, ptr %9, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = mul i64 8, %18
  %20 = call noalias ptr @malloc(i64 noundef %19) #7
  store ptr %20, ptr %10, align 8, !tbaa !5
  store double 0.000000e+00, ptr %3, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %39, %1
  %22 = load double, ptr %3, align 8, !tbaa !9
  %23 = load i32, ptr %9, align 4, !tbaa !11
  %24 = sitofp i32 %23 to double
  %25 = fcmp olt double %22, %24
  br i1 %25, label %26, label %42

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store double 2.616260e+02, ptr %11, align 8, !tbaa !9
  %27 = load double, ptr %3, align 8, !tbaa !9
  %28 = load double, ptr %4, align 8, !tbaa !9
  %29 = fdiv double %27, %28
  %30 = fmul double %29, 0x401921FB54442D18
  %31 = load double, ptr %11, align 8, !tbaa !9
  %32 = fmul double %30, %31
  %33 = call double @sin(double noundef %32) #6
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load double, ptr %3, align 8, !tbaa !9
  %36 = fptosi double %35 to i32
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %34, i64 %37
  store double %33, ptr %38, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %39

39:                                               ; preds = %26
  %40 = load double, ptr %3, align 8, !tbaa !9
  %41 = fadd double %40, 1.000000e+00
  store double %41, ptr %3, align 8, !tbaa !9
  br label %21, !llvm.loop !13

42:                                               ; preds = %21
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %71, %42
  %44 = load i32, ptr %8, align 4, !tbaa !11
  %45 = load i32, ptr %9, align 4, !tbaa !11
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %72

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = call double @CurrentDelay(ptr noundef %48)
  store double %49, ptr %12, align 8, !tbaa !9
  %50 = load double, ptr %12, align 8, !tbaa !9
  %51 = load double, ptr %5, align 8, !tbaa !9
  %52 = fmul double %51, 1.500000e+00
  %53 = fcmp olt double %50, %52
  br i1 %53, label %54, label %71

54:                                               ; preds = %47
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !11
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  %60 = load double, ptr %5, align 8, !tbaa !9
  %61 = load i32, ptr %9, align 4, !tbaa !11
  %62 = load i32, ptr %8, align 4, !tbaa !11
  %63 = sub nsw i32 %61, %62
  %64 = sitofp i32 %63 to double
  %65 = call double @llvm.minnum.f64(double %60, double %64)
  call void @WriteSamples(ptr noundef %55, ptr noundef %59, double noundef %65, ptr noundef %6)
  %66 = load double, ptr %6, align 8, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !11
  %68 = sitofp i32 %67 to double
  %69 = fadd double %68, %66
  %70 = fptosi double %69 to i32
  store i32 %70, ptr %8, align 4, !tbaa !11
  br label %71

71:                                               ; preds = %54, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %43, !llvm.loop !15

72:                                               ; preds = %43
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %73) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void
}

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind
declare double @sin(double noundef) #4

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

declare double @CurrentDelay(ptr noundef) #2

declare void @WriteSamples(ptr noundef, ptr noundef, double noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minnum.f64(double, double) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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 = { "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 allocsize(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 #4 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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: nounwind uwtable
define dso_local void @Program(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  call void @AudioSamplesMinDelay(ptr noundef %0, ptr noundef nonnull %2, ptr noundef nonnull %3) #7
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = fmul double %5, 2.000000e+00
  %7 = fptosi double %6 to i32
  %8 = sext i32 %7 to i64
  %9 = shl nsw i64 %8, 3
  %10 = call noalias ptr @malloc(i64 noundef %9) #8
  %11 = sitofp i32 %7 to double
  %12 = icmp sgt i32 %7, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  br i1 %12, label %.lr.ph23, label %._crit_edge

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.021 = phi double [ %21, %.lr.ph ], [ 0.000000e+00, %1 ]
  %13 = load double, ptr %2, align 8, !tbaa !5
  %14 = fdiv double %.021, %13
  %15 = fmul double %14, 0x401921FB54442D18
  %16 = fmul double %15, 2.616260e+02
  %17 = call double @sin(double noundef %16) #7
  %18 = fptosi double %.021 to i32
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds double, ptr %10, i64 %19
  store double %17, ptr %20, align 8, !tbaa !5
  %21 = fadd double %.021, 1.000000e+00
  %22 = fcmp olt double %21, %11
  br i1 %22, label %.lr.ph, label %.preheader, !llvm.loop !9

.lr.ph23:                                         ; preds = %.preheader, %37
  %.01922 = phi i32 [ %.1, %37 ], [ 0, %.preheader ]
  %23 = call double @CurrentDelay(ptr noundef %0) #7
  %24 = load double, ptr %3, align 8, !tbaa !5
  %25 = fmul double %24, 1.500000e+00
  %26 = fcmp olt double %23, %25
  br i1 %26, label %27, label %37

27:                                               ; preds = %.lr.ph23
  %28 = sext i32 %.01922 to i64
  %29 = getelementptr inbounds double, ptr %10, i64 %28
  %30 = sub nsw i32 %7, %.01922
  %31 = sitofp i32 %30 to double
  %32 = call double @llvm.minnum.f64(double %24, double %31)
  call void @WriteSamples(ptr noundef %0, ptr noundef %29, double noundef %32, ptr noundef nonnull %4) #7
  %33 = load double, ptr %4, align 8, !tbaa !5
  %34 = sitofp i32 %.01922 to double
  %35 = fadd double %33, %34
  %36 = fptosi double %35 to i32
  br label %37

37:                                               ; preds = %27, %.lr.ph23
  %.1 = phi i32 [ %36, %27 ], [ %.01922, %.lr.ph23 ]
  %38 = icmp slt i32 %.1, %7
  br i1 %38, label %.lr.ph23, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %37, %1, %.preheader
  call void @free(ptr noundef %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  ret void
}

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

declare void @AudioSamplesMinDelay(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #4

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

declare double @CurrentDelay(ptr noundef) local_unnamed_addr #2

declare void @WriteSamples(ptr noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minnum.f64(double, double) #5

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6

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 = { "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass