; LLVM IR from facebook/redex :: libresource/ResourceTypes.ll (ZNK7android15ResTable_config24isLocaleMoreSpecificThanERKS0_)

; 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.android::ResTable_config" = type { i32, %union.anon, %union.anon.0, %union.anon.2, %union.anon.4, %union.anon.6, %union.anon.8, %union.anon.10, %union.anon.12, [4 x i8], [8 x i8], %union.anon.14, i8, [8 x i8] }
%union.anon = type { i32 }
%union.anon.0 = type { i32 }
%union.anon.2 = type { i32 }
%union.anon.4 = type { i32 }
%union.anon.6 = type { i32 }
%union.anon.8 = type { i32 }
%union.anon.10 = type { i32 }
%union.anon.12 = type { i32 }
%union.anon.14 = type { i32 }
%struct.anon.1 = type { [2 x i8], [2 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7android15ResTable_config24isLocaleMoreSpecificThanERKS0_(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr noundef nonnull align 4 dereferenceable(64) %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = getelementptr inbounds %"struct.android::ResTable_config", ptr %6, i32 0, i32 2
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %15, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.android::ResTable_config", ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %74

15:                                               ; preds = %10, %2
  %16 = getelementptr inbounds %"struct.android::ResTable_config", ptr %6, i32 0, i32 2
  %17 = getelementptr inbounds %struct.anon.1, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds [2 x i8], ptr %17, i64 0, i64 0
  %19 = load i8, ptr %18, align 4, !tbaa !9
  %20 = sext i8 %19 to i32
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.android::ResTable_config", ptr %21, i32 0, i32 2
  %23 = getelementptr inbounds %struct.anon.1, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [2 x i8], ptr %23, i64 0, i64 0
  %25 = load i8, ptr %24, align 4, !tbaa !9
  %26 = sext i8 %25 to i32
  %27 = icmp ne i32 %20, %26
  br i1 %27, label %28, label %44

28:                                               ; preds = %15
  %29 = getelementptr inbounds %"struct.android::ResTable_config", ptr %6, i32 0, i32 2
  %30 = getelementptr inbounds %struct.anon.1, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds [2 x i8], ptr %30, i64 0, i64 0
  %32 = load i8, ptr %31, align 4, !tbaa !9
  %33 = icmp ne i8 %32, 0
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i32 -1, ptr %3, align 4
  br label %79

35:                                               ; preds = %28
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.android::ResTable_config", ptr %36, i32 0, i32 2
  %38 = getelementptr inbounds %struct.anon.1, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds [2 x i8], ptr %38, i64 0, i64 0
  %40 = load i8, ptr %39, align 4, !tbaa !9
  %41 = icmp ne i8 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %35
  store i32 1, ptr %3, align 4
  br label %79

43:                                               ; preds = %35
  br label %44

44:                                               ; preds = %43, %15
  %45 = getelementptr inbounds %"struct.android::ResTable_config", ptr %6, i32 0, i32 2
  %46 = getelementptr inbounds %struct.anon.1, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds [2 x i8], ptr %46, i64 0, i64 0
  %48 = load i8, ptr %47, align 2, !tbaa !9
  %49 = sext i8 %48 to i32
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.android::ResTable_config", ptr %50, i32 0, i32 2
  %52 = getelementptr inbounds %struct.anon.1, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds [2 x i8], ptr %52, i64 0, i64 0
  %54 = load i8, ptr %53, align 2, !tbaa !9
  %55 = sext i8 %54 to i32
  %56 = icmp ne i32 %49, %55
  br i1 %56, label %57, label %73

57:                                               ; preds = %44
  %58 = getelementptr inbounds %"struct.android::ResTable_config", ptr %6, i32 0, i32 2
  %59 = getelementptr inbounds %struct.anon.1, ptr %58, i32 0, i32 1
  %60 = getelementptr inbounds [2 x i8], ptr %59, i64 0, i64 0
  %61 = load i8, ptr %60, align 2, !tbaa !9
  %62 = icmp ne i8 %61, 0
  br i1 %62, label %64, label %63

63:                                               ; preds = %57
  store i32 -1, ptr %3, align 4
  br label %79

64:                                               ; preds = %57
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.android::ResTable_config", ptr %65, i32 0, i32 2
  %67 = getelementptr inbounds %struct.anon.1, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds [2 x i8], ptr %67, i64 0, i64 0
  %69 = load i8, ptr %68, align 2, !tbaa !9
  %70 = icmp ne i8 %69, 0
  br i1 %70, label %72, label %71

71:                                               ; preds = %64
  store i32 1, ptr %3, align 4
  br label %79

72:                                               ; preds = %64
  br label %73

73:                                               ; preds = %72, %44
  br label %74

74:                                               ; preds = %73, %10
  %75 = call noundef i32 @_ZNK7android15ResTable_config26getImportanceScoreOfLocaleEv(ptr noundef nonnull align 4 dereferenceable(64) %6)
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = call noundef i32 @_ZNK7android15ResTable_config26getImportanceScoreOfLocaleEv(ptr noundef nonnull align 4 dereferenceable(64) %76)
  %78 = sub nsw i32 %75, %77
  store i32 %78, ptr %3, align 4
  br label %79

79:                                               ; preds = %74, %71, %63, %42, %34
  %80 = load i32, ptr %3, align 4
  ret i32 %80
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7android15ResTable_config26getImportanceScoreOfLocaleEv(ptr noundef nonnull align 4 dereferenceable(64)) #1 align 2

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK7android15ResTable_config24isLocaleMoreSpecificThanERKS0_(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr noundef nonnull align 4 dereferenceable(64) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 4
  %.not = icmp eq i32 %4, 0
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i32, ptr %5, align 4
  %.not7 = icmp eq i32 %6, 0
  %or.cond = select i1 %.not, i1 %.not7, i1 false
  %7 = trunc i32 %4 to i8
  %8 = trunc i32 %6 to i8
  %9 = lshr i32 %4, 16
  %10 = trunc i32 %9 to i8
  %11 = lshr i32 %6, 16
  %12 = trunc i32 %11 to i8
  br i1 %or.cond, label %19, label %13

13:                                               ; preds = %2
  %.not8 = icmp eq i8 %7, %8
  br i1 %.not8, label %16, label %14

14:                                               ; preds = %13
  %.not9 = icmp eq i8 %7, 0
  br i1 %.not9, label %23, label %15

15:                                               ; preds = %14
  %.not10 = icmp eq i8 %8, 0
  br i1 %.not10, label %23, label %16

16:                                               ; preds = %15, %13
  %.not11 = icmp eq i8 %10, %12
  br i1 %.not11, label %19, label %17

17:                                               ; preds = %16
  %.not12 = icmp eq i8 %10, 0
  br i1 %.not12, label %23, label %18

18:                                               ; preds = %17
  %.not13 = icmp eq i8 %12, 0
  br i1 %.not13, label %23, label %19

19:                                               ; preds = %2, %16, %18
  %20 = tail call noundef i32 @_ZNK7android15ResTable_config26getImportanceScoreOfLocaleEv(ptr noundef nonnull align 4 dereferenceable(64) %0)
  %21 = tail call noundef i32 @_ZNK7android15ResTable_config26getImportanceScoreOfLocaleEv(ptr noundef nonnull align 4 dereferenceable(64) %1)
  %22 = sub nsw i32 %20, %21
  br label %23

23:                                               ; preds = %18, %17, %15, %14, %19
  %.0 = phi i32 [ %22, %19 ], [ -1, %14 ], [ 1, %15 ], [ -1, %17 ], [ 1, %18 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7android15ResTable_config26getImportanceScoreOfLocaleEv(ptr noundef nonnull align 4 dereferenceable(64)) local_unnamed_addr #1 align 2

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass