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

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 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 0}
!13 = !{!"_ZTS14__Bt_L2Cap_Pdu", !14, i64 0, !7, i64 4}
!14 = !{!"_ZTS17__Bt_L2Cap_Header", !10, i64 0, !10, i64 2}
!15 = !{!13, !10, i64 2}
!16 = !{!17, !6, i64 16}
!17 = !{!"_ZTS15__Bt_Hci_Device", !6, i64 0, !18, i64 8, !18, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!18 = !{!"int", !7, i64 0}
!19 = !{!18, !18, 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 @BtAttFindInformationRequest(ptr nocapture noundef readonly %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i16 noundef zeroext %3) local_unnamed_addr #1 {
  %5 = alloca [260 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 260, ptr nonnull %5) #2
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  %7 = and i16 %1, 4095
  %8 = zext nneg i16 %7 to i32
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  store i8 4, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 9
  store i16 %2, ptr %10, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %5, i64 11
  store i16 %3, ptr %11, align 1, !tbaa !5
  store i16 5, ptr %6, align 4, !tbaa !8
  %12 = getelementptr inbounds i8, ptr %5, i64 6
  store i16 4, ptr %12, align 2, !tbaa !12
  %13 = or disjoint i32 %8, 602112
  store i32 %13, ptr %5, align 16
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = call noundef i32 %15(ptr noundef nonnull %5, i32 noundef 13)
  call void @llvm.lifetime.end.p0(i64 260, ptr nonnull %5) #2
  ret i1 true
}

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 = { 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