; LLVM IR from fhanau/Efficient-Compression-Tool :: src/miniz (miniz)

; 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.mz_zip_archive_tag = type { i64, i64, i32, i32, i32, ptr, ptr }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_reader_init_file(ptr noundef, ptr noundef, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_reader_end(ptr noundef) #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_init_file(ptr noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_end(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_init_from_reader(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_add_mem_ex(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i16 noundef zeroext, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @mz_zip_writer_validate_archive_name(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_finalize_archive(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mz_zip_add_mem_to_archive_file_in_place(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i16 noundef zeroext %5, ptr noundef %6) #0 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i16, align 2
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %struct.mz_zip_archive_tag, align 8
  %19 = alloca %struct.stat, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store i64 %3, ptr %12, align 8, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i16 %5, ptr %14, align 2, !tbaa !11
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 48, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 144, ptr %19) #5
  call void @llvm.memset.p0.i64(ptr align 8 %18, i8 0, i64 48, i1 false)
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %40

24:                                               ; preds = %7
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %40

27:                                               ; preds = %24
  %28 = load i64, ptr %12, align 8, !tbaa !9
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %40

33:                                               ; preds = %30, %27
  %34 = load i16, ptr %14, align 2, !tbaa !11
  %35 = zext i16 %34 to i32
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %41

37:                                               ; preds = %33
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %37, %30, %24, %7
  store i32 0, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %103

41:                                               ; preds = %37, %33
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = call i32 @mz_zip_writer_validate_archive_name(ptr noundef %42)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 0, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %103

46:                                               ; preds = %41
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = call i32 @stat(ptr noundef %47, ptr noundef %19) #5
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %56

50:                                               ; preds = %46
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = call i32 @mz_zip_writer_init_file(ptr noundef %18, ptr noundef %51, i64 noundef 0)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 0, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %103

55:                                               ; preds = %50
  store i32 1, ptr %17, align 4, !tbaa !13
  br label %76

56:                                               ; preds = %46
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = call i32 @mz_zip_reader_init_file(ptr noundef %18, ptr noundef %57, i32 noundef 2048)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 0, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %103

61:                                               ; preds = %56
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = call i32 @mz_zip_reader_locate_file(ptr noundef %18, ptr noundef %62, i32 noundef 0)
  %64 = icmp ne i32 %63, -1
  br i1 %64, label %65, label %69

65:                                               ; preds = %61
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %66)
  %68 = call i32 @mz_zip_reader_end(ptr noundef %18)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %103

69:                                               ; preds = %61
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = call i32 @mz_zip_writer_init_from_reader(ptr noundef %18, ptr noundef %70)
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %75, label %73

73:                                               ; preds = %69
  %74 = call i32 @mz_zip_reader_end(ptr noundef %18)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %103

75:                                               ; preds = %69
  br label %76

76:                                               ; preds = %75, %55
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = load i64, ptr %12, align 8, !tbaa !9
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  %81 = load i16, ptr %14, align 2, !tbaa !11
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  %83 = call i32 @mz_zip_writer_add_mem_ex(ptr noundef %18, ptr noundef %77, ptr noundef %78, i64 noundef %79, ptr noundef %80, i16 noundef zeroext %81, ptr noundef %82)
  store i32 %83, ptr %16, align 4, !tbaa !13
  %84 = call i32 @mz_zip_writer_finalize_archive(ptr noundef %18)
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %87, label %86

86:                                               ; preds = %76
  store i32 0, ptr %16, align 4, !tbaa !13
  br label %87

87:                                               ; preds = %86, %76
  %88 = call i32 @mz_zip_writer_end(ptr noundef %18)
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  store i32 0, ptr %16, align 4, !tbaa !13
  br label %91

91:                                               ; preds = %90, %87
  %92 = load i32, ptr %16, align 4, !tbaa !13
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %101, label %94

94:                                               ; preds = %91
  %95 = load i32, ptr %17, align 4, !tbaa !13
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %101

97:                                               ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = call i32 @remove(ptr noundef %98) #5
  store i32 %99, ptr %21, align 4, !tbaa !13
  %100 = load i32, ptr %21, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  br label %101

101:                                              ; preds = %97, %94, %91
  %102 = load i32, ptr %16, align 4, !tbaa !13
  store i32 %102, ptr %8, align 4
  store i32 1, ptr %20, align 4
  br label %103

103:                                              ; preds = %101, %73, %65, %60, %54, %45, %40
  call void @llvm.lifetime.end.p0(i64 144, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  %104 = load i32, ptr %8, align 4
  ret i32 %104
}

; Function Attrs: nounwind
declare i32 @stat(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @mz_zip_reader_locate_file(ptr noundef, ptr noundef, i32 noundef) #0

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: nounwind
declare i32 @remove(ptr noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind "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 #4 = { "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 #5 = { 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 = !{!"short", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}


; 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.mz_zip_archive_tag = type { i64, i64, i32, i32, i32, ptr, ptr }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_reader_init_file(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #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: nounwind uwtable
declare dso_local i32 @mz_zip_reader_end(ptr noundef) 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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_init_file(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_end(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_init_from_reader(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_add_mem_ex(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i16 noundef zeroext, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @mz_zip_writer_validate_archive_name(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mz_zip_writer_finalize_archive(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mz_zip_add_mem_to_archive_file_in_place(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i16 noundef zeroext %5, ptr noundef %6) local_unnamed_addr #0 {
  %8 = alloca %struct.mz_zip_archive_tag, align 8
  %9 = alloca %struct.stat, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %9) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %8, i8 0, i64 48, i1 false)
  %10 = icmp ne ptr %0, null
  %11 = icmp ne ptr %1, null
  %or.cond = and i1 %10, %11
  br i1 %or.cond, label %12, label %43

12:                                               ; preds = %7
  %13 = icmp eq i64 %3, 0
  %14 = icmp ne ptr %2, null
  %or.cond3 = or i1 %14, %13
  br i1 %or.cond3, label %15, label %43

15:                                               ; preds = %12
  %16 = icmp eq i16 %5, 0
  %17 = icmp ne ptr %4, null
  %or.cond5 = or i1 %17, %16
  br i1 %or.cond5, label %18, label %43

18:                                               ; preds = %15
  %19 = tail call i32 @mz_zip_writer_validate_archive_name(ptr noundef nonnull %1)
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %43, label %20

20:                                               ; preds = %18
  %21 = call i32 @stat(ptr noundef nonnull %0, ptr noundef nonnull %9) #4
  %.not35 = icmp ne i32 %21, 0
  br i1 %.not35, label %22, label %24

22:                                               ; preds = %20
  %23 = call i32 @mz_zip_writer_init_file(ptr noundef nonnull %8, ptr noundef nonnull %0, i64 noundef 0)
  %.not39 = icmp eq i32 %23, 0
  br i1 %.not39, label %43, label %35

24:                                               ; preds = %20
  %25 = call i32 @mz_zip_reader_init_file(ptr noundef nonnull %8, ptr noundef nonnull %0, i32 noundef 2048)
  %.not36 = icmp eq i32 %25, 0
  br i1 %.not36, label %43, label %26

26:                                               ; preds = %24
  %27 = call i32 @mz_zip_reader_locate_file(ptr noundef nonnull %8, ptr noundef nonnull %1, i32 noundef 0)
  %.not37 = icmp eq i32 %27, -1
  br i1 %.not37, label %31, label %28

28:                                               ; preds = %26
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef nonnull %1)
  %30 = call i32 @mz_zip_reader_end(ptr noundef nonnull %8)
  br label %43

31:                                               ; preds = %26
  %32 = call i32 @mz_zip_writer_init_from_reader(ptr noundef nonnull %8, ptr noundef nonnull %0)
  %.not38 = icmp eq i32 %32, 0
  br i1 %.not38, label %33, label %35

33:                                               ; preds = %31
  %34 = call i32 @mz_zip_reader_end(ptr noundef nonnull %8)
  br label %43

35:                                               ; preds = %22, %31
  %36 = call i32 @mz_zip_writer_add_mem_ex(ptr noundef nonnull %8, ptr noundef nonnull %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i16 noundef zeroext %5, ptr noundef %6)
  %37 = call i32 @mz_zip_writer_finalize_archive(ptr noundef nonnull %8)
  %.not40 = icmp eq i32 %37, 0
  %38 = call i32 @mz_zip_writer_end(ptr noundef nonnull %8)
  %.not41 = icmp eq i32 %38, 0
  %39 = select i1 %.not41, i1 true, i1 %.not40
  %.1 = select i1 %39, i32 0, i32 %36
  %40 = icmp eq i32 %.1, 0
  %or.cond7 = and i1 %.not35, %40
  br i1 %or.cond7, label %41, label %43

41:                                               ; preds = %35
  %42 = call i32 @remove(ptr noundef nonnull %0) #4
  br label %43

43:                                               ; preds = %35, %41, %24, %22, %18, %7, %12, %15, %33, %28
  %.0 = phi i32 [ 0, %28 ], [ 0, %33 ], [ 0, %15 ], [ 0, %12 ], [ 0, %7 ], [ 0, %18 ], [ 0, %22 ], [ 0, %24 ], [ 0, %41 ], [ %.1, %35 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %8) #4
  ret i32 %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @stat(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @mz_zip_reader_locate_file(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @remove(ptr nocapture noundef readonly) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nofree nounwind "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 #4 = { 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)"}


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