; 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

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

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

14:                                               ; preds = %3
  store i32 -102, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %108

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

21:                                               ; preds = %15
  store i32 -102, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %108

22:                                               ; preds = %15
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.unz64_s, ptr %23, i32 0, i32 14
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %25, i32 0, i32 5
  %27 = load i32, ptr %26, align 8, !tbaa !21
  %28 = zext i32 %27 to i64
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.unz64_s, ptr %29, i32 0, i32 14
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %31, i32 0, i32 6
  %33 = load i64, ptr %32, align 8, !tbaa !24
  %34 = sub i64 %28, %33
  store i64 %34, ptr %10, align 8, !tbaa !25
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %40

37:                                               ; preds = %22
  %38 = load i64, ptr %10, align 8, !tbaa !25
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %108

40:                                               ; preds = %22
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = load i64, ptr %10, align 8, !tbaa !25
  %44 = icmp ugt i64 %42, %43
  br i1 %44, label %45, label %48

45:                                               ; preds = %40
  %46 = load i64, ptr %10, align 8, !tbaa !25
  %47 = trunc i64 %46 to i32
  store i32 %47, ptr %9, align 4, !tbaa !9
  br label %50

48:                                               ; preds = %40
  %49 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %49, ptr %9, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %48, %45
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %108

54:                                               ; preds = %50
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.unz64_s, ptr %55, i32 0, i32 14
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %57, i32 0, i32 12
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.unz64_s, ptr %59, i32 0, i32 14
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %61, i32 0, i32 13
  %63 = load ptr, ptr %62, align 8, !tbaa !26
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.unz64_s, ptr %64, i32 0, i32 14
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  %67 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %66, i32 0, i32 4
  %68 = load i64, ptr %67, align 8, !tbaa !27
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.unz64_s, ptr %69, i32 0, i32 14
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %71, i32 0, i32 6
  %73 = load i64, ptr %72, align 8, !tbaa !24
  %74 = add i64 %68, %73
  %75 = call i64 @call_zseek64(ptr noundef %58, ptr noundef %63, i64 noundef %74, i32 noundef 0)
  %76 = icmp ne i64 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %54
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %108

78:                                               ; preds = %54
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.unz64_s, ptr %79, i32 0, i32 14
  %81 = load ptr, ptr %80, align 8, !tbaa !11
  %82 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %81, i32 0, i32 12
  %83 = getelementptr inbounds %struct.zlib_filefunc64_32_def_s, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %struct.zlib_filefunc64_def_s, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !28
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.unz64_s, ptr %86, i32 0, i32 14
  %88 = load ptr, ptr %87, align 8, !tbaa !11
  %89 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %88, i32 0, i32 12
  %90 = getelementptr inbounds %struct.zlib_filefunc64_32_def_s, ptr %89, i32 0, i32 0
  %91 = getelementptr inbounds %struct.zlib_filefunc64_def_s, ptr %90, i32 0, i32 8
  %92 = load ptr, ptr %91, align 8, !tbaa !29
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.unz64_s, ptr %93, i32 0, i32 14
  %95 = load ptr, ptr %94, align 8, !tbaa !11
  %96 = getelementptr inbounds %struct.file_in_zip64_read_info_s, ptr %95, i32 0, i32 13
  %97 = load ptr, ptr %96, align 8, !tbaa !26
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = load i32, ptr %9, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = call i64 %85(ptr noundef %92, ptr noundef %97, ptr noundef %98, i64 noundef %100)
  %102 = load i32, ptr %9, align 4, !tbaa !9
  %103 = zext i32 %102 to i64
  %104 = icmp ne i64 %101, %103
  br i1 %104, label %105, label %106

105:                                              ; preds = %78
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %108

106:                                              ; preds = %78
  %107 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %107, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %108

108:                                              ; preds = %106, %105, %77, %53, %37, %21, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %109 = load i32, ptr %4, align 4
  ret i32 %109
}

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 = { 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, !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 376}
!12 = !{!"", !13, i64 0, !6, i64 104, !6, i64 112, !15, i64 120, !16, i64 144, !16, i64 152, !16, i64 160, !16, i64 168, !16, i64 176, !17, i64 184, !16, i64 192, !16, i64 200, !18, i64 208, !20, i64 360, !6, i64 376, !10, i64 384, !7, i64 392, !6, i64 416}
!13 = !{!"zlib_filefunc64_32_def_s", !14, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!14 = !{!"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}
!15 = !{!"unz_global_info64_s", !16, i64 0, !17, i64 8, !17, i64 16}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"unz_file_info64_s", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !16, i64 48, !16, i64 56, !17, i64 64, !17, i64 72, !17, i64 80, !17, i64 88, !17, i64 96, !17, i64 104, !19, i64 112, !16, i64 136, !17, i64 144}
!19 = !{!"tm_unz_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!20 = !{!"unz_file_info64_internal_s", !16, i64 0, !16, i64 8}
!21 = !{!22, !10, i64 144}
!22 = !{!"", !6, i64 0, !23, i64 8, !16, i64 120, !17, i64 128, !16, i64 136, !10, i64 144, !16, i64 152, !16, i64 160, !17, i64 168, !17, i64 176, !16, i64 184, !16, i64 192, !13, i64 200, !6, i64 304, !17, i64 312, !16, i64 320, !10, i64 328}
!23 = !{!"z_stream_s", !6, i64 0, !10, i64 8, !17, i64 16, !6, i64 24, !10, i64 32, !17, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !17, i64 96, !17, i64 104}
!24 = !{!22, !16, i64 152}
!25 = !{!16, !16, i64 0}
!26 = !{!22, !6, i64 304}
!27 = !{!22, !16, i64 136}
!28 = !{!22, !6, i64 216}
!29 = !{!22, !6, i64 264}


; 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 @call_zseek64(ptr noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

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

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

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %7, i64 144
  %11 = load i32, ptr %10, align 8, !tbaa !19
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds i8, ptr %7, i64 152
  %14 = load i64, ptr %13, align 8, !tbaa !22
  %15 = sub i64 %12, %14
  %16 = icmp eq ptr %1, null
  br i1 %16, label %17, label %19

17:                                               ; preds = %9
  %18 = trunc i64 %15 to i32
  br label %42

19:                                               ; preds = %9
  %20 = zext i32 %2 to i64
  %21 = icmp ult i64 %15, %20
  %22 = trunc nuw i64 %15 to i32
  %.023 = select i1 %21, i32 %22, i32 %2
  %23 = icmp eq i32 %.023, 0
  br i1 %23, label %42, label %24

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %7, i64 200
  %26 = getelementptr inbounds i8, ptr %7, i64 304
  %27 = load ptr, ptr %26, align 8, !tbaa !23
  %28 = getelementptr inbounds i8, ptr %7, i64 136
  %29 = load i64, ptr %28, align 8, !tbaa !24
  %30 = add i64 %29, %14
  %31 = tail call i64 @call_zseek64(ptr noundef nonnull %25, ptr noundef %27, i64 noundef %30, i32 noundef 0) #2
  %.not = icmp eq i64 %31, 0
  br i1 %.not, label %32, label %42

32:                                               ; preds = %24
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 216
  %35 = load ptr, ptr %34, align 8, !tbaa !25
  %36 = getelementptr inbounds i8, ptr %33, i64 264
  %37 = load ptr, ptr %36, align 8, !tbaa !26
  %38 = getelementptr inbounds i8, ptr %33, i64 304
  %39 = load ptr, ptr %38, align 8, !tbaa !23
  %40 = zext i32 %.023 to i64
  %41 = tail call i64 %35(ptr noundef %37, ptr noundef %39, ptr noundef nonnull %1, i64 noundef %40) #2
  %.not28 = icmp eq i64 %41, %40
  %.023. = select i1 %.not28, i32 %.023, i32 -1
  br label %42

42:                                               ; preds = %32, %24, %19, %5, %3, %17
  %.0 = phi i32 [ %18, %17 ], [ -102, %3 ], [ -102, %5 ], [ 0, %19 ], [ -1, %24 ], [ %.023., %32 ]
  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 = { 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, !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, !17, i64 144}
!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}
!22 = !{!20, !13, i64 152}
!23 = !{!20, !9, i64 304}
!24 = !{!20, !13, i64 136}
!25 = !{!20, !9, i64 216}
!26 = !{!20, !9, i64 264}


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