; LLVM IR from TobiasKozel/VAE :: external/portaudio/src/common (pa_process)

; 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.PaUtilBufferProcessor = type { i64, i64, i32, i32, i32, i32, i64, i32, i32, i32, i32, ptr, ptr, i32, i32, i32, i32, ptr, ptr, i64, i64, ptr, ptr, i64, ptr, ptr, i64, ptr, i64, i32, [2 x i64], [2 x ptr], i32, [2 x i64], [2 x ptr], %struct.PaUtilTriangularDitherGenerator, double, ptr, ptr }
%struct.PaUtilTriangularDitherGenerator = type { i32, i32, i32 }
%struct.PaUtilChannelDescriptor = type { ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels = external hidden unnamed_addr constant [104 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @PaUtil_Set2ndInterleavedInputChannels(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %12 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %12, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %13, ptr %11, align 8, !tbaa !5
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %20

16:                                               ; preds = %4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %17, i32 0, i32 7
  %19 = load i32, ptr %18, align 8, !tbaa !11
  store i32 %19, ptr %8, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %16, %4
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %22, i32 0, i32 7
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = icmp ult i32 %21, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %20
  br label %28

27:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 532, ptr noundef @__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels) #4
  unreachable

28:                                               ; preds = %26
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = add i32 %29, %30
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %32, i32 0, i32 7
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = icmp ule i32 %31, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %28
  br label %38

37:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 533, ptr noundef @__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels) #4
  unreachable

38:                                               ; preds = %36
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %39, i32 0, i32 29
  %41 = load i32, ptr %40, align 8, !tbaa !16
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  br label %45

44:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 534, ptr noundef @__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels) #4
  unreachable

45:                                               ; preds = %43
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %79, %45
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = icmp ult i32 %47, %48
  br i1 %49, label %50, label %82

50:                                               ; preds = %46
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %52, i32 0, i32 31
  %54 = getelementptr inbounds [2 x ptr], ptr %53, i64 0, i64 1
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = add i32 %56, %57
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %55, i64 %59
  %61 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %60, i32 0, i32 0
  store ptr %51, ptr %61, align 8, !tbaa !17
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %62, i32 0, i32 8
  %64 = load i32, ptr %63, align 4, !tbaa !19
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = zext i32 %64 to i64
  %67 = getelementptr inbounds i8, ptr %65, i64 %66
  store ptr %67, ptr %11, align 8, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %69, i32 0, i32 31
  %71 = getelementptr inbounds [2 x ptr], ptr %70, i64 0, i64 1
  %72 = load ptr, ptr %71, align 8, !tbaa !5
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = add i32 %73, %74
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %72, i64 %76
  %78 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %77, i32 0, i32 1
  store i32 %68, ptr %78, align 8, !tbaa !20
  br label %79

79:                                               ; preds = %50
  %80 = load i32, ptr %9, align 4, !tbaa !9
  %81 = add i32 %80, 1
  store i32 %81, ptr %9, align 4, !tbaa !9
  br label %46, !llvm.loop !21

82:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"", !13, i64 0, !13, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !13, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !13, i64 104, !13, i64 112, !6, i64 120, !6, i64 128, !13, i64 136, !6, i64 144, !6, i64 152, !13, i64 160, !6, i64 168, !13, i64 176, !10, i64 184, !7, i64 192, !7, i64 208, !10, i64 224, !7, i64 232, !7, i64 248, !14, i64 264, !15, i64 280, !6, i64 288, !6, i64 296}
!13 = !{!"long", !7, i64 0}
!14 = !{!"PaUtilTriangularDitherGenerator", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!"double", !7, i64 0}
!16 = !{!12, !10, i64 184}
!17 = !{!18, !6, i64 0}
!18 = !{!"PaUtilChannelDescriptor", !6, i64 0, !10, i64 8}
!19 = !{!12, !10, i64 44}
!20 = !{!18, !10, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"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.PaUtilChannelDescriptor = type { ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels = external hidden unnamed_addr constant [104 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @PaUtil_Set2ndInterleavedInputChannels(ptr nocapture noundef readonly %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = icmp eq i32 %3, 0
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %. = select i1 %5, i32 %7, i32 %3
  %8 = icmp ugt i32 %7, %1
  br i1 %8, label %10, label %9

9:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 532, ptr noundef nonnull @__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels) #2
  unreachable

10:                                               ; preds = %4
  %11 = add i32 %., %1
  %.not = icmp ugt i32 %11, %7
  br i1 %.not, label %12, label %13

12:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 533, ptr noundef nonnull @__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels) #2
  unreachable

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 184
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %.not27 = icmp eq i32 %15, 0
  br i1 %.not27, label %21, label %.lr.ph

.lr.ph:                                           ; preds = %13
  %16 = getelementptr inbounds i8, ptr %0, i64 216
  %17 = getelementptr inbounds i8, ptr %0, i64 44
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = zext i32 %18 to i64
  %wide.trip.count = zext i32 %. to i64
  %.pre33 = load ptr, ptr %16, align 8, !tbaa !16
  %xtraiter = and i64 %wide.trip.count, 1
  %20 = icmp eq i32 %., 1
  br i1 %20, label %._crit_edge.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967294
  br label %22

21:                                               ; preds = %13
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 534, ptr noundef nonnull @__PRETTY_FUNCTION__.PaUtil_Set2ndInterleavedInputChannels) #2
  unreachable

22:                                               ; preds = %22, %.lr.ph.new
  %23 = phi ptr [ %.pre33, %.lr.ph.new ], [ %37, %22 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %22 ]
  %.029 = phi ptr [ %2, %.lr.ph.new ], [ %36, %22 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %22 ]
  %24 = trunc nuw i64 %indvars.iv to i32
  %25 = add i32 %24, %1
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %23, i64 %26
  store ptr %.029, ptr %27, align 8, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %.029, i64 %19
  %29 = load ptr, ptr %16, align 8, !tbaa !16
  %30 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %29, i64 %26, i32 1
  store i32 %., ptr %30, align 8, !tbaa !19
  %31 = trunc i64 %indvars.iv to i32
  %32 = or disjoint i32 %31, 1
  %33 = add i32 %32, %1
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %29, i64 %34
  store ptr %28, ptr %35, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %28, i64 %19
  %37 = load ptr, ptr %16, align 8, !tbaa !16
  %38 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %37, i64 %34, i32 1
  store i32 %., ptr %38, align 8, !tbaa !19
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.unr-lcssa.loopexit, label %22, !llvm.loop !20

._crit_edge.unr-lcssa.loopexit:                   ; preds = %22
  %39 = trunc nuw i64 %indvars.iv.next.1 to i32
  br label %._crit_edge.unr-lcssa

._crit_edge.unr-lcssa:                            ; preds = %._crit_edge.unr-lcssa.loopexit, %.lr.ph
  %.unr = phi ptr [ %.pre33, %.lr.ph ], [ %37, %._crit_edge.unr-lcssa.loopexit ]
  %indvars.iv.unr = phi i32 [ 0, %.lr.ph ], [ %39, %._crit_edge.unr-lcssa.loopexit ]
  %.029.unr = phi ptr [ %2, %.lr.ph ], [ %36, %._crit_edge.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.epilog-lcssa

._crit_edge.epilog-lcssa:                         ; preds = %._crit_edge.unr-lcssa
  %40 = add i32 %indvars.iv.unr, %1
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %.unr, i64 %41
  store ptr %.029.unr, ptr %42, align 8, !tbaa !17
  %43 = load ptr, ptr %16, align 8, !tbaa !16
  %44 = getelementptr inbounds %struct.PaUtilChannelDescriptor, ptr %43, i64 %41, i32 1
  store i32 %., ptr %44, align 8, !tbaa !19
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.unr-lcssa, %._crit_edge.epilog-lcssa
  ret void
}

attributes #0 = { noreturn 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 #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 = { 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, !10, i64 40}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !11, i64 56, !11, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !11, i64 88, !11, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !11, i64 128, !7, i64 136, !11, i64 144, !11, i64 152, !7, i64 160, !11, i64 168, !7, i64 176, !10, i64 184, !8, i64 192, !8, i64 208, !10, i64 224, !8, i64 232, !8, i64 248, !12, i64 264, !13, i64 280, !11, i64 288, !11, i64 296}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"PaUtilTriangularDitherGenerator", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!"double", !8, i64 0}
!14 = !{!6, !10, i64 184}
!15 = !{!6, !10, i64 44}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !11, i64 0}
!18 = !{!"PaUtilChannelDescriptor", !11, i64 0, !10, i64 8}
!19 = !{!18, !10, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass