; LLVM IR from eugenebokhan/awesome-ml :: Awesome ML/Utils/Zip/minizip (unzip)

; 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.unz64_s = type { %struct.zlib_filefunc64_32_def_s, ptr, ptr, %struct.unz_global_info64_s, i64, i64, i64, i64, i64, i64, i64, i64, %struct.unz_file_info64_s, %struct.unz_file_info64_internal_s, ptr, i32, [3 x i64], ptr }
%struct.zlib_filefunc64_32_def_s = type { %struct.zlib_filefunc64_def_s, ptr, ptr, ptr, ptr }
%struct.zlib_filefunc64_def_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.unz_global_info64_s = type { i64, i64, i64 }
%struct.unz_file_info64_s = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, %struct.tm_unz_s, i64, i64 }
%struct.tm_unz_s = type { i32, i32, i32, i32, i32, i32 }
%struct.unz_file_info64_internal_s = type { i64, i64 }
%struct.file_in_zip64_read_info_s = type { ptr, %struct.z_stream_s, i64, i64, i64, i32, i64, i64, i64, i64, i64, i64, %struct.zlib_filefunc64_32_def_s, ptr, i64, i64, i32 }
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }

; 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 uwtable
define dso_local i32 @unzeof(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store i32 -102, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %25

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.unz64_s, ptr %11, i32 0, i32 14
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %9
  store i32 -102, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %25

16:                                               ; preds = %9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.unz64_s, ptr %17, i32 0, i32 14
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %19, i32 0, i32 11
  %21 = load i64, ptr %20, align 8, !tbaa !20
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %16
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %25

24:                                               ; preds = %16
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %25

25:                                               ; preds = %24, %23, %15, %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %26 = load i32, ptr %2, align 4
  ret i32 %26
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 376}
!10 = !{!"", !11, i64 0, !6, i64 104, !6, i64 112, !13, i64 120, !14, i64 144, !14, i64 152, !14, i64 160, !14, i64 168, !14, i64 176, !15, i64 184, !14, i64 192, !14, i64 200, !16, i64 208, !19, i64 360, !6, i64 376, !18, i64 384, !7, i64 392, !6, i64 416}
!11 = !{!"zlib_filefunc64_32_def_s", !12, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!12 = !{!"zlib_filefunc64_def_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!"unz_global_info64_s", !14, i64 0, !15, i64 8, !15, i64 16}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"unz_file_info64_s", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !14, i64 48, !14, i64 56, !15, i64 64, !15, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !17, i64 112, !14, i64 136, !15, i64 144}
!17 = !{!"tm_unz_s", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16, !18, i64 20}
!18 = !{!"int", !7, i64 0}
!19 = !{!"unz_file_info64_internal_s", !14, i64 0, !14, i64 8}
!20 = !{!21, !14, i64 192}
!21 = !{!"", !6, i64 0, !22, i64 8, !14, i64 120, !15, i64 128, !14, i64 136, !18, i64 144, !14, i64 152, !14, i64 160, !15, i64 168, !15, i64 176, !14, i64 184, !14, i64 192, !11, i64 200, !6, i64 304, !15, i64 312, !14, i64 320, !18, i64 328}
!22 = !{!"z_stream_s", !6, i64 0, !18, i64 8, !15, i64 16, !6, i64 24, !18, i64 32, !15, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !18, i64 88, !15, i64 96, !15, i64 104}


; 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 nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 -102, 2) i32 @unzeof(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %11, label %3

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

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %5, i64 192
  %9 = load i64, ptr %8, align 8, !tbaa !19
  %10 = icmp eq i64 %9, 0
  %. = zext i1 %10 to i32
  br label %11

11:                                               ; preds = %7, %3, %1
  %.0 = phi i32 [ -102, %1 ], [ -102, %3 ], [ %., %7 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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" }

!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, !9, i64 376}
!6 = !{!"", !7, i64 0, !9, i64 104, !9, i64 112, !12, i64 120, !13, i64 144, !13, i64 152, !13, i64 160, !13, i64 168, !13, i64 176, !14, i64 184, !13, i64 192, !13, i64 200, !15, i64 208, !18, i64 360, !9, i64 376, !17, i64 384, !10, i64 392, !9, i64 416}
!7 = !{!"zlib_filefunc64_32_def_s", !8, i64 0, !9, i64 72, !9, i64 80, !9, i64 88, !9, i64 96}
!8 = !{!"zlib_filefunc64_def_s", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40, !9, i64 48, !9, i64 56, !9, i64 64}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"unz_global_info64_s", !13, i64 0, !14, i64 8, !14, i64 16}
!13 = !{!"long long", !10, i64 0}
!14 = !{!"long", !10, i64 0}
!15 = !{!"unz_file_info64_s", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !13, i64 48, !13, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !16, i64 112, !13, i64 136, !14, i64 144}
!16 = !{!"tm_unz_s", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20}
!17 = !{!"int", !10, i64 0}
!18 = !{!"unz_file_info64_internal_s", !13, i64 0, !13, i64 8}
!19 = !{!20, !13, i64 192}
!20 = !{!"", !9, i64 0, !21, i64 8, !13, i64 120, !14, i64 128, !13, i64 136, !17, i64 144, !13, i64 152, !13, i64 160, !14, i64 168, !14, i64 176, !13, i64 184, !13, i64 192, !7, i64 200, !9, i64 304, !14, i64 312, !13, i64 320, !17, i64 328}
!21 = !{!"z_stream_s", !9, i64 0, !17, i64 8, !14, i64 16, !9, i64 24, !17, i64 32, !14, i64 40, !9, i64 48, !9, i64 56, !9, i64 64, !9, i64 72, !9, i64 80, !17, i64 88, !14, i64 96, !14, i64 104}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass