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

; 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.__Bt_Hci_ACL_Data_Packet = type <{ %struct.__Bt_Hci_ACL_Data_Packet_Header, [1 x i8] }>
%struct.__Bt_Hci_ACL_Data_Packet_Header = type { i32 }
%struct.__Bt_L2Cap_Pdu = type <{ %struct.__Bt_L2Cap_Header, %union.anon }>
%struct.__Bt_L2Cap_Header = type { i16, i16 }
%union.anon = type <{ i32, [17 x i8] }>
%struct.__Bt_Attribute_Req_Rsp = type <{ i8, %union.anon.5 }>
%union.anon.5 = 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_Find_By_Type_Value_Req = type <{ i16, i16, i16, [1 x i8] }>
%struct.__Bt_Hci_Device = type { ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; 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 zeroext i1 @BtAttFindByTypeValueRequest(ptr noundef %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i16 noundef zeroext %3, i16 noundef zeroext %4, ptr noundef %5, i64 noundef %6) #1 {
  %8 = alloca ptr, align 8
  %9 = alloca i16, align 2
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca [260 x i8], align 16
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i16 %1, ptr %9, align 2, !tbaa !9
  store i16 %2, ptr %10, align 2, !tbaa !9
  store i16 %3, ptr %11, align 2, !tbaa !9
  store i16 %4, ptr %12, align 2, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  store i64 %6, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 260, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %19 = getelementptr inbounds [260 x i8], ptr %15, i64 0, i64 0
  store ptr %19, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %20 = load ptr, ptr %16, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.__Bt_Hci_ACL_Data_Packet, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds [1 x i8], ptr %21, i64 0, i64 0
  store ptr %22, ptr %17, align 8, !tbaa !5
  %23 = load i16, ptr %9, align 2, !tbaa !9
  %24 = zext i16 %23 to i32
  %25 = load ptr, ptr %16, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.__Bt_Hci_ACL_Data_Packet, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 1
  %28 = and i32 %24, 4095
  %29 = and i32 %27, -4096
  %30 = or i32 %29, %28
  store i32 %30, ptr %26, align 1
  %31 = load ptr, ptr %16, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.__Bt_Hci_ACL_Data_Packet, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 1
  %34 = and i32 %33, -12289
  %35 = or i32 %34, 12288
  store i32 %35, ptr %32, align 1
  %36 = load ptr, ptr %16, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.__Bt_Hci_ACL_Data_Packet, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 1
  %39 = and i32 %38, -49153
  %40 = or i32 %39, 0
  store i32 %40, ptr %37, align 1
  %41 = load ptr, ptr %17, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %42, i32 0, i32 0
  store i8 6, ptr %43, align 1, !tbaa !13
  %44 = load i16, ptr %10, align 2, !tbaa !9
  %45 = load ptr, ptr %17, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %46, i32 0, i32 1
  %48 = getelementptr inbounds %struct.__Bt_Att_Find_By_Type_Value_Req, ptr %47, i32 0, i32 0
  store i16 %44, ptr %48, align 1, !tbaa !13
  %49 = load i16, ptr %11, align 2, !tbaa !9
  %50 = load ptr, ptr %17, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds %struct.__Bt_Att_Find_By_Type_Value_Req, ptr %52, i32 0, i32 1
  store i16 %49, ptr %53, align 1, !tbaa !13
  %54 = load i16, ptr %12, align 2, !tbaa !9
  %55 = load ptr, ptr %17, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %struct.__Bt_Att_Find_By_Type_Value_Req, ptr %57, i32 0, i32 2
  store i16 %54, ptr %58, align 1, !tbaa !13
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %struct.__Bt_Attribute_Req_Rsp, ptr %60, i32 0, i32 1
  %62 = getelementptr inbounds %struct.__Bt_Att_Find_By_Type_Value_Req, ptr %61, i32 0, i32 3
  %63 = getelementptr inbounds [1 x i8], ptr %62, i64 0, i64 0
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = load i64, ptr %14, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %63, ptr align 1 %64, i64 %65, i1 false)
  %66 = load i64, ptr %14, align 8, !tbaa !11
  %67 = add i64 7, %66
  %68 = trunc i64 %67 to i16
  %69 = load ptr, ptr %17, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds %struct.__Bt_L2Cap_Header, ptr %70, i32 0, i32 0
  store i16 %68, ptr %71, align 1, !tbaa !14
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds %struct.__Bt_L2Cap_Header, ptr %73, i32 0, i32 1
  store i16 4, ptr %74, align 1, !tbaa !17
  %75 = load ptr, ptr %17, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.__Bt_L2Cap_Pdu, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds %struct.__Bt_L2Cap_Header, ptr %76, i32 0, i32 0
  %78 = load i16, ptr %77, align 1, !tbaa !14
  %79 = zext i16 %78 to i64
  %80 = add i64 %79, 4
  %81 = trunc i64 %80 to i32
  %82 = load ptr, ptr %16, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.__Bt_Hci_ACL_Data_Packet, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 1
  %85 = and i32 %81, 65535
  %86 = shl i32 %85, 16
  %87 = and i32 %84, 65535
  %88 = or i32 %87, %86
  store i32 %88, ptr %83, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.__Bt_Hci_Device, ptr %89, i32 0, i32 3
  %91 = load ptr, ptr %90, align 8, !tbaa !18
  %92 = load ptr, ptr %16, align 8, !tbaa !5
  %93 = load ptr, ptr %16, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.__Bt_Hci_ACL_Data_Packet, ptr %93, i32 0, i32 0
  %95 = load i32, ptr %94, align 1
  %96 = lshr i32 %95, 16
  %97 = zext i32 %96 to i64
  %98 = add i64 %97, 4
  %99 = trunc i64 %98 to i32
  %100 = call noundef i32 %91(ptr noundef %92, i32 noundef %99)
  store i32 %100, ptr %18, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 260, ptr %15) #3
  ret i1 true
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"_ZTS14__Bt_L2Cap_Pdu", !16, i64 0, !7, i64 4}
!16 = !{!"_ZTS17__Bt_L2Cap_Header", !10, i64 0, !10, i64 2}
!17 = !{!15, !10, i64 2}
!18 = !{!19, !6, i64 16}
!19 = !{!"_ZTS15__Bt_Hci_Device", !6, i64 0, !20, i64 8, !20, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!20 = !{!"int", !7, i64 0}
!21 = !{!20, !20, 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 @BtAttFindByTypeValueRequest(ptr nocapture noundef readonly %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i16 noundef zeroext %3, i16 noundef zeroext %4, ptr nocapture noundef readonly %5, i64 noundef %6) local_unnamed_addr #1 {
  %8 = alloca [260 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 260, ptr nonnull %8) #3
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  %10 = and i16 %1, 4095
  %11 = or disjoint i16 %10, 12288
  %12 = zext nneg i16 %11 to i32
  %13 = getelementptr inbounds i8, ptr %8, i64 8
  store i8 6, ptr %13, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %8, i64 9
  store i16 %2, ptr %14, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %8, i64 11
  store i16 %3, ptr %15, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %8, i64 13
  store i16 %4, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %8, i64 15
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %17, ptr align 1 %5, i64 %6, i1 false)
  %18 = trunc i64 %6 to i16
  %19 = add i16 %18, 7
  store i16 %19, ptr %9, align 4, !tbaa !8
  %20 = getelementptr inbounds i8, ptr %8, i64 6
  store i16 4, ptr %20, align 2, !tbaa !12
  %21 = add i16 %18, 11
  %22 = zext i16 %21 to i32
  %23 = shl nuw i32 %22, 16
  %24 = or disjoint i32 %23, %12
  store i32 %24, ptr %8, align 16
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = add nuw nsw i32 %22, 4
  %28 = call noundef i32 %26(ptr noundef nonnull %8, i32 noundef %27)
  call void @llvm.lifetime.end.p0(i64 260, ptr nonnull %8) #3
  ret i1 true
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 0}
!9 = !{!"_ZTS14__Bt_L2Cap_Pdu", !10, i64 0, !6, i64 4}
!10 = !{!"_ZTS17__Bt_L2Cap_Header", !11, i64 0, !11, i64 2}
!11 = !{!"short", !6, i64 0}
!12 = !{!9, !11, i64 2}
!13 = !{!14, !15, i64 16}
!14 = !{!"_ZTS15__Bt_Hci_Device", !15, i64 0, !16, i64 8, !16, i64 12, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64}
!15 = !{!"any pointer", !6, i64 0}
!16 = !{!"int", !6, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass