; LLVM IR from lich0821/WeChatFerry :: WeChatFerry/rpc/nanopb (pb_common)

; 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.pb_field_iter_s = type { ptr, ptr, i16, i16, i16, i16, i16, i16, i16, i8, ptr, ptr, ptr, ptr }
%struct.pb_msgdesc_s = type { ptr, ptr, ptr, ptr, i16, i16, i16 }

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @load_descriptor_values(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare hidden void @advance_iterator(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @pb_field_iter_find(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.pb_field_iter_s, ptr %9, i32 0, i32 6
  %11 = load i16, ptr %10, align 8, !tbaa !11
  %12 = zext i16 %11 to i32
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp eq i32 %12, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  br label %95

16:                                               ; preds = %2
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.pb_field_iter_s, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds %struct.pb_msgdesc_s, ptr %20, i32 0, i32 6
  %22 = load i16, ptr %21, align 4, !tbaa !15
  %23 = zext i16 %22 to i32
  %24 = icmp ugt i32 %17, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %16
  store i1 false, ptr %3, align 1
  br label %95

26:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #2
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.pb_field_iter_s, ptr %27, i32 0, i32 2
  %29 = load i16, ptr %28, align 8, !tbaa !17
  store i16 %29, ptr %6, align 2, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.pb_field_iter_s, ptr %31, i32 0, i32 6
  %33 = load i16, ptr %32, align 8, !tbaa !11
  %34 = zext i16 %33 to i32
  %35 = icmp ult i32 %30, %34
  br i1 %35, label %36, label %44

36:                                               ; preds = %26
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.pb_field_iter_s, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = getelementptr inbounds %struct.pb_msgdesc_s, ptr %39, i32 0, i32 4
  %41 = load i16, ptr %40, align 8, !tbaa !19
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.pb_field_iter_s, ptr %42, i32 0, i32 2
  store i16 %41, ptr %43, align 8, !tbaa !17
  br label %44

44:                                               ; preds = %36, %26
  br label %45

45:                                               ; preds = %83, %44
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  call void @advance_iterator(ptr noundef %46)
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.pb_field_iter_s, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = getelementptr inbounds %struct.pb_msgdesc_s, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.pb_field_iter_s, ptr %52, i32 0, i32 3
  %54 = load i16, ptr %53, align 2, !tbaa !21
  %55 = zext i16 %54 to i64
  %56 = getelementptr inbounds i32, ptr %51, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !9
  store i32 %57, ptr %7, align 4, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = lshr i32 %58, 2
  %60 = and i32 %59, 63
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = and i32 %61, 63
  %63 = icmp eq i32 %60, %62
  br i1 %63, label %64, label %82

64:                                               ; preds = %45
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = call zeroext i1 @load_descriptor_values(ptr noundef %65)
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.pb_field_iter_s, ptr %67, i32 0, i32 6
  %69 = load i16, ptr %68, align 8, !tbaa !11
  %70 = zext i16 %69 to i32
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = icmp eq i32 %70, %71
  br i1 %72, label %73, label %81

73:                                               ; preds = %64
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.pb_field_iter_s, ptr %74, i32 0, i32 9
  %76 = load i8, ptr %75, align 2, !tbaa !22
  %77 = zext i8 %76 to i32
  %78 = and i32 %77, 15
  %79 = icmp ne i32 %78, 10
  br i1 %79, label %80, label %81

80:                                               ; preds = %73
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %94

81:                                               ; preds = %73, %64
  br label %82

82:                                               ; preds = %81, %45
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.pb_field_iter_s, ptr %84, i32 0, i32 2
  %86 = load i16, ptr %85, align 8, !tbaa !17
  %87 = zext i16 %86 to i32
  %88 = load i16, ptr %6, align 2, !tbaa !18
  %89 = zext i16 %88 to i32
  %90 = icmp ne i32 %87, %89
  br i1 %90, label %45, label %91, !llvm.loop !23

91:                                               ; preds = %83
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = call zeroext i1 @load_descriptor_values(ptr noundef %92)
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %94

94:                                               ; preds = %91, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #2
  br label %95

95:                                               ; preds = %94, %25, %15
  %96 = load i1, ptr %3, align 1
  ret i1 %96
}

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 24}
!12 = !{!"pb_field_iter_s", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 18, !13, i64 20, !13, i64 22, !13, i64 24, !13, i64 26, !13, i64 28, !7, i64 30, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !6, i64 0}
!15 = !{!16, !13, i64 36}
!16 = !{!"pb_msgdesc_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 34, !13, i64 36}
!17 = !{!12, !13, i64 16}
!18 = !{!13, !13, i64 0}
!19 = !{!16, !13, i64 32}
!20 = !{!16, !6, i64 0}
!21 = !{!12, !13, i64 18}
!22 = !{!12, !7, i64 30}
!23 = distinct !{!23, !24}
!24 = !{!"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"

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @load_descriptor_values(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @advance_iterator(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @pb_field_iter_find(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i16, ptr %3, align 8, !tbaa !5
  %5 = zext i16 %4 to i32
  %6 = icmp eq i32 %5, %1
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %2
  %8 = load ptr, ptr %0, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %8, i64 36
  %10 = load i16, ptr %9, align 4, !tbaa !12
  %11 = zext i16 %10 to i32
  %12 = icmp ult i32 %11, %1
  br i1 %12, label %.loopexit, label %13

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load i16, ptr %14, align 8, !tbaa !14
  %16 = icmp ugt i32 %5, %1
  br i1 %16, label %17, label %20

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %8, i64 32
  %19 = load i16, ptr %18, align 8, !tbaa !15
  store i16 %19, ptr %14, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %17, %13
  %21 = getelementptr inbounds i8, ptr %0, i64 18
  %22 = getelementptr inbounds i8, ptr %0, i64 30
  br label %23

23:                                               ; preds = %42, %20
  tail call void @advance_iterator(ptr noundef nonnull %0)
  %24 = load ptr, ptr %0, align 8, !tbaa !11
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = load i16, ptr %21, align 2, !tbaa !17
  %27 = zext i16 %26 to i64
  %28 = getelementptr inbounds i32, ptr %25, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !18
  %30 = lshr i32 %29, 2
  %31 = xor i32 %30, %1
  %32 = and i32 %31, 63
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %42

34:                                               ; preds = %23
  %35 = tail call zeroext i1 @load_descriptor_values(ptr noundef nonnull %0)
  %36 = load i16, ptr %3, align 8, !tbaa !5
  %37 = zext i16 %36 to i32
  %38 = icmp eq i32 %37, %1
  br i1 %38, label %39, label %42

39:                                               ; preds = %34
  %40 = load i8, ptr %22, align 2, !tbaa !20
  %41 = and i8 %40, 15
  %.not = icmp eq i8 %41, 10
  br i1 %.not, label %42, label %.loopexit

42:                                               ; preds = %23, %39, %34
  %43 = load i16, ptr %14, align 8, !tbaa !14
  %.not23 = icmp eq i16 %43, %15
  br i1 %.not23, label %44, label %23, !llvm.loop !21

44:                                               ; preds = %42
  %45 = tail call zeroext i1 @load_descriptor_values(ptr noundef nonnull %0)
  br label %.loopexit

.loopexit:                                        ; preds = %39, %44, %7, %2
  %.1 = phi i1 [ true, %2 ], [ false, %7 ], [ false, %44 ], [ true, %39 ]
  ret i1 %.1
}

attributes #0 = { 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, !10, i64 24}
!6 = !{!"pb_field_iter_s", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 18, !10, i64 20, !10, i64 22, !10, i64 24, !10, i64 26, !10, i64 28, !8, i64 30, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !10, i64 36}
!13 = !{!"pb_msgdesc_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 34, !10, i64 36}
!14 = !{!6, !10, i64 16}
!15 = !{!13, !10, i64 32}
!16 = !{!13, !7, i64 0}
!17 = !{!6, !10, i64 18}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !8, i64 0}
!20 = !{!6, !8, i64 30}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass