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

%struct.neo_aa_header_impl = type { i32, ptr, ptr, ptr, ptr, ptr, i64, ptr }

@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data = external hidden unnamed_addr constant [76 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [30 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

declare i32 @neo_aa_header_get_field_type(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define hidden i64 @internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data(i64 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i64 %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %14, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %15 = load ptr, ptr %6, align 8, !tbaa !9
  %16 = getelementptr inbounds i32, ptr %15, i64 0
  %17 = load i32, ptr %16, align 4, !tbaa !11
  store i32 %17, ptr %7, align 4, !tbaa !11
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = icmp ne i32 %18, 825246017
  br i1 %19, label %20, label %26

20:                                               ; preds = %2
  %21 = load i32, ptr %7, align 4, !tbaa !11
  %22 = icmp ne i32 %21, 826360153
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !9
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.2, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data, ptr noundef @.str.11) #4
  store i64 0, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %77

26:                                               ; preds = %20, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = getelementptr inbounds i32, ptr %27, i64 1
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = and i32 %29, 65535
  %31 = zext i32 %30 to i64
  store i64 %31, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %32 = load i64, ptr %9, align 8, !tbaa !5
  store i64 %32, ptr %10, align 8, !tbaa !5
  %33 = load i64, ptr %4, align 8, !tbaa !5
  %34 = load i64, ptr %9, align 8, !tbaa !5
  %35 = icmp ult i64 %33, %34
  br i1 %35, label %36, label %39

36:                                               ; preds = %26
  %37 = load ptr, ptr @stderr, align 8, !tbaa !9
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.2, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data, ptr noundef @.str.12) #4
  store i64 0, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %76

39:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %40 = load i64, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = call ptr @neo_aa_header_create_with_encoded_data(i64 noundef %40, ptr noundef %41)
  store ptr %42, ptr %11, align 8, !tbaa !9
  %43 = load ptr, ptr %11, align 8, !tbaa !9
  %44 = icmp ne ptr %43, null
  br i1 %44, label %48, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr @stderr, align 8, !tbaa !9
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.2, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data, ptr noundef @.str.13) #4
  store i64 0, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %75

48:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %49 = load ptr, ptr %11, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.neo_aa_header_impl, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !13
  store i32 %51, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %52

52:                                               ; preds = %69, %48
  %53 = load i32, ptr %13, align 4, !tbaa !11
  %54 = load i32, ptr %12, align 4, !tbaa !11
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %72

57:                                               ; preds = %52
  %58 = load ptr, ptr %11, align 8, !tbaa !9
  %59 = load i32, ptr %13, align 4, !tbaa !11
  %60 = call i32 @neo_aa_header_get_field_type(ptr noundef %58, i32 noundef %59)
  %61 = icmp eq i32 %60, 5
  br i1 %61, label %62, label %68

62:                                               ; preds = %57
  %63 = load ptr, ptr %11, align 8, !tbaa !9
  %64 = load i32, ptr %13, align 4, !tbaa !11
  %65 = call i64 @neo_aa_header_get_field_key_uint(ptr noundef %63, i32 noundef %64)
  %66 = load i64, ptr %10, align 8, !tbaa !5
  %67 = add i64 %66, %65
  store i64 %67, ptr %10, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %62, %57
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %13, align 4, !tbaa !11
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %13, align 4, !tbaa !11
  br label %52, !llvm.loop !15

72:                                               ; preds = %56
  %73 = load ptr, ptr %11, align 8, !tbaa !9
  call void @neo_aa_header_destroy_nozero(ptr noundef %73)
  %74 = load i64, ptr %10, align 8, !tbaa !5
  store i64 %74, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %75

75:                                               ; preds = %72, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %76

76:                                               ; preds = %75, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %77

77:                                               ; preds = %76, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %78 = load i64, ptr %3, align 8
  ret i64 %78
}

declare ptr @neo_aa_header_create_with_encoded_data(i64 noundef, ptr noundef) #2

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

declare void @neo_aa_header_destroy_nozero(ptr noundef) #2

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 = { "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 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 #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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !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}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"neo_aa_header_impl", !12, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !6, i64 48, !10, i64 56}
!15 = distinct !{!15, !16}
!16 = !{!"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.2 = external hidden unnamed_addr constant [7 x i8], align 1
@__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data = external hidden unnamed_addr constant [76 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [30 x i8], align 1

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

declare i32 @neo_aa_header_get_field_type(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define hidden i64 @internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data(i64 noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = load i32, ptr %1, align 4, !tbaa !5
  switch i32 %3, label %4 [
    i32 826360153, label %7
    i32 825246017, label %7
  ]

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !9
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str.2, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data, ptr noundef nonnull @.str.11) #3
  br label %31

7:                                                ; preds = %2, %2
  %8 = getelementptr inbounds i8, ptr %1, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = and i32 %9, 65535
  %11 = zext nneg i32 %10 to i64
  %12 = icmp ugt i64 %11, %0
  br i1 %12, label %13, label %16

13:                                               ; preds = %7
  %14 = load ptr, ptr @stderr, align 8, !tbaa !9
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.2, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data, ptr noundef nonnull @.str.12) #3
  br label %31

16:                                               ; preds = %7
  %17 = tail call ptr @neo_aa_header_create_with_encoded_data(i64 noundef %11, ptr noundef nonnull %1) #4
  %.not = icmp eq ptr %17, null
  br i1 %.not, label %18, label %21

18:                                               ; preds = %16
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.2, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_item_encoded_data_size_for_encoded_data, ptr noundef nonnull @.str.13) #3
  br label %31

21:                                               ; preds = %16
  %22 = load i32, ptr %17, align 8, !tbaa !11
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %29, %21
  %.024.lcssa = phi i64 [ %11, %21 ], [ %.125, %29 ]
  tail call void @neo_aa_header_destroy_nozero(ptr noundef nonnull %17) #4
  br label %31

.lr.ph:                                           ; preds = %21, %29
  %.029 = phi i32 [ %30, %29 ], [ 0, %21 ]
  %.02428 = phi i64 [ %.125, %29 ], [ %11, %21 ]
  %24 = tail call i32 @neo_aa_header_get_field_type(ptr noundef nonnull %17, i32 noundef %.029) #4
  %25 = icmp eq i32 %24, 5
  br i1 %25, label %26, label %29

26:                                               ; preds = %.lr.ph
  %27 = tail call i64 @neo_aa_header_get_field_key_uint(ptr noundef nonnull %17, i32 noundef %.029) #4
  %28 = add i64 %27, %.02428
  br label %29

29:                                               ; preds = %.lr.ph, %26
  %.125 = phi i64 [ %28, %26 ], [ %.02428, %.lr.ph ]
  %30 = add nuw nsw i32 %.029, 1
  %exitcond.not = icmp eq i32 %30, %22
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

31:                                               ; preds = %13, %._crit_edge, %18, %4
  %.2 = phi i64 [ 0, %4 ], [ 0, %13 ], [ %.024.lcssa, %._crit_edge ], [ 0, %18 ]
  ret i64 %.2
}

declare ptr @neo_aa_header_create_with_encoded_data(i64 noundef, ptr noundef) local_unnamed_addr #1

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

declare void @neo_aa_header_destroy_nozero(ptr noundef) local_unnamed_addr #1

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 = { "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 = { cold nounwind }
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)"}
!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}
!11 = !{!12, !6, i64 0}
!12 = !{!"neo_aa_header_impl", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !13, i64 48, !10, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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