; 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_extension(ptr noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.pb_field_iter_s, ptr %7, i32 0, i32 9
  %9 = load i8, ptr %8, align 2, !tbaa !9
  %10 = zext i8 %9 to i32
  %11 = and i32 %10, 15
  %12 = icmp eq i32 %11, 10
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store i1 true, ptr %2, align 1
  br label %52

14:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.pb_field_iter_s, ptr %15, i32 0, i32 2
  %17 = load i16, ptr %16, align 8, !tbaa !12
  store i16 %17, ptr %4, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  br label %18

18:                                               ; preds = %40, %14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  call void @advance_iterator(ptr noundef %19)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.pb_field_iter_s, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = getelementptr inbounds %struct.pb_msgdesc_s, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.pb_field_iter_s, ptr %25, i32 0, i32 3
  %27 = load i16, ptr %26, align 2, !tbaa !17
  %28 = zext i16 %27 to i64
  %29 = getelementptr inbounds i32, ptr %24, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !18
  store i32 %30, ptr %5, align 4, !tbaa !18
  %31 = load i32, ptr %5, align 4, !tbaa !18
  %32 = lshr i32 %31, 8
  %33 = and i32 %32, 255
  %34 = and i32 %33, 15
  %35 = icmp eq i32 %34, 10
  br i1 %35, label %36, label %39

36:                                               ; preds = %18
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = call zeroext i1 @load_descriptor_values(ptr noundef %37)
  store i1 %38, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %51

39:                                               ; preds = %18
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.pb_field_iter_s, ptr %41, i32 0, i32 2
  %43 = load i16, ptr %42, align 8, !tbaa !12
  %44 = zext i16 %43 to i32
  %45 = load i16, ptr %4, align 2, !tbaa !13
  %46 = zext i16 %45 to i32
  %47 = icmp ne i32 %44, %46
  br i1 %47, label %18, label %48, !llvm.loop !20

48:                                               ; preds = %40
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = call zeroext i1 @load_descriptor_values(ptr noundef %49)
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %51

51:                                               ; preds = %48, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #2
  br label %52

52:                                               ; preds = %51, %13
  %53 = load i1, ptr %2, align 1
  ret i1 %53
}

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, !7, i64 30}
!10 = !{!"pb_field_iter_s", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 18, !11, i64 20, !11, i64 22, !11, i64 24, !11, i64 26, !11, i64 28, !7, i64 30, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"pb_msgdesc_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 34, !11, i64 36}
!17 = !{!10, !11, i64 18}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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 zeroext i1 @pb_field_iter_find_extension(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 30
  %3 = load i8, ptr %2, align 2, !tbaa !5
  %4 = and i8 %3, 15
  %5 = icmp eq i8 %4, 10
  br i1 %5, label %25, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i16, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 18
  br label %10

10:                                               ; preds = %21, %6
  tail call void @advance_iterator(ptr noundef nonnull %0)
  %11 = load ptr, ptr %0, align 8, !tbaa !12
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = load i16, ptr %9, align 2, !tbaa !15
  %14 = zext i16 %13 to i64
  %15 = getelementptr inbounds i32, ptr %12, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !16
  %17 = and i32 %16, 3840
  %18 = icmp eq i32 %17, 2560
  br i1 %18, label %19, label %21

19:                                               ; preds = %10
  %20 = tail call zeroext i1 @load_descriptor_values(ptr noundef nonnull %0)
  br label %25

21:                                               ; preds = %10
  %22 = load i16, ptr %7, align 8, !tbaa !11
  %.not = icmp eq i16 %22, %8
  br i1 %.not, label %23, label %10, !llvm.loop !18

23:                                               ; preds = %21
  %24 = tail call zeroext i1 @load_descriptor_values(ptr noundef nonnull %0)
  br label %25

25:                                               ; preds = %19, %23, %1
  %.1 = phi i1 [ true, %1 ], [ %20, %19 ], [ false, %23 ]
  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, !8, i64 30}
!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, !10, i64 16}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"pb_msgdesc_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 34, !10, i64 36}
!15 = !{!6, !10, i64 18}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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