; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/modules/juce_core/zip/zlib (inflate)

; 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.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%struct.inflate_state = type { i32, i32, i32, i32, i32, i32, i64, i64, ptr, i32, i32, i32, i32, ptr, i64, i32, i32, i32, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, ptr, [320 x i16], [288 x i16], [2048 x %struct.code] }
%struct.code = type { i8, i8, i16 }

; 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

declare i64 @z_adler32(i64 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

13:                                               ; preds = %3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.z_stream_s, ptr %14, i32 0, i32 7
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %13, %3
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %112

19:                                               ; preds = %13
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.z_stream_s, ptr %20, i32 0, i32 7
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.inflate_state, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %33

27:                                               ; preds = %19
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.inflate_state, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !16
  %31 = icmp ne i32 %30, 10
  br i1 %31, label %32, label %33

32:                                               ; preds = %27
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %112

33:                                               ; preds = %27, %19
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.inflate_state, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !16
  %37 = icmp eq i32 %36, 10
  br i1 %37, label %38, label %51

38:                                               ; preds = %33
  %39 = call i64 @z_adler32(i64 noundef 0, ptr noundef null, i32 noundef 0)
  store i64 %39, ptr %9, align 8, !tbaa !17
  %40 = load i64, ptr %9, align 8, !tbaa !17
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = call i64 @z_adler32(i64 noundef %40, ptr noundef %41, i32 noundef %42)
  store i64 %43, ptr %9, align 8, !tbaa !17
  %44 = load i64, ptr %9, align 8, !tbaa !17
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.inflate_state, ptr %45, i32 0, i32 6
  %47 = load i64, ptr %46, align 8, !tbaa !18
  %48 = icmp ne i64 %44, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %38
  store i32 -3, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %112

50:                                               ; preds = %38
  br label %51

51:                                               ; preds = %50, %33
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.z_stream_s, ptr %53, i32 0, i32 4
  %55 = load i32, ptr %54, align 8, !tbaa !19
  %56 = call i32 @updatewindow(ptr noundef %52, i32 noundef %55)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %61

58:                                               ; preds = %51
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.inflate_state, ptr %59, i32 0, i32 0
  store i32 28, ptr %60, align 8, !tbaa !16
  store i32 -4, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %112

61:                                               ; preds = %51
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.inflate_state, ptr %63, i32 0, i32 10
  %65 = load i32, ptr %64, align 4, !tbaa !20
  %66 = icmp ugt i32 %62, %65
  br i1 %66, label %67, label %90

67:                                               ; preds = %61
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.inflate_state, ptr %68, i32 0, i32 13
  %70 = load ptr, ptr %69, align 8, !tbaa !21
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds i8, ptr %71, i64 %73
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.inflate_state, ptr %75, i32 0, i32 10
  %77 = load i32, ptr %76, align 4, !tbaa !20
  %78 = zext i32 %77 to i64
  %79 = sub i64 0, %78
  %80 = getelementptr inbounds i8, ptr %74, i64 %79
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.inflate_state, ptr %81, i32 0, i32 10
  %83 = load i32, ptr %82, align 4, !tbaa !20
  %84 = zext i32 %83 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %70, ptr align 1 %80, i64 %84, i1 false)
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.inflate_state, ptr %85, i32 0, i32 10
  %87 = load i32, ptr %86, align 4, !tbaa !20
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.inflate_state, ptr %88, i32 0, i32 11
  store i32 %87, ptr %89, align 8, !tbaa !22
  br label %109

90:                                               ; preds = %61
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.inflate_state, ptr %91, i32 0, i32 13
  %93 = load ptr, ptr %92, align 8, !tbaa !21
  %94 = load ptr, ptr %8, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.inflate_state, ptr %94, i32 0, i32 10
  %96 = load i32, ptr %95, align 4, !tbaa !20
  %97 = zext i32 %96 to i64
  %98 = getelementptr inbounds i8, ptr %93, i64 %97
  %99 = load i32, ptr %7, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = sub i64 0, %100
  %102 = getelementptr inbounds i8, ptr %98, i64 %101
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = load i32, ptr %7, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %102, ptr align 1 %103, i64 %105, i1 false)
  %106 = load i32, ptr %7, align 4, !tbaa !9
  %107 = load ptr, ptr %8, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.inflate_state, ptr %107, i32 0, i32 11
  store i32 %106, ptr %108, align 8, !tbaa !22
  br label %109

109:                                              ; preds = %90, %67
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.inflate_state, ptr %110, i32 0, i32 3
  store i32 1, ptr %111, align 4, !tbaa !23
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %112

112:                                              ; preds = %109, %58, %49, %32, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %113 = load i32, ptr %4, align 4
  ret i32 %113
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 56}
!12 = !{!"z_stream_s", !6, i64 0, !10, i64 8, !13, i64 16, !6, i64 24, !10, i64 32, !13, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !13, i64 96, !13, i64 104}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"inflate_state", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !6, i64 64, !13, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !6, i64 96, !6, i64 104, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !6, i64 136, !7, i64 144, !7, i64 784, !7, i64 1360}
!16 = !{!15, !10, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!15, !13, i64 24}
!19 = !{!12, !10, i64 32}
!20 = !{!15, !10, i64 52}
!21 = !{!15, !6, i64 64}
!22 = !{!15, !10, i64 56}
!23 = !{!15, !10, i64 12}


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

declare i64 @z_adler32(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -4, 1) i32 @z_inflateSetDictionary(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = icmp eq ptr %0, null
  br i1 %4, label %46, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %46, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %7, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %.not = icmp eq i32 %11, 0
  %.pr = load i32, ptr %7, align 8, !tbaa !14
  %12 = icmp eq i32 %.pr, 10
  br i1 %.not, label %14, label %13

13:                                               ; preds = %9
  br i1 %12, label %.thread, label %46

14:                                               ; preds = %9
  br i1 %12, label %.thread, label %19

.thread:                                          ; preds = %13, %14
  %15 = tail call i64 @z_adler32(i64 noundef 0, ptr noundef null, i32 noundef 0) #3
  %16 = tail call i64 @z_adler32(i64 noundef %15, ptr noundef %1, i32 noundef %2) #3
  %17 = getelementptr inbounds i8, ptr %7, i64 24
  %18 = load i64, ptr %17, align 8, !tbaa !15
  %.not37 = icmp eq i64 %16, %18
  br i1 %.not37, label %19, label %46

19:                                               ; preds = %.thread, %14
  %20 = getelementptr inbounds i8, ptr %0, i64 32
  %21 = load i32, ptr %20, align 8, !tbaa !16
  %22 = tail call i32 @updatewindow(ptr noundef nonnull %0, i32 noundef %21)
  %.not38 = icmp eq i32 %22, 0
  br i1 %.not38, label %24, label %23

23:                                               ; preds = %19
  store i32 28, ptr %7, align 8, !tbaa !14
  br label %46

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %7, i64 52
  %26 = load i32, ptr %25, align 4, !tbaa !17
  %27 = icmp ult i32 %26, %2
  %28 = getelementptr inbounds i8, ptr %7, i64 64
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  br i1 %27, label %30, label %37

30:                                               ; preds = %24
  %31 = zext i32 %2 to i64
  %32 = getelementptr inbounds i8, ptr %1, i64 %31
  %33 = zext i32 %26 to i64
  %34 = sub nsw i64 0, %33
  %35 = getelementptr inbounds i8, ptr %32, i64 %34
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %29, ptr nonnull align 1 %35, i64 %33, i1 false)
  %36 = load i32, ptr %25, align 4, !tbaa !17
  br label %43

37:                                               ; preds = %24
  %38 = zext i32 %26 to i64
  %39 = getelementptr inbounds i8, ptr %29, i64 %38
  %40 = zext i32 %2 to i64
  %41 = sub nsw i64 0, %40
  %42 = getelementptr inbounds i8, ptr %39, i64 %41
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %42, ptr align 1 %1, i64 %40, i1 false)
  br label %43

43:                                               ; preds = %37, %30
  %.sink = phi i32 [ %36, %30 ], [ %2, %37 ]
  %44 = getelementptr inbounds i8, ptr %7, i64 56
  store i32 %.sink, ptr %44, align 8
  %45 = getelementptr inbounds i8, ptr %7, i64 12
  store i32 1, ptr %45, align 4, !tbaa !19
  br label %46

46:                                               ; preds = %.thread, %13, %3, %5, %43, %23
  %.0 = phi i32 [ -4, %23 ], [ 0, %43 ], [ -2, %5 ], [ -2, %3 ], [ -2, %13 ], [ -3, %.thread ]
  ret i32 %.0
}

attributes #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 nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 56}
!6 = !{!"z_stream_s", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !11, i64 96, !11, i64 104}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !10, i64 8}
!13 = !{!"inflate_state", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !7, i64 64, !11, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !7, i64 96, !7, i64 104, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !7, i64 136, !8, i64 144, !8, i64 784, !8, i64 1360}
!14 = !{!13, !10, i64 0}
!15 = !{!13, !11, i64 24}
!16 = !{!6, !10, i64 32}
!17 = !{!13, !10, i64 52}
!18 = !{!13, !7, i64 64}
!19 = !{!13, !10, i64 12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass