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

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @PaUtil_ResetBufferProcessor(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %5, i32 0, i32 19
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %8, i32 0, i32 23
  store i64 %7, ptr %9, align 8, !tbaa !15
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %10, i32 0, i32 20
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %13, i32 0, i32 26
  store i64 %12, ptr %14, align 8, !tbaa !17
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %15, i32 0, i32 23
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = icmp ugt i64 %17, 0
  br i1 %18, label %19, label %37

19:                                               ; preds = %1
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %20, i32 0, i32 6
  %22 = load i64, ptr %21, align 8, !tbaa !18
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %23, i32 0, i32 9
  %25 = load i32, ptr %24, align 8, !tbaa !19
  %26 = zext i32 %25 to i64
  %27 = mul i64 %22, %26
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %28, i32 0, i32 7
  %30 = load i32, ptr %29, align 8, !tbaa !20
  %31 = zext i32 %30 to i64
  %32 = mul i64 %27, %31
  store i64 %32, ptr %3, align 8, !tbaa !21
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %33, i32 0, i32 21
  %35 = load ptr, ptr %34, align 8, !tbaa !22
  %36 = load i64, ptr %3, align 8, !tbaa !21
  call void @llvm.memset.p0.i64(ptr align 1 %35, i8 0, i64 %36, i1 false)
  br label %37

37:                                               ; preds = %19, %1
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %38, i32 0, i32 26
  %40 = load i64, ptr %39, align 8, !tbaa !17
  %41 = icmp ugt i64 %40, 0
  br i1 %41, label %42, label %60

42:                                               ; preds = %37
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %43, i32 0, i32 6
  %45 = load i64, ptr %44, align 8, !tbaa !18
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %46, i32 0, i32 15
  %48 = load i32, ptr %47, align 8, !tbaa !23
  %49 = zext i32 %48 to i64
  %50 = mul i64 %45, %49
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %51, i32 0, i32 13
  %53 = load i32, ptr %52, align 8, !tbaa !24
  %54 = zext i32 %53 to i64
  %55 = mul i64 %50, %54
  store i64 %55, ptr %4, align 8, !tbaa !21
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.PaUtilBufferProcessor, ptr %56, i32 0, i32 24
  %58 = load ptr, ptr %57, align 8, !tbaa !25
  %59 = load i64, ptr %4, align 8, !tbaa !21
  call void @llvm.memset.p0.i64(ptr align 1 %58, i8 0, i64 %59, i1 false)
  br label %60

60:                                               ; preds = %42, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

!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, !11, i64 104}
!10 = !{!"", !11, i64 0, !11, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !11, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !6, i64 88, !6, i64 96, !11, i64 104, !11, i64 112, !6, i64 120, !6, i64 128, !11, i64 136, !6, i64 144, !6, i64 152, !11, i64 160, !6, i64 168, !11, i64 176, !12, i64 184, !7, i64 192, !7, i64 208, !12, i64 224, !7, i64 232, !7, i64 248, !13, i64 264, !14, i64 280, !6, i64 288, !6, i64 296}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"PaUtilTriangularDitherGenerator", !12, i64 0, !12, i64 4, !12, i64 8}
!14 = !{!"double", !7, i64 0}
!15 = !{!10, !11, i64 136}
!16 = !{!10, !11, i64 112}
!17 = !{!10, !11, i64 160}
!18 = !{!10, !11, i64 32}
!19 = !{!10, !12, i64 48}
!20 = !{!10, !12, i64 40}
!21 = !{!11, !11, i64 0}
!22 = !{!10, !6, i64 120}
!23 = !{!10, !12, i64 80}
!24 = !{!10, !12, i64 72}
!25 = !{!10, !6, i64 144}


; 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @PaUtil_ResetBufferProcessor(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 104
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 136
  store i64 %3, ptr %4, align 8, !tbaa !14
  %5 = getelementptr inbounds i8, ptr %0, i64 112
  %6 = load i64, ptr %5, align 8, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %0, i64 160
  store i64 %6, ptr %7, align 8, !tbaa !16
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %21, label %8

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load i64, ptr %9, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load i32, ptr %11, align 8, !tbaa !18
  %13 = zext i32 %12 to i64
  %14 = mul i64 %10, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = load i32, ptr %15, align 8, !tbaa !19
  %17 = zext i32 %16 to i64
  %18 = mul i64 %14, %17
  %19 = getelementptr inbounds i8, ptr %0, i64 120
  %20 = load ptr, ptr %19, align 8, !tbaa !20
  tail call void @llvm.memset.p0.i64(ptr align 1 %20, i8 0, i64 %18, i1 false)
  %.pr = load i64, ptr %7, align 8, !tbaa !16
  br label %21

21:                                               ; preds = %8, %1
  %22 = phi i64 [ %.pr, %8 ], [ %6, %1 ]
  %.not15 = icmp eq i64 %22, 0
  br i1 %.not15, label %36, label %23

23:                                               ; preds = %21
  %24 = getelementptr inbounds i8, ptr %0, i64 32
  %25 = load i64, ptr %24, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %0, i64 80
  %27 = load i32, ptr %26, align 8, !tbaa !21
  %28 = zext i32 %27 to i64
  %29 = mul i64 %25, %28
  %30 = getelementptr inbounds i8, ptr %0, i64 72
  %31 = load i32, ptr %30, align 8, !tbaa !22
  %32 = zext i32 %31 to i64
  %33 = mul i64 %29, %32
  %34 = getelementptr inbounds i8, ptr %0, i64 144
  %35 = load ptr, ptr %34, align 8, !tbaa !23
  tail call void @llvm.memset.p0.i64(ptr align 1 %35, i8 0, i64 %33, i1 false)
  br label %36

36:                                               ; preds = %23, %21
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) 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, !7, i64 104}
!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, !7, i64 136}
!15 = !{!6, !7, i64 112}
!16 = !{!6, !7, i64 160}
!17 = !{!6, !7, i64 32}
!18 = !{!6, !10, i64 48}
!19 = !{!6, !10, i64 40}
!20 = !{!6, !11, i64 120}
!21 = !{!6, !10, i64 80}
!22 = !{!6, !10, i64 72}
!23 = !{!6, !11, i64 144}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass