; LLVM IR from IOsonata/IOsonata :: src/bluetooth (bt_attrsp)

; 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.CurParseInf_t = type { i8, i8, i8 }
%struct.__Bt_Dev_Data = type { [30 x i8], [6 x i8], i16, i32, ptr, [10 x %struct.BtGattDBSrvc_t] }
%struct.BtGattDBSrvc_t = type { %struct.__Bt_Uuid16, i8, %struct.__Bt_Gattc_Hdl_Range, [6 x %struct.BtGattDBChar_t] }
%struct.__Bt_Uuid16 = type <{ i8, i16 }>
%struct.__Bt_Gattc_Hdl_Range = type { i16, i16 }
%struct.BtGattDBChar_t = type { %struct.BtGattcChar_t, i16, i16, i16, i16 }
%struct.BtGattcChar_t = type { %struct.__Bt_Uuid16, %struct.BtGattCharProps_t, i8, i16, i16 }
%struct.BtGattCharProps_t = type { i8 }
%struct.__Bt_Uuid = type <{ i8, %union.anon.1 }>
%union.anon.1 = type { i32 }
%struct.__Bt_Attribute_Req_Rsp = type <{ i8, %union.anon }>
%union.anon = type { %struct.__Bt_Att_Read_By_Type_Req }
%struct.__Bt_Att_Read_By_Type_Req = type { i16, i16, %union.__Bt_Uuid_Val }
%union.__Bt_Uuid_Val = type { i32, [12 x i8] }
%struct.__Bt_Att_ErrorRsp = type <{ i8, i16, i8 }>

@g_CurIdx = external dso_local global %struct.CurParseInf_t, align 1
@g_BtDevSdc = external global %struct.__Bt_Dev_Data, align 8
@g_UuidType = external global %struct.__Bt_Uuid, align 1

; Function Attrs: mustprogress uwtable
define dso_local i32 @BtAttProcessError(i16 noundef zeroext %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i16, align 2
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  %13 = alloca ptr, align 8
  %14 = alloca i16, align 2
  %15 = alloca i16, align 2
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i16, align 2
  %19 = alloca i16, align 2
  store i16 %0, ptr %4, align 2, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.__Bt_Att_ErrorRsp, ptr %21, i32 0, i32 0
  %23 = load i8, ptr %22, align 1, !tbaa !13
  %24 = zext i8 %23 to i32
  switch i32 %24, label %165 [
    i32 16, label %25
    i32 8, label %79
    i32 10, label %156
  ]

25:                                               ; preds = %3
  %26 = load ptr, ptr %5, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.__Bt_Att_ErrorRsp, ptr %27, i32 0, i32 2
  %29 = load i8, ptr %28, align 1, !tbaa !13
  %30 = zext i8 %29 to i32
  %31 = icmp eq i32 %30, 10
  br i1 %31, label %32, label %78

32:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %33

33:                                               ; preds = %42, %32
  %34 = load i32, ptr %8, align 4, !tbaa !11
  %35 = load i32, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 3), align 8, !tbaa !14
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %45

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %39 = load i32, ptr %8, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [10 x %struct.BtGattDBSrvc_t], ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 5), i64 0, i64 %40
  store ptr %41, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %42

42:                                               ; preds = %38
  %43 = load i32, ptr %8, align 4, !tbaa !11
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %8, align 4, !tbaa !11
  br label %33, !llvm.loop !16

45:                                               ; preds = %37
  store i8 0, ptr @g_CurIdx, align 1, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %46 = load i8, ptr @g_CurIdx, align 1, !tbaa !18
  %47 = zext i8 %46 to i64
  %48 = getelementptr inbounds [10 x %struct.BtGattDBSrvc_t], ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 5), i64 0, i64 %47
  store ptr %48, ptr %10, align 8, !tbaa !9
  store i8 0, ptr getelementptr inbounds (%struct.CurParseInf_t, ptr @g_CurIdx, i32 0, i32 2), align 1, !tbaa !20
  %49 = load ptr, ptr %10, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %49, i32 0, i32 2
  %51 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %50, i32 0, i32 0
  %52 = load i16, ptr %51, align 2, !tbaa !21
  %53 = trunc i16 %52 to i8
  store i8 %53, ptr getelementptr inbounds (%struct.CurParseInf_t, ptr @g_CurIdx, i32 0, i32 1), align 1, !tbaa !26
  %54 = load i8, ptr getelementptr inbounds (%struct.CurParseInf_t, ptr @g_CurIdx, i32 0, i32 1), align 1, !tbaa !26
  %55 = zext i8 %54 to i32
  %56 = load ptr, ptr %10, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %56, i32 0, i32 2
  %58 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %57, i32 0, i32 1
  %59 = load i16, ptr %58, align 2, !tbaa !27
  %60 = zext i16 %59 to i32
  %61 = icmp sgt i32 %55, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %45
  br label %77

63:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #3
  %64 = load ptr, ptr %10, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %64, i32 0, i32 2
  %66 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %65, i32 0, i32 0
  %67 = load i16, ptr %66, align 2, !tbaa !21
  store i16 %67, ptr %11, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #3
  %68 = load ptr, ptr %10, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %68, i32 0, i32 2
  %70 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %69, i32 0, i32 1
  %71 = load i16, ptr %70, align 2, !tbaa !27
  store i16 %71, ptr %12, align 2, !tbaa !5
  store i16 10243, ptr getelementptr inbounds (%struct.__Bt_Uuid, ptr @g_UuidType, i32 0, i32 1), align 1, !tbaa !13
  %72 = load ptr, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 4), align 8, !tbaa !28
  %73 = load i16, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 2), align 4, !tbaa !29
  %74 = load i16, ptr %11, align 2, !tbaa !5
  %75 = load i16, ptr %12, align 2, !tbaa !5
  %76 = call zeroext i1 @BtAttReadByTypeRequest(ptr noundef %72, i16 noundef zeroext %73, i16 noundef zeroext %74, i16 noundef zeroext %75, ptr noundef @g_UuidType)
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #3
  br label %77

77:                                               ; preds = %63, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %78

78:                                               ; preds = %77, %25
  br label %166

79:                                               ; preds = %3
  %80 = load ptr, ptr %5, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %80, i32 0, i32 1
  %82 = getelementptr inbounds %struct.__Bt_Att_ErrorRsp, ptr %81, i32 0, i32 2
  %83 = load i8, ptr %82, align 1, !tbaa !13
  %84 = zext i8 %83 to i32
  %85 = icmp eq i32 %84, 10
  br i1 %85, label %86, label %155

86:                                               ; preds = %79
  %87 = load i8, ptr @g_CurIdx, align 1, !tbaa !18
  %88 = zext i8 %87 to i32
  %89 = load i32, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 3), align 8, !tbaa !14
  %90 = sub nsw i32 %89, 1
  %91 = icmp sge i32 %88, %90
  br i1 %91, label %92, label %130

92:                                               ; preds = %86
  store i8 0, ptr @g_CurIdx, align 1, !tbaa !18
  store i8 0, ptr getelementptr inbounds (%struct.CurParseInf_t, ptr @g_CurIdx, i32 0, i32 2), align 1, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %93 = load i8, ptr @g_CurIdx, align 1, !tbaa !18
  %94 = zext i8 %93 to i64
  %95 = getelementptr inbounds [10 x %struct.BtGattDBSrvc_t], ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 5), i64 0, i64 %94
  store ptr %95, ptr %13, align 8, !tbaa !9
  %96 = load ptr, ptr %13, align 8, !tbaa !9
  %97 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %96, i32 0, i32 2
  %98 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %97, i32 0, i32 0
  %99 = load i16, ptr %98, align 2, !tbaa !21
  %100 = trunc i16 %99 to i8
  store i8 %100, ptr getelementptr inbounds (%struct.CurParseInf_t, ptr @g_CurIdx, i32 0, i32 1), align 1, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #3
  %101 = load ptr, ptr %13, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %101, i32 0, i32 2
  %103 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %102, i32 0, i32 0
  %104 = load i16, ptr %103, align 2, !tbaa !21
  store i16 %104, ptr %14, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #3
  %105 = load ptr, ptr %13, align 8, !tbaa !9
  %106 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %105, i32 0, i32 2
  %107 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %106, i32 0, i32 1
  %108 = load i16, ptr %107, align 2, !tbaa !27
  store i16 %108, ptr %15, align 2, !tbaa !5
  %109 = load i16, ptr getelementptr inbounds (%struct.__Bt_Uuid, ptr @g_UuidType, i32 0, i32 1), align 1, !tbaa !13
  %110 = zext i16 %109 to i32
  switch i32 %110, label %123 [
    i32 10243, label %111
    i32 10498, label %122
  ]

111:                                              ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %112

112:                                              ; preds = %118, %111
  %113 = load i32, ptr %16, align 4, !tbaa !11
  %114 = load i32, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 3), align 8, !tbaa !14
  %115 = icmp slt i32 %113, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %112
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %121

117:                                              ; preds = %112
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %16, align 4, !tbaa !11
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %16, align 4, !tbaa !11
  br label %112, !llvm.loop !30

121:                                              ; preds = %116
  store i16 10498, ptr getelementptr inbounds (%struct.__Bt_Uuid, ptr @g_UuidType, i32 0, i32 1), align 1, !tbaa !13
  br label %124

122:                                              ; preds = %92
  store i16 10497, ptr getelementptr inbounds (%struct.__Bt_Uuid, ptr @g_UuidType, i32 0, i32 1), align 1, !tbaa !13
  br label %124

123:                                              ; preds = %92
  br label %124

124:                                              ; preds = %123, %122, %121
  %125 = load ptr, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 4), align 8, !tbaa !28
  %126 = load i16, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 2), align 4, !tbaa !29
  %127 = load i16, ptr %14, align 2, !tbaa !5
  %128 = load i16, ptr %15, align 2, !tbaa !5
  %129 = call zeroext i1 @BtAttReadByTypeRequest(ptr noundef %125, i16 noundef zeroext %126, i16 noundef zeroext %127, i16 noundef zeroext %128, ptr noundef @g_UuidType)
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %154

130:                                              ; preds = %86
  %131 = load i8, ptr @g_CurIdx, align 1, !tbaa !18
  %132 = add i8 %131, 1
  store i8 %132, ptr @g_CurIdx, align 1, !tbaa !18
  store i8 0, ptr getelementptr inbounds (%struct.CurParseInf_t, ptr @g_CurIdx, i32 0, i32 2), align 1, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %133 = load i8, ptr @g_CurIdx, align 1, !tbaa !18
  %134 = zext i8 %133 to i64
  %135 = getelementptr inbounds [10 x %struct.BtGattDBSrvc_t], ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 5), i64 0, i64 %134
  store ptr %135, ptr %17, align 8, !tbaa !9
  %136 = load ptr, ptr %17, align 8, !tbaa !9
  %137 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %136, i32 0, i32 2
  %138 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %137, i32 0, i32 0
  %139 = load i16, ptr %138, align 2, !tbaa !21
  %140 = trunc i16 %139 to i8
  store i8 %140, ptr getelementptr inbounds (%struct.CurParseInf_t, ptr @g_CurIdx, i32 0, i32 1), align 1, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 2, ptr %18) #3
  %141 = load ptr, ptr %17, align 8, !tbaa !9
  %142 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %141, i32 0, i32 2
  %143 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %142, i32 0, i32 0
  %144 = load i16, ptr %143, align 2, !tbaa !21
  store i16 %144, ptr %18, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %19) #3
  %145 = load ptr, ptr %17, align 8, !tbaa !9
  %146 = getelementptr inbounds %struct.BtGattDBSrvc_t, ptr %145, i32 0, i32 2
  %147 = getelementptr inbounds %struct.__Bt_Gattc_Hdl_Range, ptr %146, i32 0, i32 1
  %148 = load i16, ptr %147, align 2, !tbaa !27
  store i16 %148, ptr %19, align 2, !tbaa !5
  %149 = load ptr, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 4), align 8, !tbaa !28
  %150 = load i16, ptr getelementptr inbounds (%struct.__Bt_Dev_Data, ptr @g_BtDevSdc, i32 0, i32 2), align 4, !tbaa !29
  %151 = load i16, ptr %18, align 2, !tbaa !5
  %152 = load i16, ptr %19, align 2, !tbaa !5
  %153 = call zeroext i1 @BtAttReadByTypeRequest(ptr noundef %149, i16 noundef zeroext %150, i16 noundef zeroext %151, i16 noundef zeroext %152, ptr noundef @g_UuidType)
  call void @llvm.lifetime.end.p0(i64 2, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %154

154:                                              ; preds = %130, %124
  br label %155

155:                                              ; preds = %154, %79
  br label %166

156:                                              ; preds = %3
  %157 = load ptr, ptr %5, align 8, !tbaa !9
  %158 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %157, i32 0, i32 1
  %159 = getelementptr inbounds %struct.__Bt_Att_ErrorRsp, ptr %158, i32 0, i32 2
  %160 = load i8, ptr %159, align 1, !tbaa !13
  %161 = zext i8 %160 to i32
  %162 = icmp eq i32 %161, 1
  br i1 %162, label %163, label %164

163:                                              ; preds = %156
  br label %164

164:                                              ; preds = %163, %156
  br label %166

165:                                              ; preds = %3
  br label %166

166:                                              ; preds = %165, %164, %155, %78
  %167 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %167
}

; 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

declare zeroext i1 @BtAttReadByTypeRequest(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 40}
!15 = !{!"_ZTS13__Bt_Dev_Data", !7, i64 0, !7, i64 30, !6, i64 36, !12, i64 40, !10, i64 48, !7, i64 56}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !7, i64 0}
!19 = !{!"_ZTS13CurParseInf_t", !7, i64 0, !7, i64 1, !7, i64 2}
!20 = !{!19, !7, i64 2}
!21 = !{!22, !6, i64 4}
!22 = !{!"_ZTS14BtGattDBSrvc_t", !23, i64 0, !7, i64 3, !25, i64 4, !7, i64 8}
!23 = !{!"_ZTS11__Bt_Uuid16", !7, i64 0, !24, i64 0, !6, i64 1}
!24 = !{!"_ZTS14__Bt_Uuid_Type", !7, i64 0}
!25 = !{!"_ZTS20__Bt_Gattc_Hdl_Range", !6, i64 0, !6, i64 2}
!26 = !{!19, !7, i64 1}
!27 = !{!22, !6, i64 6}
!28 = !{!15, !10, i64 48}
!29 = !{!15, !6, i64 36}
!30 = distinct !{!30, !17}


; 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"

%struct.CurParseInf_t = type { i8, i8, i8 }
%struct.__Bt_Dev_Data = type { [30 x i8], [6 x i8], i16, i32, ptr, [10 x %struct.BtGattDBSrvc_t] }
%struct.BtGattDBSrvc_t = type { %struct.__Bt_Uuid16, i8, %struct.__Bt_Gattc_Hdl_Range, [6 x %struct.BtGattDBChar_t] }
%struct.__Bt_Uuid16 = type <{ i8, i16 }>
%struct.__Bt_Gattc_Hdl_Range = type { i16, i16 }
%struct.BtGattDBChar_t = type { %struct.BtGattcChar_t, i16, i16, i16, i16 }
%struct.BtGattcChar_t = type { %struct.__Bt_Uuid16, %struct.BtGattCharProps_t, i8, i16, i16 }
%struct.BtGattCharProps_t = type { i8 }
%struct.__Bt_Uuid = type <{ i8, %union.anon.1 }>
%union.anon.1 = type { i32 }

@g_CurIdx = external dso_local local_unnamed_addr global %struct.CurParseInf_t, align 1
@g_BtDevSdc = external local_unnamed_addr global %struct.__Bt_Dev_Data, align 8
@g_UuidType = external global %struct.__Bt_Uuid, align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @BtAttProcessError(i16 noundef zeroext %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5
  switch i8 %5, label %48 [
    i8 16, label %6
    i8 8, label %18
  ]

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = icmp eq i8 %8, 10
  br i1 %9, label %.preheader, label %48

.preheader:                                       ; preds = %6
  store i8 0, ptr @g_CurIdx, align 1, !tbaa !8
  store i8 0, ptr getelementptr inbounds (i8, ptr @g_CurIdx, i64 2), align 1, !tbaa !10
  %10 = load i16, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 60), align 4, !tbaa !11
  %11 = trunc i16 %10 to i8
  store i8 %11, ptr getelementptr inbounds (i8, ptr @g_CurIdx, i64 1), align 1, !tbaa !17
  %.mask = and i16 %10, 255
  %12 = load i16, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 62), align 2, !tbaa !18
  %13 = icmp ugt i16 %.mask, %12
  br i1 %13, label %48, label %14

14:                                               ; preds = %.preheader
  store i16 10243, ptr getelementptr inbounds (i8, ptr @g_UuidType, i64 1), align 1, !tbaa !5
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 48), align 8, !tbaa !19
  %16 = load i16, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 36), align 4, !tbaa !23
  %17 = tail call zeroext i1 @BtAttReadByTypeRequest(ptr noundef %15, i16 noundef zeroext %16, i16 noundef zeroext %10, i16 noundef zeroext %12, ptr noundef nonnull @g_UuidType)
  br label %48

18:                                               ; preds = %3
  %19 = getelementptr inbounds i8, ptr %1, i64 4
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = icmp eq i8 %20, 10
  br i1 %21, label %22, label %48

22:                                               ; preds = %18
  %23 = load i8, ptr @g_CurIdx, align 1, !tbaa !8
  %24 = zext i8 %23 to i32
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 40), align 8, !tbaa !24
  %26 = add nsw i32 %25, -1
  %.not = icmp sgt i32 %26, %24
  br i1 %.not, label %37, label %27

27:                                               ; preds = %22
  store i8 0, ptr @g_CurIdx, align 1, !tbaa !8
  store i8 0, ptr getelementptr inbounds (i8, ptr @g_CurIdx, i64 2), align 1, !tbaa !10
  %28 = load i16, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 60), align 4, !tbaa !11
  %29 = trunc i16 %28 to i8
  store i8 %29, ptr getelementptr inbounds (i8, ptr @g_CurIdx, i64 1), align 1, !tbaa !17
  %30 = load i16, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 62), align 2, !tbaa !18
  %31 = load i16, ptr getelementptr inbounds (i8, ptr @g_UuidType, i64 1), align 1, !tbaa !5
  switch i16 %31, label %33 [
    i16 10243, label %.sink.split
    i16 10498, label %32
  ]

32:                                               ; preds = %27
  br label %.sink.split

.sink.split:                                      ; preds = %27, %32
  %.sink = phi i16 [ 10497, %32 ], [ 10498, %27 ]
  store i16 %.sink, ptr getelementptr inbounds (i8, ptr @g_UuidType, i64 1), align 1, !tbaa !5
  br label %33

33:                                               ; preds = %.sink.split, %27
  %34 = load ptr, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 48), align 8, !tbaa !19
  %35 = load i16, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 36), align 4, !tbaa !23
  %36 = tail call zeroext i1 @BtAttReadByTypeRequest(ptr noundef %34, i16 noundef zeroext %35, i16 noundef zeroext %28, i16 noundef zeroext %30, ptr noundef nonnull @g_UuidType)
  br label %48

37:                                               ; preds = %22
  %38 = add i8 %23, 1
  store i8 %38, ptr @g_CurIdx, align 1, !tbaa !8
  store i8 0, ptr getelementptr inbounds (i8, ptr @g_CurIdx, i64 2), align 1, !tbaa !10
  %39 = zext i8 %38 to i64
  %40 = getelementptr inbounds [10 x %struct.BtGattDBSrvc_t], ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 56), i64 0, i64 %39, i32 2
  %41 = load i16, ptr %40, align 4, !tbaa !11
  %42 = trunc i16 %41 to i8
  store i8 %42, ptr getelementptr inbounds (i8, ptr @g_CurIdx, i64 1), align 1, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %40, i64 2
  %44 = load i16, ptr %43, align 2, !tbaa !18
  %45 = load ptr, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 48), align 8, !tbaa !19
  %46 = load i16, ptr getelementptr inbounds (i8, ptr @g_BtDevSdc, i64 36), align 4, !tbaa !23
  %47 = tail call zeroext i1 @BtAttReadByTypeRequest(ptr noundef %45, i16 noundef zeroext %46, i16 noundef zeroext %41, i16 noundef zeroext %44, ptr noundef nonnull @g_UuidType)
  br label %48

48:                                               ; preds = %14, %.preheader, %3, %18, %37, %33, %6
  ret i32 0
}

declare zeroext i1 @BtAttReadByTypeRequest(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, 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 = { "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !6, i64 0}
!9 = !{!"_ZTS13CurParseInf_t", !6, i64 0, !6, i64 1, !6, i64 2}
!10 = !{!9, !6, i64 2}
!11 = !{!12, !15, i64 4}
!12 = !{!"_ZTS14BtGattDBSrvc_t", !13, i64 0, !6, i64 3, !16, i64 4, !6, i64 8}
!13 = !{!"_ZTS11__Bt_Uuid16", !6, i64 0, !14, i64 0, !15, i64 1}
!14 = !{!"_ZTS14__Bt_Uuid_Type", !6, i64 0}
!15 = !{!"short", !6, i64 0}
!16 = !{!"_ZTS20__Bt_Gattc_Hdl_Range", !15, i64 0, !15, i64 2}
!17 = !{!9, !6, i64 1}
!18 = !{!12, !15, i64 6}
!19 = !{!20, !22, i64 48}
!20 = !{!"_ZTS13__Bt_Dev_Data", !6, i64 0, !6, i64 30, !15, i64 36, !21, i64 40, !22, i64 48, !6, i64 56}
!21 = !{!"int", !6, i64 0}
!22 = !{!"any pointer", !6, i64 0}
!23 = !{!20, !15, i64 36}
!24 = !{!20, !21, i64 40}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass