; LLVM IR from facebook/redex :: libresource/Visitor.ll (ZN4arsc14XmlFileVisitor10visit_nodeEPN7android15ResXMLTree_nodeE)

; 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::ResXMLTree_node" = type { %"struct.android::ResChunk_header", i32, %"struct.android::ResStringPool_ref" }
%"struct.android::ResChunk_header" = type { i16, i16, i32 }
%"struct.android::ResStringPool_ref" = type { i32 }

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4arsc14XmlFileVisitor10visit_nodeEPN7android15ResXMLTree_nodeE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.android::ResXMLTree_node", ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %"struct.android::ResChunk_header", ptr %10, i32 0, i32 0
  %12 = load i16, ptr %11, align 4, !tbaa !9
  store i16 %12, ptr %6, align 2, !tbaa !15
  br label %13

13:                                               ; preds = %2
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.android::ResXMLTree_node", ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %8, align 8, !tbaa !16
  %19 = getelementptr inbounds ptr, ptr %18, i64 13
  %20 = load ptr, ptr %19, align 8
  %21 = call noundef zeroext i1 %20(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef %17)
  %22 = load i16, ptr %6, align 2, !tbaa !15
  %23 = zext i16 %22 to i32
  %24 = icmp eq i32 %23, 256
  br i1 %24, label %25, label %34

25:                                               ; preds = %15
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.android::ResXMLTree_node", ptr %27, i32 0, i32 0
  %29 = call noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef %28)
  %30 = load ptr, ptr %8, align 8, !tbaa !16
  %31 = getelementptr inbounds ptr, ptr %30, i64 6
  %32 = load ptr, ptr %31, align 8
  %33 = call noundef zeroext i1 %32(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef %26, ptr noundef %29)
  store i1 %33, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

34:                                               ; preds = %15
  %35 = load i16, ptr %6, align 2, !tbaa !15
  %36 = zext i16 %35 to i32
  %37 = icmp eq i32 %36, 257
  br i1 %37, label %38, label %47

38:                                               ; preds = %34
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.android::ResXMLTree_node", ptr %40, i32 0, i32 0
  %42 = call noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef %41)
  %43 = load ptr, ptr %8, align 8, !tbaa !16
  %44 = getelementptr inbounds ptr, ptr %43, i64 7
  %45 = load ptr, ptr %44, align 8
  %46 = call noundef zeroext i1 %45(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef %39, ptr noundef %42)
  store i1 %46, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

47:                                               ; preds = %34
  %48 = load i16, ptr %6, align 2, !tbaa !15
  %49 = zext i16 %48 to i32
  %50 = icmp eq i32 %49, 258
  br i1 %50, label %51, label %60

51:                                               ; preds = %47
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.android::ResXMLTree_node", ptr %53, i32 0, i32 0
  %55 = call noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef %54)
  %56 = load ptr, ptr %8, align 8, !tbaa !16
  %57 = getelementptr inbounds ptr, ptr %56, i64 8
  %58 = load ptr, ptr %57, align 8
  %59 = call noundef zeroext i1 %58(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef %52, ptr noundef %55)
  store i1 %59, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

60:                                               ; preds = %47
  %61 = load i16, ptr %6, align 2, !tbaa !15
  %62 = zext i16 %61 to i32
  %63 = icmp eq i32 %62, 259
  br i1 %63, label %64, label %73

64:                                               ; preds = %60
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.android::ResXMLTree_node", ptr %66, i32 0, i32 0
  %68 = call noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef %67)
  %69 = load ptr, ptr %8, align 8, !tbaa !16
  %70 = getelementptr inbounds ptr, ptr %69, i64 9
  %71 = load ptr, ptr %70, align 8
  %72 = call noundef zeroext i1 %71(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef %65, ptr noundef %68)
  store i1 %72, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

73:                                               ; preds = %60
  %74 = load i16, ptr %6, align 2, !tbaa !15
  %75 = zext i16 %74 to i32
  %76 = icmp eq i32 %75, 260
  br i1 %76, label %77, label %86

77:                                               ; preds = %73
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %"struct.android::ResXMLTree_node", ptr %79, i32 0, i32 0
  %81 = call noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef %80)
  %82 = load ptr, ptr %8, align 8, !tbaa !16
  %83 = getelementptr inbounds ptr, ptr %82, i64 11
  %84 = load ptr, ptr %83, align 8
  %85 = call noundef zeroext i1 %84(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef %78, ptr noundef %81)
  store i1 %85, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

86:                                               ; preds = %73
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

91:                                               ; preds = %90, %77, %64, %51, %38, %25
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  %92 = load i1, ptr %3, align 1
  ret i1 %92
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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" }
attributes #3 = { 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++ TBAA"}
!9 = !{!10, !12, i64 0}
!10 = !{!"_ZTSN7android15ResXMLTree_nodeE", !11, i64 0, !13, i64 8, !14, i64 12}
!11 = !{!"_ZTSN7android15ResChunk_headerE", !12, i64 0, !12, i64 2, !13, i64 4}
!12 = !{!"short", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN7android17ResStringPool_refE", !13, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, 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"

@switch.table._ZN4arsc14XmlFileVisitor10visit_nodeEPN7android15ResXMLTree_nodeE = private unnamed_addr constant [5 x i64] [i64 48, i64 56, i64 64, i64 72, i64 88], align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4arsc14XmlFileVisitor10visit_nodeEPN7android15ResXMLTree_nodeE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = load i16, ptr %1, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 12
  %5 = load ptr, ptr %0, align 8, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %5, i64 104
  %7 = load ptr, ptr %6, align 8
  %8 = tail call noundef zeroext i1 %7(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %4)
  %switch.tableidx = add i16 %3, -256
  %9 = icmp ult i16 %switch.tableidx, 5
  br i1 %9, label %switch.lookup, label %16

switch.lookup:                                    ; preds = %2
  %10 = zext nneg i16 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [5 x i64], ptr @switch.table._ZN4arsc14XmlFileVisitor10visit_nodeEPN7android15ResXMLTree_nodeE, i64 0, i64 %10
  %switch.load = load i64, ptr %switch.gep, align 8
  %11 = tail call noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef nonnull %1)
  %12 = load ptr, ptr %0, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %12, i64 %switch.load
  %14 = load ptr, ptr %13, align 8
  %15 = tail call noundef zeroext i1 %14(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %1, ptr noundef %11)
  br label %16

16:                                               ; preds = %2, %switch.lookup
  %.0 = phi i1 [ true, %2 ], [ %15, %switch.lookup ]
  ret i1 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN4arscL19assert_and_get_dataEPN7android15ResChunk_headerE(ptr noundef) local_unnamed_addr #1

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, !8, i64 0}
!6 = !{!"_ZTSN7android15ResXMLTree_nodeE", !7, i64 0, !11, i64 8, !12, i64 12}
!7 = !{!"_ZTSN7android15ResChunk_headerE", !8, i64 0, !8, i64 2, !11, i64 4}
!8 = !{!"short", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTSN7android17ResStringPool_refE", !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !10, i64 0}


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