; LLVM IR from 0xilis/libNeoAppleArchive :: libNeoAppleArchive (libNeoAppleArchive_internal)

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

@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [132 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [58 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

16:                                               ; preds = %94, %3
  %17 = load i32, ptr %7, align 4, !tbaa !11
  %18 = zext i32 %17 to i64
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = icmp ult i64 %18, %19
  br i1 %20, label %21, label %95

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !11
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  store ptr %25, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %26, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i32, ptr %27, align 4, !tbaa !11
  store i32 %28, ptr %10, align 4, !tbaa !11
  %29 = load i32, ptr %7, align 4, !tbaa !11
  %30 = load i32, ptr %10, align 4, !tbaa !11
  %31 = add i32 %29, %30
  %32 = zext i32 %31 to i64
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = icmp ugt i64 %32, %33
  br i1 %34, label %35, label %44

35:                                               ; preds = %21
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = load i32, ptr %10, align 4, !tbaa !11
  %38 = load i64, ptr %5, align 8, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.4, i32 noundef %37, i64 noundef %38) #4
  %40 = load i64, ptr %5, align 8, !tbaa !9
  %41 = trunc i64 %40 to i32
  %42 = load i32, ptr %7, align 4, !tbaa !11
  %43 = sub i32 %41, %42
  store i32 %43, ptr %10, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %35, %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 4
  store ptr %46, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load i32, ptr %10, align 4, !tbaa !11
  %49 = sub i32 %48, 4
  %50 = zext i32 %49 to i64
  %51 = call i64 @strnlen(ptr noundef %47, i64 noundef %50) #5
  store i64 %51, ptr %12, align 8, !tbaa !9
  %52 = load i32, ptr %10, align 4, !tbaa !11
  %53 = zext i32 %52 to i64
  %54 = load i64, ptr %12, align 8, !tbaa !9
  %55 = add i64 4, %54
  %56 = add i64 %55, 1
  %57 = icmp ult i64 %53, %56
  br i1 %57, label %58, label %65

58:                                               ; preds = %44
  %59 = load ptr, ptr @stderr, align 8, !tbaa !5
  %60 = load i64, ptr %12, align 8, !tbaa !9
  %61 = add i64 4, %60
  %62 = add i64 %61, 1
  %63 = load i32, ptr %10, align 4, !tbaa !11
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.5, i64 noundef %62, i32 noundef %63) #4
  store i32 1, ptr %13, align 4
  br label %92

65:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = load i64, ptr %12, align 8, !tbaa !9
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  %69 = getelementptr inbounds i8, ptr %68, i64 1
  store ptr %69, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %70 = load i32, ptr %10, align 4, !tbaa !11
  %71 = zext i32 %70 to i64
  %72 = load i64, ptr %12, align 8, !tbaa !9
  %73 = add i64 4, %72
  %74 = add i64 %73, 1
  %75 = sub i64 %71, %74
  store i64 %75, ptr %15, align 8, !tbaa !9
  %76 = load i64, ptr %15, align 8, !tbaa !9
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %84

78:                                               ; preds = %65
  %79 = load i32, ptr %6, align 4, !tbaa !11
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = load i64, ptr %15, align 8, !tbaa !9
  %83 = call i32 @fsetxattr(i32 noundef %79, ptr noundef %80, ptr noundef %81, i64 noundef %82, i32 noundef 0) #4
  br label %88

84:                                               ; preds = %65
  %85 = load i32, ptr %6, align 4, !tbaa !11
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = call i32 @fsetxattr(i32 noundef %85, ptr noundef %86, ptr noundef null, i64 noundef 0, i32 noundef 0) #4
  br label %88

88:                                               ; preds = %84, %78
  %89 = load i32, ptr %10, align 4, !tbaa !11
  %90 = load i32, ptr %7, align 4, !tbaa !11
  %91 = add i32 %90, %89
  store i32 %91, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  store i32 0, ptr %13, align 4
  br label %92

92:                                               ; preds = %88, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %93 = load i32, ptr %13, align 4
  switch i32 %93, label %96 [
    i32 0, label %94
  ]

94:                                               ; preds = %92
  br label %16, !llvm.loop !13

95:                                               ; preds = %16
  store i32 0, ptr %13, align 4
  br label %96

96:                                               ; preds = %95, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %97 = load i32, ptr %13, align 4
  switch i32 %97, label %99 [
    i32 0, label %98
    i32 1, label %98
  ]

98:                                               ; preds = %96, %96
  ret void

99:                                               ; preds = %96
  unreachable
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strnlen(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind
declare i32 @fsetxattr(i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [132 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [58 x i8], align 1

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

; Function Attrs: nounwind uwtable
define hidden void @internal_do_not_call_apply_xattr_blob_to_fd(ptr noundef %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not44 = icmp eq i64 %1, 0
  br i1 %.not44, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %4 = trunc nuw i64 %1 to i32
  br label %5

5:                                                ; preds = %.lr.ph, %33
  %6 = phi i64 [ 0, %.lr.ph ], [ %35, %33 ]
  %.043 = phi i32 [ 0, %.lr.ph ], [ %34, %33 ]
  %7 = getelementptr inbounds i8, ptr %0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = add i32 %8, %.043
  %10 = zext i32 %9 to i64
  %11 = icmp ugt i64 %10, %1
  br i1 %11, label %12, label %16

12:                                               ; preds = %5
  %13 = load ptr, ptr @stderr, align 8, !tbaa !9
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.4, i32 noundef %8, i64 noundef %1) #4
  %15 = sub i32 %4, %.043
  br label %16

16:                                               ; preds = %12, %5
  %.033 = phi i32 [ %15, %12 ], [ %8, %5 ]
  %17 = getelementptr inbounds i8, ptr %7, i64 4
  %18 = add i32 %.033, -4
  %19 = zext i32 %18 to i64
  %20 = tail call i64 @strnlen(ptr noundef nonnull %17, i64 noundef %19) #5
  %21 = zext i32 %.033 to i64
  %22 = add i64 %20, 5
  %.not41 = icmp ugt i64 %22, %21
  br i1 %.not41, label %.thread, label %25

.thread:                                          ; preds = %16
  %23 = load ptr, ptr @stderr, align 8, !tbaa !9
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.5, i64 noundef %22, i32 noundef %.033) #4
  br label %.loopexit

25:                                               ; preds = %16
  %.not = icmp eq i64 %22, %21
  br i1 %.not, label %31, label %26

26:                                               ; preds = %25
  %27 = sub nsw i64 %21, %22
  %28 = getelementptr inbounds i8, ptr %17, i64 %20
  %29 = getelementptr inbounds i8, ptr %28, i64 1
  %30 = tail call i32 @fsetxattr(i32 noundef %2, ptr noundef nonnull %17, ptr noundef nonnull %29, i64 noundef %27, i32 noundef 0) #6
  br label %33

31:                                               ; preds = %25
  %32 = tail call i32 @fsetxattr(i32 noundef %2, ptr noundef nonnull %17, ptr noundef null, i64 noundef 0, i32 noundef 0) #6
  br label %33

33:                                               ; preds = %26, %31
  %34 = add i32 %.033, %.043
  %35 = zext i32 %34 to i64
  %36 = icmp ult i64 %35, %1
  br i1 %36, label %5, label %.loopexit

.loopexit:                                        ; preds = %33, %3, %.thread
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strnlen(ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @fsetxattr(i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { 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 #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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 "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 = { cold nounwind }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass