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

; 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 @unzGetGlobalComment(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %11, ptr %9, align 8, !tbaa !9
  %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 %10, align 4
  br label %86

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %16, ptr %8, align 8, !tbaa !5
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.unz64_s, ptr %18, i32 0, i32 3
  %20 = getelementptr inbounds %struct.unz_global_info64_s, ptr %19, i32 0, i32 2
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = icmp ugt i64 %17, %21
  br i1 %22, label %23, label %28

23:                                               ; preds = %15
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.unz64_s, ptr %24, i32 0, i32 3
  %26 = getelementptr inbounds %struct.unz_global_info64_s, ptr %25, i32 0, i32 2
  %27 = load i64, ptr %26, align 8, !tbaa !11
  store i64 %27, ptr %9, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %23, %15
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.unz64_s, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.unz64_s, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !21
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.unz64_s, ptr %34, i32 0, i32 8
  %36 = load i64, ptr %35, align 8, !tbaa !22
  %37 = add i64 %36, 22
  %38 = call i64 @call_zseek64(ptr noundef %30, ptr noundef %33, i64 noundef %37, i32 noundef 0)
  %39 = icmp ne i64 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %28
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %86

41:                                               ; preds = %28
  %42 = load i64, ptr %9, align 8, !tbaa !9
  %43 = icmp ugt i64 %42, 0
  br i1 %43, label %44, label %66

44:                                               ; preds = %41
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %45, align 1, !tbaa !23
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.unz64_s, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.zlib_filefunc64_32_def_s, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.zlib_filefunc64_def_s, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !24
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.unz64_s, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.zlib_filefunc64_32_def_s, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.zlib_filefunc64_def_s, ptr %53, i32 0, i32 8
  %55 = load ptr, ptr %54, align 8, !tbaa !25
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.unz64_s, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !21
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = call i64 %50(ptr noundef %55, ptr noundef %58, ptr noundef %59, i64 noundef %60)
  %62 = load i64, ptr %9, align 8, !tbaa !9
  %63 = icmp ne i64 %61, %62
  br i1 %63, label %64, label %65

64:                                               ; preds = %44
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %86

65:                                               ; preds = %44
  br label %66

66:                                               ; preds = %65, %41
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %83

69:                                               ; preds = %66
  %70 = load i64, ptr %7, align 8, !tbaa !9
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.unz64_s, ptr %71, i32 0, i32 3
  %73 = getelementptr inbounds %struct.unz_global_info64_s, ptr %72, i32 0, i32 2
  %74 = load i64, ptr %73, align 8, !tbaa !11
  %75 = icmp ugt i64 %70, %74
  br i1 %75, label %76, label %83

76:                                               ; preds = %69
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.unz64_s, ptr %78, i32 0, i32 3
  %80 = getelementptr inbounds %struct.unz_global_info64_s, ptr %79, i32 0, i32 2
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = getelementptr inbounds i8, ptr %77, i64 %81
  store i8 0, ptr %82, align 1, !tbaa !23
  br label %83

83:                                               ; preds = %76, %69, %66
  %84 = load i64, ptr %9, align 8, !tbaa !9
  %85 = trunc i64 %84 to i32
  store i32 %85, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %86

86:                                               ; preds = %83, %64, %40, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %87 = load i32, ptr %4, align 4
  ret i32 %87
}

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

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 = { "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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 136}
!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, !10, i64 184, !16, i64 192, !16, i64 200, !17, i64 208, !20, i64 360, !6, i64 376, !19, 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, !10, i64 8, !10, i64 16}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"unz_file_info64_s", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !16, i64 48, !16, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !18, i64 112, !16, i64 136, !10, i64 144}
!18 = !{!"tm_unz_s", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12, !19, i64 16, !19, i64 20}
!19 = !{!"int", !7, i64 0}
!20 = !{!"unz_file_info64_internal_s", !16, i64 0, !16, i64 8}
!21 = !{!12, !6, i64 112}
!22 = !{!12, !16, i64 176}
!23 = !{!7, !7, i64 0}
!24 = !{!12, !6, i64 16}
!25 = !{!12, !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"

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

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 136
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %spec.select = tail call i64 @llvm.umin.i64(i64 %7, i64 %2)
  %8 = getelementptr inbounds i8, ptr %0, i64 112
  %9 = load ptr, ptr %8, align 8, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %0, i64 176
  %11 = load i64, ptr %10, align 8, !tbaa !20
  %12 = add i64 %11, 22
  %13 = tail call i64 @call_zseek64(ptr noundef nonnull %0, ptr noundef %9, i64 noundef %12, i32 noundef 0) #3
  %.not = icmp eq i64 %13, 0
  br i1 %.not, label %14, label %29

14:                                               ; preds = %5
  %.not29 = icmp eq i64 %spec.select, 0
  br i1 %.not29, label %22, label %15

15:                                               ; preds = %14
  store i8 0, ptr %1, align 1, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !22
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  %19 = load ptr, ptr %18, align 8, !tbaa !23
  %20 = load ptr, ptr %8, align 8, !tbaa !19
  %21 = tail call i64 %17(ptr noundef %19, ptr noundef %20, ptr noundef nonnull %1, i64 noundef %spec.select) #3
  %.not30 = icmp eq i64 %21, %spec.select
  br i1 %.not30, label %.thread, label %29

22:                                               ; preds = %14
  %.not31 = icmp eq ptr %1, null
  br i1 %.not31, label %27, label %.thread

.thread:                                          ; preds = %15, %22
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = icmp ult i64 %23, %2
  br i1 %24, label %25, label %27

25:                                               ; preds = %.thread
  %26 = getelementptr inbounds i8, ptr %1, i64 %23
  store i8 0, ptr %26, align 1, !tbaa !21
  br label %27

27:                                               ; preds = %25, %.thread, %22
  %28 = trunc i64 %spec.select to i32
  br label %29

29:                                               ; preds = %15, %5, %3, %27
  %.023 = phi i32 [ %28, %27 ], [ -102, %3 ], [ -1, %5 ], [ -1, %15 ]
  ret i32 %.023
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !14, i64 136}
!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 = !{!6, !9, i64 112}
!20 = !{!6, !13, i64 176}
!21 = !{!10, !10, i64 0}
!22 = !{!6, !9, i64 16}
!23 = !{!6, !9, i64 64}


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