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

@.str = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @z_inflateReset(ptr noundef) #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 uwtable
define dso_local i32 @z_inflateInit2_(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %25, label %14

14:                                               ; preds = %4
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 0
  %17 = load i8, ptr %16, align 1, !tbaa !11
  %18 = sext i8 %17 to i32
  %19 = load i8, ptr @.str, align 1, !tbaa !11
  %20 = sext i8 %19 to i32
  %21 = icmp ne i32 %18, %20
  br i1 %21, label %25, label %22

22:                                               ; preds = %14
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 112
  br i1 %24, label %25, label %26

25:                                               ; preds = %22, %14, %4
  store i32 -6, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %108

26:                                               ; preds = %22
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 -2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %108

30:                                               ; preds = %26
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.z_stream_s, ptr %31, i32 0, i32 6
  store ptr null, ptr %32, align 8, !tbaa !12
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.z_stream_s, ptr %33, i32 0, i32 8
  %35 = load ptr, ptr %34, align 8, !tbaa !15
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %42

37:                                               ; preds = %30
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.z_stream_s, ptr %38, i32 0, i32 8
  store ptr @zcalloc, ptr %39, align 8, !tbaa !15
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.z_stream_s, ptr %40, i32 0, i32 10
  store ptr null, ptr %41, align 8, !tbaa !16
  br label %42

42:                                               ; preds = %37, %30
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.z_stream_s, ptr %43, i32 0, i32 9
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %50

47:                                               ; preds = %42
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.z_stream_s, ptr %48, i32 0, i32 9
  store ptr @zcfree, ptr %49, align 8, !tbaa !17
  br label %50

50:                                               ; preds = %47, %42
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.z_stream_s, ptr %51, i32 0, i32 8
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.z_stream_s, ptr %54, i32 0, i32 10
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  %57 = call ptr %53(ptr noundef %56, i32 noundef 1, i32 noundef 9552)
  store ptr %57, ptr %10, align 8, !tbaa !5
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = icmp eq ptr %58, null
  br i1 %59, label %60, label %61

60:                                               ; preds = %50
  store i32 -4, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %108

61:                                               ; preds = %50
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.z_stream_s, ptr %63, i32 0, i32 7
  store ptr %62, ptr %64, align 8, !tbaa !18
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = icmp slt i32 %65, 0
  br i1 %66, label %67, label %72

67:                                               ; preds = %61
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.inflate_state, ptr %68, i32 0, i32 2
  store i32 0, ptr %69, align 8, !tbaa !19
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = sub nsw i32 0, %70
  store i32 %71, ptr %7, align 4, !tbaa !9
  br label %84

72:                                               ; preds = %61
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = ashr i32 %73, 4
  %75 = add nsw i32 %74, 1
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.inflate_state, ptr %76, i32 0, i32 2
  store i32 %75, ptr %77, align 8, !tbaa !19
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = icmp slt i32 %78, 48
  br i1 %79, label %80, label %83

80:                                               ; preds = %72
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = and i32 %81, 15
  store i32 %82, ptr %7, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %80, %72
  br label %84

84:                                               ; preds = %83, %67
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = icmp slt i32 %85, 8
  br i1 %86, label %90, label %87

87:                                               ; preds = %84
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = icmp sgt i32 %88, 15
  br i1 %89, label %90, label %100

90:                                               ; preds = %87, %84
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.z_stream_s, ptr %91, i32 0, i32 9
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.z_stream_s, ptr %94, i32 0, i32 10
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  call void %93(ptr noundef %96, ptr noundef %97)
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.z_stream_s, ptr %98, i32 0, i32 7
  store ptr null, ptr %99, align 8, !tbaa !18
  store i32 -2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %108

100:                                              ; preds = %87
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.inflate_state, ptr %102, i32 0, i32 9
  store i32 %101, ptr %103, align 8, !tbaa !21
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.inflate_state, ptr %104, i32 0, i32 13
  store ptr null, ptr %105, align 8, !tbaa !22
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = call i32 @z_inflateReset(ptr noundef %106)
  store i32 %107, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %108

108:                                              ; preds = %100, %90, %60, %29, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %109 = load i32, ptr %5, align 4
  ret i32 %109
}

declare ptr @zcalloc(ptr noundef, i32 noundef, i32 noundef) #2

declare void @zcfree(ptr noundef, ptr noundef) #2

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


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

@.str = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @z_inflateReset(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @z_inflateInit2_(ptr noundef %0, i32 noundef %1, ptr noundef readonly %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %2, null
  br i1 %5, label %51, label %6

6:                                                ; preds = %4
  %7 = load i8, ptr %2, align 1, !tbaa !5
  %8 = load i8, ptr @.str, align 1, !tbaa !5
  %9 = icmp ne i8 %7, %8
  %10 = icmp ne i32 %3, 112
  %or.cond = or i1 %10, %9
  br i1 %or.cond, label %51, label %11

11:                                               ; preds = %6
  %12 = icmp eq ptr %0, null
  br i1 %12, label %51, label %13

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr null, ptr %14, align 8, !tbaa !8
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %20

18:                                               ; preds = %13
  store ptr @zcalloc, ptr %15, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr null, ptr %19, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %18, %13
  %21 = phi ptr [ @zcalloc, %18 ], [ %16, %13 ]
  %22 = getelementptr inbounds i8, ptr %0, i64 72
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  store ptr @zcfree, ptr %22, align 8, !tbaa !15
  br label %26

26:                                               ; preds = %25, %20
  %27 = getelementptr inbounds i8, ptr %0, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = tail call ptr %21(ptr noundef %28, i32 noundef 1, i32 noundef 9552) #2
  %30 = icmp eq ptr %29, null
  br i1 %30, label %51, label %31

31:                                               ; preds = %26
  %32 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %29, ptr %32, align 8, !tbaa !16
  %33 = icmp slt i32 %1, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = sub nsw i32 0, %1
  br label %41

36:                                               ; preds = %31
  %37 = lshr i32 %1, 4
  %38 = add nuw nsw i32 %37, 1
  %39 = icmp ult i32 %1, 48
  %40 = and i32 %1, 15
  %spec.select = select i1 %39, i32 %40, i32 %1
  br label %41

41:                                               ; preds = %36, %34
  %.sink = phi i32 [ 0, %34 ], [ %38, %36 ]
  %.035 = phi i32 [ %35, %34 ], [ %spec.select, %36 ]
  %42 = getelementptr inbounds i8, ptr %29, i64 8
  store i32 %.sink, ptr %42, align 8
  %43 = add nsw i32 %.035, -16
  %or.cond3 = icmp ult i32 %43, -8
  br i1 %or.cond3, label %44, label %47

44:                                               ; preds = %41
  %45 = load ptr, ptr %22, align 8, !tbaa !15
  %46 = load ptr, ptr %27, align 8, !tbaa !14
  tail call void %45(ptr noundef %46, ptr noundef nonnull %29) #2
  store ptr null, ptr %32, align 8, !tbaa !16
  br label %51

47:                                               ; preds = %41
  %48 = getelementptr inbounds i8, ptr %29, i64 48
  store i32 %.035, ptr %48, align 8, !tbaa !17
  %49 = getelementptr inbounds i8, ptr %29, i64 64
  store ptr null, ptr %49, align 8, !tbaa !19
  %50 = tail call i32 @z_inflateReset(ptr noundef nonnull %0)
  br label %51

51:                                               ; preds = %26, %11, %4, %6, %47, %44
  %.0 = phi i32 [ -2, %44 ], [ %50, %47 ], [ -6, %6 ], [ -6, %4 ], [ -2, %11 ], [ -4, %26 ]
  ret i32 %.0
}

declare ptr @zcalloc(ptr noundef, i32 noundef, i32 noundef) #1

declare void @zcfree(ptr noundef, ptr noundef) #1

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass