; LLVM IR from ermig1979/Simd :: src/Simd (SimdBaseImageLoadPng)

; 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.Simd::Base::Zlib::Zhuffman" = type { [512 x i16], [16 x i16], [17 x i32], [16 x i16], [288 x i8], [288 x i16] }

@_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE14ZdefaultLength = external hidden constant [288 x i8], align 16
@_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE16ZdefaultDistance = external hidden constant [32 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEb(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(56) %1, i1 noundef zeroext %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca %"struct.Simd::Base::Zlib::Zhuffman", align 4
  %9 = alloca %"struct.Simd::Base::Zlib::Zhuffman", align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  %13 = zext i1 %2 to i8
  store i8 %13, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2020, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 2020, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %14 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %22

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef i32 @_ZN4Simd4Base4ZlibL11ParseHeaderERNS_17InputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40) %17)
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21, %3
  br label %23

23:                                               ; preds = %68, %22
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call noundef i64 @_ZN4Simd17InputMemoryStream8ReadBitsEm(ptr noundef nonnull align 8 dereferenceable(40) %24, i64 noundef 1)
  %26 = trunc i64 %25 to i32
  store i32 %26, ptr %10, align 4, !tbaa !13
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call noundef i64 @_ZN4Simd17InputMemoryStream8ReadBitsEm(ptr noundef nonnull align 8 dereferenceable(40) %27, i64 noundef 2)
  %29 = trunc i64 %28 to i32
  store i32 %29, ptr %11, align 4, !tbaa !13
  %30 = load i32, ptr %11, align 4, !tbaa !13
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %39

32:                                               ; preds = %23
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call noundef i32 @_ZN4Simd4Base4ZlibL22ParseUncompressedBlockERNS_17InputMemoryStreamERNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40) %33, ptr noundef nonnull align 8 dereferenceable(56) %34)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %32
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

38:                                               ; preds = %32
  br label %67

39:                                               ; preds = %23
  %40 = load i32, ptr %11, align 4, !tbaa !13
  %41 = icmp eq i32 %40, 3
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

43:                                               ; preds = %39
  %44 = load i32, ptr %11, align 4, !tbaa !13
  %45 = icmp eq i32 %44, 1
  br i1 %45, label %46, label %53

46:                                               ; preds = %43
  %47 = call noundef zeroext i1 @_ZN4Simd4Base4Zlib8Zhuffman5BuildEPKhi(ptr noundef nonnull align 4 dereferenceable(2020) %8, ptr noundef @_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE14ZdefaultLength, i32 noundef 288)
  br i1 %47, label %49, label %48

48:                                               ; preds = %46
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

49:                                               ; preds = %46
  %50 = call noundef zeroext i1 @_ZN4Simd4Base4Zlib8Zhuffman5BuildEPKhi(ptr noundef nonnull align 4 dereferenceable(2020) %9, ptr noundef @_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE16ZdefaultDistance, i32 noundef 32)
  br i1 %50, label %52, label %51

51:                                               ; preds = %49
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

52:                                               ; preds = %49
  br label %59

53:                                               ; preds = %43
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call noundef i32 @_ZN4Simd4Base4ZlibL19ComputeHuffmanCodesERNS_17InputMemoryStreamERNS1_8ZhuffmanES5_(ptr noundef nonnull align 8 dereferenceable(40) %54, ptr noundef nonnull align 4 dereferenceable(2020) %8, ptr noundef nonnull align 4 dereferenceable(2020) %9)
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

58:                                               ; preds = %53
  br label %59

59:                                               ; preds = %58, %52
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = call noundef i32 @_ZN4Simd4Base4ZlibL17ParseHuffmanBlockERNS_17InputMemoryStreamERKNS1_8ZhuffmanES6_RNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40) %60, ptr noundef nonnull align 4 dereferenceable(2020) %8, ptr noundef nonnull align 4 dereferenceable(2020) %9, ptr noundef nonnull align 8 dereferenceable(56) %61)
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %65, label %64

64:                                               ; preds = %59
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

65:                                               ; preds = %59
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66, %38
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %10, align 4, !tbaa !13
  %70 = icmp ne i32 %69, 0
  %71 = xor i1 %70, true
  br i1 %71, label %23, label %72, !llvm.loop !15

72:                                               ; preds = %68
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %73

73:                                               ; preds = %72, %64, %57, %51, %48, %42, %37, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 2020, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 2020, ptr %8) #3
  %74 = load i1, ptr %4, align 1
  ret i1 %74
}

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL11ParseHeaderERNS_17InputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40)) #0

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i64 @_ZN4Simd17InputMemoryStream8ReadBitsEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL22ParseUncompressedBlockERNS_17InputMemoryStreamERNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(56)) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4Simd4Base4Zlib8Zhuffman5BuildEPKhi(ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL19ComputeHuffmanCodesERNS_17InputMemoryStreamERNS1_8ZhuffmanES5_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef nonnull align 4 dereferenceable(2020)) #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL17ParseHuffmanBlockERNS_17InputMemoryStreamERKNS1_8ZhuffmanES6_RNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef nonnull align 8 dereferenceable(56)) #0

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

attributes #0 = { mustprogress 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 = { alwaysinline mustprogress 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%"struct.Simd::Base::Zlib::Zhuffman" = type { [512 x i16], [16 x i16], [17 x i32], [16 x i16], [288 x i8], [288 x i16] }

@_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE14ZdefaultLength = external hidden constant [288 x i8], align 16
@_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE16ZdefaultDistance = external hidden constant [32 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEb(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(56) %1, i1 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = alloca %"struct.Simd::Base::Zlib::Zhuffman", align 4
  %5 = alloca %"struct.Simd::Base::Zlib::Zhuffman", align 4
  call void @llvm.lifetime.start.p0(i64 2020, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 2020, ptr nonnull %5) #3
  br i1 %2, label %6, label %.preheader

6:                                                ; preds = %3
  %7 = tail call noundef i32 @_ZN4Simd4Base4ZlibL11ParseHeaderERNS_17InputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %6, %3
  br label %8

8:                                                ; preds = %.preheader, %22
  %9 = call noundef i64 @_ZN4Simd17InputMemoryStream8ReadBitsEm(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef 1)
  %10 = call noundef i64 @_ZN4Simd17InputMemoryStream8ReadBitsEm(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef 2)
  %11 = trunc i64 %10 to i32
  switch i32 %11, label %18 [
    i32 0, label %12
    i32 3, label %.loopexit
    i32 1, label %14
  ]

12:                                               ; preds = %8
  %13 = call noundef i32 @_ZN4Simd4Base4ZlibL22ParseUncompressedBlockERNS_17InputMemoryStreamERNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(56) %1)
  %.not16 = icmp eq i32 %13, 0
  br i1 %.not16, label %.loopexit, label %22

14:                                               ; preds = %8
  %15 = call noundef zeroext i1 @_ZN4Simd4Base4Zlib8Zhuffman5BuildEPKhi(ptr noundef nonnull align 4 dereferenceable(2020) %4, ptr noundef nonnull @_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE14ZdefaultLength, i32 noundef 288)
  br i1 %15, label %16, label %.loopexit

16:                                               ; preds = %14
  %17 = call noundef zeroext i1 @_ZN4Simd4Base4Zlib8Zhuffman5BuildEPKhi(ptr noundef nonnull align 4 dereferenceable(2020) %5, ptr noundef nonnull @_ZZN4Simd4Base4Zlib6DecodeERNS_17InputMemoryStreamERNS_18OutputMemoryStreamEbE16ZdefaultDistance, i32 noundef 32)
  br i1 %17, label %20, label %.loopexit

18:                                               ; preds = %8
  %19 = call noundef i32 @_ZN4Simd4Base4ZlibL19ComputeHuffmanCodesERNS_17InputMemoryStreamERNS1_8ZhuffmanES5_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 4 dereferenceable(2020) %4, ptr noundef nonnull align 4 dereferenceable(2020) %5)
  %.not14 = icmp eq i32 %19, 0
  br i1 %.not14, label %.loopexit, label %20

20:                                               ; preds = %18, %16
  %21 = call noundef i32 @_ZN4Simd4Base4ZlibL17ParseHuffmanBlockERNS_17InputMemoryStreamERKNS1_8ZhuffmanES6_RNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 4 dereferenceable(2020) %4, ptr noundef nonnull align 4 dereferenceable(2020) %5, ptr noundef nonnull align 8 dereferenceable(56) %1)
  %.not15 = icmp eq i32 %21, 0
  br i1 %.not15, label %.loopexit, label %22

22:                                               ; preds = %12, %20
  %23 = and i64 %9, 4294967295
  %.not17 = icmp eq i64 %23, 0
  br i1 %.not17, label %8, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %22, %20, %18, %16, %14, %8, %12, %6
  %.0 = phi i1 [ false, %6 ], [ true, %22 ], [ false, %20 ], [ false, %18 ], [ false, %16 ], [ false, %14 ], [ false, %8 ], [ false, %12 ]
  call void @llvm.lifetime.end.p0(i64 2020, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 2020, ptr nonnull %4) #3
  ret i1 %.0
}

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL11ParseHeaderERNS_17InputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i64 @_ZN4Simd17InputMemoryStream8ReadBitsEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL22ParseUncompressedBlockERNS_17InputMemoryStreamERNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4Simd4Base4Zlib8Zhuffman5BuildEPKhi(ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL19ComputeHuffmanCodesERNS_17InputMemoryStreamERNS1_8ZhuffmanES5_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef nonnull align 4 dereferenceable(2020)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN4Simd4Base4ZlibL17ParseHuffmanBlockERNS_17InputMemoryStreamERKNS1_8ZhuffmanES6_RNS_18OutputMemoryStreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef nonnull align 4 dereferenceable(2020), ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #0

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

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline mustprogress 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass