; 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
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data = external hidden unnamed_addr constant [67 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 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: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nounwind uwtable
define hidden i64 @internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data(ptr noundef %0, i32 noundef %1) #3 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %18, label %15

15:                                               ; preds = %2
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.9, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #5
  call void @exit(i32 noundef 1) #6
  unreachable

18:                                               ; preds = %2
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp sge i32 %19, 0
  br i1 %20, label %24, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.9, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #5
  call void @exit(i32 noundef 1) #6
  unreachable

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.neo_aa_header_impl, ptr %25, i32 0, i32 6
  %27 = load i64, ptr %26, align 8, !tbaa !11
  store i64 %27, ptr %6, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.neo_aa_header_impl, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !15
  store i32 %30, ptr %7, align 4, !tbaa !9
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %36, label %33

33:                                               ; preds = %24
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str.9, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #5
  call void @exit(i32 noundef 1) #6
  unreachable

36:                                               ; preds = %24
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  store i64 6, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %96

40:                                               ; preds = %36
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %47, label %44

44:                                               ; preds = %40
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.9, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #5
  call void @exit(i32 noundef 1) #6
  unreachable

47:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 6, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %88, %47
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  store i32 2, ptr %8, align 4
  br label %91

53:                                               ; preds = %48
  %54 = load i64, ptr %9, align 8, !tbaa !14
  %55 = load i64, ptr %6, align 8, !tbaa !14
  %56 = icmp uge i64 %54, %55
  br i1 %56, label %57, label %60

57:                                               ; preds = %53
  %58 = load ptr, ptr @stderr, align 8, !tbaa !5
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.2, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data, ptr noundef @.str.10) #5
  store i64 0, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %91

60:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = call i64 @neo_aa_header_get_field_size(ptr noundef %61, i32 noundef %62)
  store i64 %63, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = call i32 @neo_aa_header_get_field_type(ptr noundef %64, i32 noundef %65)
  store i32 %66, ptr %12, align 4, !tbaa !9
  %67 = load i64, ptr %9, align 8, !tbaa !14
  %68 = add i64 %67, 4
  store i64 %68, ptr %9, align 8, !tbaa !14
  %69 = load i32, ptr %12, align 4, !tbaa !9
  %70 = icmp eq i32 %69, 2
  br i1 %70, label %71, label %74

71:                                               ; preds = %60
  %72 = load i64, ptr %9, align 8, !tbaa !14
  %73 = add i64 %72, 2
  store i64 %73, ptr %9, align 8, !tbaa !14
  br label %74

74:                                               ; preds = %71, %60
  %75 = load i64, ptr %11, align 8, !tbaa !14
  %76 = load i64, ptr %9, align 8, !tbaa !14
  %77 = add i64 %76, %75
  store i64 %77, ptr %9, align 8, !tbaa !14
  %78 = load i64, ptr %9, align 8, !tbaa !14
  %79 = load i64, ptr %6, align 8, !tbaa !14
  %80 = icmp ugt i64 %78, %79
  br i1 %80, label %81, label %84

81:                                               ; preds = %74
  %82 = load ptr, ptr @stderr, align 8, !tbaa !5
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef @.str.2, ptr noundef @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data, ptr noundef @.str.10) #5
  store i64 0, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %85

84:                                               ; preds = %74
  store i32 0, ptr %8, align 4
  br label %85

85:                                               ; preds = %84, %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %86 = load i32, ptr %8, align 4
  switch i32 %86, label %91 [
    i32 0, label %87
  ]

87:                                               ; preds = %85
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %10, align 4, !tbaa !9
  br label %48, !llvm.loop !16

91:                                               ; preds = %85, %57, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %92 = load i32, ptr %8, align 4
  switch i32 %92, label %95 [
    i32 2, label %93
  ]

93:                                               ; preds = %91
  %94 = load i64, ptr %9, align 8, !tbaa !14
  store i64 %94, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %95

95:                                               ; preds = %93, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %96

96:                                               ; preds = %95, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %97 = load i64, ptr %3, align 8
  ret i64 %97
}

declare i64 @neo_aa_header_get_field_size(ptr noundef, i32 noundef) #4

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

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 = { noreturn 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 #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 = { "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 }
attributes #6 = { noreturn 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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 48}
!12 = !{!"neo_aa_header_impl", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !13, i64 48, !6, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data = external hidden unnamed_addr constant [67 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 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: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define hidden i64 @internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %6

3:                                                ; preds = %2
  %4 = load ptr, ptr @stderr, align 8, !tbaa !5
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.9, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

6:                                                ; preds = %2
  %7 = icmp sgt i32 %1, -1
  br i1 %7, label %11, label %8

8:                                                ; preds = %6
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.9, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = load i32, ptr %0, align 8, !tbaa !13
  %.not38 = icmp eq i32 %14, 0
  br i1 %.not38, label %15, label %18

15:                                               ; preds = %11
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.9, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

18:                                               ; preds = %11
  %.not39 = icmp eq i32 %1, 0
  br i1 %.not39, label %.loopexit, label %19

19:                                               ; preds = %18
  %20 = icmp sgt i32 %14, %1
  br i1 %20, label %.lr.ph, label %21

21:                                               ; preds = %19
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.9, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

24:                                               ; preds = %.critedge
  %25 = add nuw nsw i32 %.03048, 1
  %exitcond.not = icmp eq i32 %25, %1
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !14

.lr.ph:                                           ; preds = %19, %24
  %.03048 = phi i32 [ %25, %24 ], [ 0, %19 ]
  %.03147 = phi i64 [ %29, %24 ], [ 6, %19 ]
  %.not40 = icmp ult i64 %.03147, %13
  br i1 %.not40, label %.critedge, label %.loopexit.sink.split

.critedge:                                        ; preds = %.lr.ph
  %26 = tail call i64 @neo_aa_header_get_field_size(ptr noundef nonnull %0, i32 noundef %.03048) #6
  %27 = tail call i32 @neo_aa_header_get_field_type(ptr noundef nonnull %0, i32 noundef %.03048) #6
  %28 = icmp eq i32 %27, 2
  %spec.select.v = select i1 %28, i64 6, i64 4
  %spec.select = add i64 %26, %.03147
  %29 = add i64 %spec.select, %spec.select.v
  %.not41 = icmp ugt i64 %29, %13
  br i1 %.not41, label %.loopexit.sink.split, label %24

.loopexit.sink.split:                             ; preds = %.critedge, %.lr.ph
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.2, ptr noundef nonnull @__FUNCTION__.internal_do_not_call_neo_aa_archive_header_key_pos_in_encoded_data, ptr noundef nonnull @.str.10) #4
  br label %.loopexit

.loopexit:                                        ; preds = %24, %.loopexit.sink.split, %18
  %.4 = phi i64 [ 6, %18 ], [ 0, %.loopexit.sink.split ], [ %29, %24 ]
  ret i64 %.4
}

declare i64 @neo_aa_header_get_field_size(ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @neo_aa_header_get_field_type(ptr 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 = { noreturn 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 = { "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 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 48}
!10 = !{!"neo_aa_header_impl", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !6, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !11, 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,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass