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

; 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_Base_Uuid_Tbl_Entry = type { [16 x i8], i8 }
%struct.__Bt_Uuid16 = type <{ i8, i16 }>

@_ZL15s_BtBaseUuidTbl = external hidden global [4 x %struct.__Bt_Base_Uuid_Tbl_Entry], align 4

; 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: 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) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local zeroext i1 @BtUuid16To128(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load i8, ptr %6, align 1
  %8 = and i8 %7, 63
  %9 = zext i8 %8 to i64
  %10 = getelementptr inbounds [4 x %struct.__Bt_Base_Uuid_Tbl_Entry], ptr @_ZL15s_BtBaseUuidTbl, i64 0, i64 %9
  store ptr %10, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.__Bt_Base_Uuid_Tbl_Entry, ptr %11, i32 0, i32 1
  %13 = load i8, ptr %12, align 1, !tbaa !9, !range !12, !noundef !13
  %14 = trunc i8 %13 to i1
  %15 = zext i1 %14 to i32
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %38

17:                                               ; preds = %2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.__Bt_Base_Uuid_Tbl_Entry, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds [16 x i8], ptr %20, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %18, ptr align 1 %21, i64 16, i1 false)
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.__Bt_Uuid16, ptr %22, i32 0, i32 1
  %24 = load i16, ptr %23, align 1, !tbaa !14
  %25 = zext i16 %24 to i32
  %26 = and i32 %25, 255
  %27 = trunc i32 %26 to i8
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 12
  store i8 %27, ptr %29, align 1, !tbaa !18
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.__Bt_Uuid16, ptr %30, i32 0, i32 1
  %32 = load i16, ptr %31, align 1, !tbaa !14
  %33 = zext i16 %32 to i32
  %34 = ashr i32 %33, 8
  %35 = trunc i32 %34 to i8
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 13
  store i8 %35, ptr %37, align 1, !tbaa !18
  br label %38

38:                                               ; preds = %17, %2
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.__Bt_Base_Uuid_Tbl_Entry, ptr %39, i32 0, i32 1
  %41 = load i8, ptr %40, align 1, !tbaa !9, !range !12, !noundef !13
  %42 = trunc i8 %41 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i1 %42
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #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, !11, i64 16}
!10 = !{!"_ZTS24__Bt_Base_Uuid_Tbl_Entry", !7, i64 0, !11, i64 16}
!11 = !{!"bool", !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!15, !17, i64 1}
!15 = !{!"_ZTS11__Bt_Uuid16", !7, i64 0, !16, i64 0, !17, i64 1}
!16 = !{!"_ZTS14__Bt_Uuid_Type", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!7, !7, 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"

%struct.__Bt_Base_Uuid_Tbl_Entry = type { [16 x i8], i8 }

@_ZL15s_BtBaseUuidTbl = external hidden local_unnamed_addr global [4 x %struct.__Bt_Base_Uuid_Tbl_Entry], align 4

; 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) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local zeroext i1 @BtUuid16To128(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = load i8, ptr %0, align 1
  %4 = and i8 %3, 63
  %5 = zext nneg i8 %4 to i64
  %6 = getelementptr inbounds [4 x %struct.__Bt_Base_Uuid_Tbl_Entry], ptr @_ZL15s_BtBaseUuidTbl, i64 0, i64 %5
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load i8, ptr %7, align 1, !tbaa !5, !range !10, !noundef !11
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %10, label %19

10:                                               ; preds = %2
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) %1, ptr noundef nonnull align 1 dereferenceable(16) %6, i64 16, i1 false)
  %11 = getelementptr inbounds i8, ptr %0, i64 1
  %12 = load i16, ptr %11, align 1, !tbaa !12
  %13 = trunc i16 %12 to i8
  %14 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 %13, ptr %14, align 1, !tbaa !16
  %15 = load i16, ptr %11, align 1, !tbaa !12
  %16 = lshr i16 %15, 8
  %17 = trunc nuw i16 %16 to i8
  %18 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 %17, ptr %18, align 1, !tbaa !16
  %.pre = load i8, ptr %7, align 1, !tbaa !5, !range !10
  %.pre9 = trunc nuw i8 %.pre to i1
  br label %19

19:                                               ; preds = %10, %2
  %.pre-phi = phi i1 [ %.pre9, %10 ], [ false, %2 ]
  ret i1 %.pre-phi
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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, !9, i64 16}
!6 = !{!"_ZTS24__Bt_Base_Uuid_Tbl_Entry", !7, i64 0, !9, i64 16}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"bool", !7, i64 0}
!10 = !{i8 0, i8 2}
!11 = !{}
!12 = !{!13, !15, i64 1}
!13 = !{!"_ZTS11__Bt_Uuid16", !7, i64 0, !14, i64 0, !15, i64 1}
!14 = !{!"_ZTS14__Bt_Uuid_Type", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!7, !7, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass