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

; 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.vorbis_look_psy = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i32, i32, i64, float }

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

; Function Attrs: nounwind uwtable
define dso_local void @_vp_psy_clear(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %103

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.vorbis_look_psy, ptr %8, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %16

12:                                               ; preds = %7
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.vorbis_look_psy, ptr %13, i32 0, i32 4
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  call void @free(ptr noundef %15) #4
  br label %16

16:                                               ; preds = %12, %7
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.vorbis_look_psy, ptr %17, i32 0, i32 5
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %25

21:                                               ; preds = %16
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.vorbis_look_psy, ptr %22, i32 0, i32 5
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  call void @free(ptr noundef %24) #4
  br label %25

25:                                               ; preds = %21, %16
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.vorbis_look_psy, ptr %26, i32 0, i32 6
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %34

30:                                               ; preds = %25
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.vorbis_look_psy, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  call void @free(ptr noundef %33) #4
  br label %34

34:                                               ; preds = %30, %25
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.vorbis_look_psy, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %77

39:                                               ; preds = %34
  store i32 0, ptr %3, align 4, !tbaa !17
  br label %40

40:                                               ; preds = %70, %39
  %41 = load i32, ptr %3, align 4, !tbaa !17
  %42 = icmp slt i32 %41, 17
  br i1 %42, label %43, label %73

43:                                               ; preds = %40
  store i32 0, ptr %4, align 4, !tbaa !17
  br label %44

44:                                               ; preds = %59, %43
  %45 = load i32, ptr %4, align 4, !tbaa !17
  %46 = icmp slt i32 %45, 8
  br i1 %46, label %47, label %62

47:                                               ; preds = %44
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.vorbis_look_psy, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = load i32, ptr %3, align 4, !tbaa !17
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %50, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !17
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds ptr, ptr %54, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  call void @free(ptr noundef %58) #4
  br label %59

59:                                               ; preds = %47
  %60 = load i32, ptr %4, align 4, !tbaa !17
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !17
  br label %44, !llvm.loop !18

62:                                               ; preds = %44
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.vorbis_look_psy, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  %66 = load i32, ptr %3, align 4, !tbaa !17
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  call void @free(ptr noundef %69) #4
  br label %70

70:                                               ; preds = %62
  %71 = load i32, ptr %3, align 4, !tbaa !17
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %3, align 4, !tbaa !17
  br label %40, !llvm.loop !20

73:                                               ; preds = %40
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.vorbis_look_psy, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !16
  call void @free(ptr noundef %76) #4
  br label %77

77:                                               ; preds = %73, %34
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.vorbis_look_psy, ptr %78, i32 0, i32 3
  %80 = load ptr, ptr %79, align 8, !tbaa !21
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %101

82:                                               ; preds = %77
  store i32 0, ptr %3, align 4, !tbaa !17
  br label %83

83:                                               ; preds = %94, %82
  %84 = load i32, ptr %3, align 4, !tbaa !17
  %85 = icmp slt i32 %84, 3
  br i1 %85, label %86, label %97

86:                                               ; preds = %83
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.vorbis_look_psy, ptr %87, i32 0, i32 3
  %89 = load ptr, ptr %88, align 8, !tbaa !21
  %90 = load i32, ptr %3, align 4, !tbaa !17
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds ptr, ptr %89, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  call void @free(ptr noundef %93) #4
  br label %94

94:                                               ; preds = %86
  %95 = load i32, ptr %3, align 4, !tbaa !17
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %3, align 4, !tbaa !17
  br label %83, !llvm.loop !22

97:                                               ; preds = %83
  %98 = load ptr, ptr %2, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.vorbis_look_psy, ptr %98, i32 0, i32 3
  %100 = load ptr, ptr %99, align 8, !tbaa !21
  call void @free(ptr noundef %100) #4
  br label %101

101:                                              ; preds = %97, %77
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %102, i8 0, i64 96, i1 false)
  br label %103

103:                                              ; preds = %101, %1
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 64, !11, i64 72, !11, i64 76, !12, i64 80, !13, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !6, i64 48}
!16 = !{!10, !6, i64 16}
!17 = !{!11, !11, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!10, !6, i64 24}
!22 = distinct !{!22, !19}


; 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @_vp_psy_clear(ptr noundef %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %73, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not29 = icmp eq ptr %4, null
  br i1 %.not29, label %6, label %5

5:                                                ; preds = %2
  tail call void @free(ptr noundef nonnull %4) #3
  br label %6

6:                                                ; preds = %5, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %.not30 = icmp eq ptr %8, null
  br i1 %.not30, label %10, label %9

9:                                                ; preds = %6
  tail call void @free(ptr noundef nonnull %8) #3
  br label %10

10:                                               ; preds = %9, %6
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %.not31 = icmp eq ptr %12, null
  br i1 %.not31, label %14, label %13

13:                                               ; preds = %10
  tail call void @free(ptr noundef nonnull %12) #3
  br label %14

14:                                               ; preds = %13, %10
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %.not32 = icmp eq ptr %16, null
  br i1 %.not32, label %61, label %.preheader34

.preheader34:                                     ; preds = %14, %.preheader34
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader34 ], [ 0, %14 ]
  %17 = load ptr, ptr %15, align 8, !tbaa !15
  %18 = getelementptr inbounds ptr, ptr %17, i64 %indvars.iv
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  tail call void @free(ptr noundef %20) #3
  %21 = load ptr, ptr %15, align 8, !tbaa !15
  %22 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  tail call void @free(ptr noundef %25) #3
  %26 = load ptr, ptr %15, align 8, !tbaa !15
  %27 = getelementptr inbounds ptr, ptr %26, i64 %indvars.iv
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  tail call void @free(ptr noundef %30) #3
  %31 = load ptr, ptr %15, align 8, !tbaa !15
  %32 = getelementptr inbounds ptr, ptr %31, i64 %indvars.iv
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %33, i64 24
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  tail call void @free(ptr noundef %35) #3
  %36 = load ptr, ptr %15, align 8, !tbaa !15
  %37 = getelementptr inbounds ptr, ptr %36, i64 %indvars.iv
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  %39 = getelementptr inbounds i8, ptr %38, i64 32
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  tail call void @free(ptr noundef %40) #3
  %41 = load ptr, ptr %15, align 8, !tbaa !15
  %42 = getelementptr inbounds ptr, ptr %41, i64 %indvars.iv
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = getelementptr inbounds i8, ptr %43, i64 40
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  tail call void @free(ptr noundef %45) #3
  %46 = load ptr, ptr %15, align 8, !tbaa !15
  %47 = getelementptr inbounds ptr, ptr %46, i64 %indvars.iv
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = getelementptr inbounds i8, ptr %48, i64 48
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  tail call void @free(ptr noundef %50) #3
  %51 = load ptr, ptr %15, align 8, !tbaa !15
  %52 = getelementptr inbounds ptr, ptr %51, i64 %indvars.iv
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds i8, ptr %53, i64 56
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  tail call void @free(ptr noundef %55) #3
  %56 = load ptr, ptr %15, align 8, !tbaa !15
  %57 = getelementptr inbounds ptr, ptr %56, i64 %indvars.iv
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  tail call void @free(ptr noundef %58) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 17
  br i1 %exitcond.not, label %59, label %.preheader34, !llvm.loop !17

59:                                               ; preds = %.preheader34
  %60 = load ptr, ptr %15, align 8, !tbaa !15
  tail call void @free(ptr noundef %60) #3
  br label %61

61:                                               ; preds = %59, %14
  %62 = getelementptr inbounds i8, ptr %0, i64 24
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %.not33 = icmp eq ptr %63, null
  br i1 %.not33, label %72, label %.preheader.preheader

.preheader.preheader:                             ; preds = %61
  %64 = load ptr, ptr %63, align 8, !tbaa !16
  tail call void @free(ptr noundef %64) #3
  %65 = load ptr, ptr %62, align 8, !tbaa !19
  %66 = getelementptr inbounds i8, ptr %65, i64 8
  %67 = load ptr, ptr %66, align 8, !tbaa !16
  tail call void @free(ptr noundef %67) #3
  %68 = load ptr, ptr %62, align 8, !tbaa !19
  %69 = getelementptr inbounds i8, ptr %68, i64 16
  %70 = load ptr, ptr %69, align 8, !tbaa !16
  tail call void @free(ptr noundef %70) #3
  %71 = load ptr, ptr %62, align 8, !tbaa !19
  tail call void @free(ptr noundef %71) #3
  br label %72

72:                                               ; preds = %.preheader.preheader, %61
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %0, i8 0, i64 96, i1 false)
  br label %73

73:                                               ; preds = %72, %1
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { 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 #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, !10, i64 32}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !11, i64 64, !7, i64 72, !7, i64 76, !11, i64 80, !12, i64 88}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !10, i64 16}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !10, i64 24}


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