; LLVM IR from taichi-dev/taichi :: taichi/common (miniz)

; 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.tinfl_decompressor_tag = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i64, i64, [3 x [1024 x i16]], [576 x i16], [64 x i16], [38 x i16], [288 x i8], [32 x i8], [19 x i8], [4 x i8], [457 x i8] }

; 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
declare void @free(ptr noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @tinfl_decompress(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @tinfl_decompress_mem_to_callback(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.tinfl_decompressor_tag, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8376, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %21 = call noalias ptr @malloc(i64 noundef 32768) #6
  store ptr %21, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store i64 0, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store i64 0, ptr %16, align 8, !tbaa !11
  %22 = load ptr, ptr %14, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %5
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %84

25:                                               ; preds = %5
  %26 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 1 %26, i8 0, i64 32768, i1 false)
  br label %27

27:                                               ; preds = %25
  %28 = getelementptr inbounds %struct.tinfl_decompressor_tag, ptr %13, i32 0, i32 0
  store i32 0, ptr %28, align 8, !tbaa !13
  br label %29

29:                                               ; preds = %27
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %78, %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = load i64, ptr %15, align 8, !tbaa !11
  %35 = sub i64 %33, %34
  store i64 %35, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %36 = load i64, ptr %16, align 8, !tbaa !11
  %37 = sub i64 32768, %36
  store i64 %37, ptr %19, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i64, ptr %15, align 8, !tbaa !11
  %40 = getelementptr inbounds i8, ptr %38, i64 %39
  %41 = load ptr, ptr %14, align 8, !tbaa !5
  %42 = load ptr, ptr %14, align 8, !tbaa !5
  %43 = load i64, ptr %16, align 8, !tbaa !11
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = and i32 %45, -7
  %47 = call i32 @tinfl_decompress(ptr noundef %13, ptr noundef %40, ptr noundef %18, ptr noundef %41, ptr noundef %44, ptr noundef %19, i32 noundef %46)
  store i32 %47, ptr %20, align 4, !tbaa !9
  %48 = load i64, ptr %18, align 8, !tbaa !11
  %49 = load i64, ptr %15, align 8, !tbaa !11
  %50 = add i64 %49, %48
  store i64 %50, ptr %15, align 8, !tbaa !11
  %51 = load i64, ptr %19, align 8, !tbaa !11
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %64

53:                                               ; preds = %31
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  %56 = load i64, ptr %16, align 8, !tbaa !11
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = load i64, ptr %19, align 8, !tbaa !11
  %59 = trunc i64 %58 to i32
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = call i32 %54(ptr noundef %57, i32 noundef %59, ptr noundef %60)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %64, label %63

63:                                               ; preds = %53
  store i32 4, ptr %17, align 4
  br label %76

64:                                               ; preds = %53, %31
  %65 = load i32, ptr %20, align 4, !tbaa !9
  %66 = icmp ne i32 %65, 2
  br i1 %66, label %67, label %71

67:                                               ; preds = %64
  %68 = load i32, ptr %20, align 4, !tbaa !9
  %69 = icmp eq i32 %68, 0
  %70 = zext i1 %69 to i32
  store i32 %70, ptr %12, align 4, !tbaa !9
  store i32 4, ptr %17, align 4
  br label %76

71:                                               ; preds = %64
  %72 = load i64, ptr %16, align 8, !tbaa !11
  %73 = load i64, ptr %19, align 8, !tbaa !11
  %74 = add i64 %72, %73
  %75 = and i64 %74, 32767
  store i64 %75, ptr %16, align 8, !tbaa !11
  store i32 0, ptr %17, align 4
  br label %76

76:                                               ; preds = %71, %67, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %77 = load i32, ptr %17, align 4
  switch i32 %77, label %86 [
    i32 0, label %78
    i32 4, label %79
  ]

78:                                               ; preds = %76
  br label %31

79:                                               ; preds = %76
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %80) #5
  %81 = load i64, ptr %15, align 8, !tbaa !11
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %81, ptr %82, align 8, !tbaa !11
  %83 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %83, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %84

84:                                               ; preds = %79, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8376, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %85 = load i32, ptr %6, align 4
  ret i32 %85

86:                                               ; preds = %76
  unreachable
}

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

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"tinfl_decompressor_tag", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 44, !12, i64 56, !12, i64 64, !7, i64 72, !7, i64 6216, !7, i64 7368, !7, i64 7496, !7, i64 7572, !7, i64 7860, !7, i64 7892, !7, i64 7911, !7, i64 7915}


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

%struct.tinfl_decompressor_tag = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i64, i64, [3 x [1024 x i16]], [576 x i16], [64 x i16], [38 x i16], [288 x i8], [32 x i8], [19 x i8], [4 x i8], [457 x i8] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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
declare dso_local i32 @tinfl_decompress(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @tinfl_decompress_mem_to_callback(ptr noundef %0, ptr nocapture noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  %6 = alloca %struct.tinfl_decompressor_tag, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8376, ptr nonnull %6) #4
  %calloc = tail call dereferenceable_or_null(32768) ptr @calloc(i64 1, i64 32768)
  %.not = icmp eq ptr %calloc, null
  br i1 %.not, label %32, label %9

9:                                                ; preds = %5
  store i32 0, ptr %6, align 8, !tbaa !5
  %10 = and i32 %4, -7
  br label %11

11:                                               ; preds = %28, %9
  %.026 = phi i64 [ 0, %9 ], [ %19, %28 ]
  %.025 = phi i64 [ 0, %9 ], [ %31, %28 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %12 = load i64, ptr %1, align 8, !tbaa !11
  %13 = sub i64 %12, %.026
  store i64 %13, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %14 = sub nuw nsw i64 32768, %.025
  store i64 %14, ptr %8, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %0, i64 %.026
  %16 = getelementptr inbounds i8, ptr %calloc, i64 %.025
  %17 = call i32 @tinfl_decompress(ptr noundef nonnull %6, ptr noundef %15, ptr noundef nonnull %7, ptr noundef nonnull %calloc, ptr noundef nonnull %16, ptr noundef nonnull %8, i32 noundef %10)
  %18 = load i64, ptr %7, align 8, !tbaa !11
  %19 = add i64 %18, %.026
  %20 = load i64, ptr %8, align 8, !tbaa !11
  %.not32 = icmp eq i64 %20, 0
  br i1 %.not32, label %24, label %21

21:                                               ; preds = %11
  %22 = trunc i64 %20 to i32
  %23 = call i32 %2(ptr noundef nonnull %16, i32 noundef %22, ptr noundef %3) #4
  %.not33 = icmp eq i32 %23, 0
  br i1 %.not33, label %.loopexit, label %24

24:                                               ; preds = %21, %11
  %.not34 = icmp eq i32 %17, 2
  br i1 %.not34, label %28, label %25

25:                                               ; preds = %24
  %26 = icmp eq i32 %17, 0
  %27 = zext i1 %26 to i32
  br label %.loopexit

28:                                               ; preds = %24
  %29 = load i64, ptr %8, align 8, !tbaa !11
  %30 = add i64 %29, %.025
  %31 = and i64 %30, 32767
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  br label %11

.loopexit:                                        ; preds = %21, %25
  %.128.ph = phi i32 [ %27, %25 ], [ 0, %21 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @free(ptr noundef %calloc) #4
  store i64 %19, ptr %1, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %5, %.loopexit
  %.0 = phi i32 [ %.128.ph, %.loopexit ], [ -1, %5 ]
  call void @llvm.lifetime.end.p0(i64 8376, ptr nonnull %6) #4
  ret i32 %.0
}

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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, !7, i64 0}
!6 = !{!"tinfl_decompressor_tag", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !8, i64 44, !10, i64 56, !10, i64 64, !8, i64 72, !8, i64 6216, !8, i64 7368, !8, i64 7496, !8, i64 7572, !8, i64 7860, !8, i64 7892, !8, i64 7911, !8, i64 7915}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass