; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @unz64local_GetCurrentFileInfoInternal(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #2

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

23:                                               ; preds = %8
  store i32 -102, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %62

24:                                               ; preds = %8
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %25, ptr %19, align 8, !tbaa !5
  %26 = load ptr, ptr %19, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.unz64_s, ptr %26, i32 0, i32 11
  %28 = load i64, ptr %27, align 8, !tbaa !13
  %29 = load ptr, ptr %19, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.unz64_s, ptr %29, i32 0, i32 6
  store i64 %28, ptr %30, align 8, !tbaa !22
  %31 = load ptr, ptr %19, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.unz64_s, ptr %31, i32 0, i32 5
  store i64 0, ptr %32, align 8, !tbaa !23
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = load ptr, ptr %19, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.unz64_s, ptr %34, i32 0, i32 12
  %36 = load ptr, ptr %19, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.unz64_s, ptr %36, i32 0, i32 13
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = load i64, ptr %13, align 8, !tbaa !9
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = load i64, ptr %15, align 8, !tbaa !9
  %42 = load ptr, ptr %16, align 8, !tbaa !5
  %43 = load i64, ptr %17, align 8, !tbaa !9
  %44 = call i32 @unz64local_GetCurrentFileInfoInternal(ptr noundef %33, ptr noundef %35, ptr noundef %37, ptr noundef %38, i64 noundef %39, ptr noundef %40, i64 noundef %41, ptr noundef %42, i64 noundef %43)
  store i32 %44, ptr %18, align 4, !tbaa !11
  %45 = load i32, ptr %18, align 4, !tbaa !11
  %46 = icmp eq i32 %45, 0
  %47 = zext i1 %46 to i32
  %48 = sext i32 %47 to i64
  %49 = load ptr, ptr %19, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.unz64_s, ptr %49, i32 0, i32 7
  store i64 %48, ptr %50, align 8, !tbaa !24
  %51 = load i32, ptr %18, align 4, !tbaa !11
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %60

53:                                               ; preds = %24
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = load ptr, ptr %19, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.unz64_s, ptr %58, i32 0, i32 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %57, ptr align 8 %59, i64 152, i1 false)
  br label %60

60:                                               ; preds = %56, %53, %24
  %61 = load i32, ptr %18, align 4, !tbaa !11
  store i32 %61, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %62

62:                                               ; preds = %60, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %63 = load i32, ptr %9, align 4
  ret i32 %63
}

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


; 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 nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @unz64local_GetCurrentFileInfoInternal(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @unzGoToFirstFile2(ptr noundef %0, ptr noundef writeonly %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7) local_unnamed_addr #1 {
  %9 = icmp eq ptr %0, null
  br i1 %9, label %23, label %10

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 200
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 160
  store i64 %12, ptr %13, align 8, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %0, i64 152
  store i64 0, ptr %14, align 8, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %0, i64 208
  %16 = getelementptr inbounds i8, ptr %0, i64 360
  %17 = tail call i32 @unz64local_GetCurrentFileInfoInternal(ptr noundef nonnull %0, ptr noundef nonnull %15, ptr noundef nonnull %16, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7)
  %18 = icmp eq i32 %17, 0
  %19 = zext i1 %18 to i64
  %20 = getelementptr inbounds i8, ptr %0, i64 168
  store i64 %19, ptr %20, align 8, !tbaa !21
  %21 = icmp ne ptr %1, null
  %or.cond = and i1 %21, %18
  br i1 %or.cond, label %22, label %23

22:                                               ; preds = %10
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(152) %1, ptr noundef nonnull align 8 dereferenceable(152) %15, i64 152, i1 false)
  br label %23

23:                                               ; preds = %10, %22, %8
  %.0 = phi i32 [ -102, %8 ], [ 0, %22 ], [ %17, %10 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree 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" }

!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, !13, i64 200}
!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, !13, i64 160}
!20 = !{!6, !13, i64 152}
!21 = !{!6, !13, i64 168}


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