; LLVM IR from VoidRune/Audio-engine :: src (minivorbis)

; 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: 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
define dso_local i32 @res1_forward(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6, i32 noundef %7) #1 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store i32 %5, ptr %15, align 4, !tbaa !9
  store ptr %6, ptr %16, align 8, !tbaa !5
  store i32 %7, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  store i32 0, ptr %19, align 4, !tbaa !9
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %45, %8
  %23 = load i32, ptr %18, align 4, !tbaa !9
  %24 = load i32, ptr %15, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %48

26:                                               ; preds = %22
  %27 = load ptr, ptr %14, align 8, !tbaa !5
  %28 = load i32, ptr %18, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %27, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %44

33:                                               ; preds = %26
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = load i32, ptr %18, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = load i32, ptr %19, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %19, align 4, !tbaa !9
  %42 = sext i32 %40 to i64
  %43 = getelementptr inbounds ptr, ptr %39, i64 %42
  store ptr %38, ptr %43, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %33, %26
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %18, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %18, align 4, !tbaa !9
  br label %22, !llvm.loop !11

48:                                               ; preds = %22
  %49 = load i32, ptr %19, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %59

51:                                               ; preds = %48
  %52 = load i32, ptr %17, align 4, !tbaa !9
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load i32, ptr %19, align 4, !tbaa !9
  %57 = load ptr, ptr %16, align 8, !tbaa !5
  %58 = call i32 @_01forward(ptr noundef %53, ptr noundef %54, ptr noundef %55, i32 noundef %56, ptr noundef %57, ptr noundef @_encodepart)
  store i32 %58, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %60

59:                                               ; preds = %48
  store i32 0, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %60

60:                                               ; preds = %59, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  %61 = load i32, ptr %9, align 4
  ret i32 %61
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_01forward(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @_encodepart(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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 = { 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 = distinct !{!11, !12}
!12 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local i32 @res1_forward(ptr noundef %0, ptr nocapture noundef readnone %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef readonly %4, i32 noundef %5, ptr noundef %6, i32 noundef %7) local_unnamed_addr #0 {
  %9 = icmp sgt i32 %5, 0
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %8
  %wide.trip.count = zext nneg i32 %5 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %10 = icmp eq i32 %5, 1
  br i1 %10, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

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

.lr.ph:                                           ; preds = %27, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %27 ]
  %.021 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %.1.1, %27 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %27 ]
  %11 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %.not19 = icmp eq i32 %12, 0
  br i1 %.not19, label %.lr.ph.1, label %13

13:                                               ; preds = %.lr.ph
  %14 = getelementptr inbounds ptr, ptr %3, i64 %indvars.iv
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = add nsw i32 %.021, 1
  %17 = sext i32 %.021 to i64
  %18 = getelementptr inbounds ptr, ptr %3, i64 %17
  store ptr %15, ptr %18, align 8, !tbaa !9
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.lr.ph, %13
  %.1 = phi i32 [ %16, %13 ], [ %.021, %.lr.ph ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %19 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv.next
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not19.1 = icmp eq i32 %20, 0
  br i1 %.not19.1, label %27, label %21

21:                                               ; preds = %.lr.ph.1
  %22 = getelementptr inbounds ptr, ptr %3, i64 %indvars.iv.next
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = add nsw i32 %.1, 1
  %25 = sext i32 %.1 to i64
  %26 = getelementptr inbounds ptr, ptr %3, i64 %25
  store ptr %23, ptr %26, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %21, %.lr.ph.1
  %.1.1 = phi i32 [ %24, %21 ], [ %.1, %.lr.ph.1 ]
  %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, label %.lr.ph, !llvm.loop !11

._crit_edge.unr-lcssa:                            ; preds = %27, %.lr.ph.preheader
  %.1.lcssa.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %.1.1, %27 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %27 ]
  %.021.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %.1.1, %27 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa
  %28 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv.unr
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %.not19.epil = icmp eq i32 %29, 0
  br i1 %.not19.epil, label %._crit_edge, label %30

30:                                               ; preds = %.lr.ph.epil
  %31 = getelementptr inbounds ptr, ptr %3, i64 %indvars.iv.unr
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = add nsw i32 %.021.unr, 1
  %34 = sext i32 %.021.unr to i64
  %35 = getelementptr inbounds ptr, ptr %3, i64 %34
  store ptr %32, ptr %35, align 8, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %30, %._crit_edge.unr-lcssa
  %.1.lcssa = phi i32 [ %.1.lcssa.ph, %._crit_edge.unr-lcssa ], [ %33, %30 ], [ %.021.unr, %.lr.ph.epil ]
  %.not = icmp eq i32 %.1.lcssa, 0
  br i1 %.not, label %._crit_edge.thread, label %36

36:                                               ; preds = %._crit_edge
  %37 = tail call i32 @_01forward(ptr noundef %0, ptr noundef %2, ptr noundef %3, i32 noundef %.1.lcssa, ptr noundef %6, ptr noundef nonnull @_encodepart)
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %8, %._crit_edge, %36
  %.018 = phi i32 [ %37, %36 ], [ 0, %._crit_edge ], [ 0, %8 ]
  ret i32 %.018
}

; Function Attrs: nounwind uwtable
declare hidden i32 @_01forward(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @_encodepart(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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