; 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_Uuid32 = type <{ i8, i32 }>

@_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 @BtUuid32To128(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 %59

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_Uuid32, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 1, !tbaa !14
  %25 = and i32 %24, 255
  %26 = trunc i32 %25 to i8
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 12
  store i8 %26, ptr %28, align 1, !tbaa !18
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.__Bt_Uuid32, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 1, !tbaa !14
  %32 = lshr i32 %31, 8
  %33 = trunc i32 %32 to i8
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 13
  store i8 %33, ptr %35, align 1, !tbaa !18
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load i8, ptr %36, align 1
  %38 = lshr i8 %37, 6
  %39 = zext i8 %38 to i32
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %58

41:                                               ; preds = %17
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.__Bt_Uuid32, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 1, !tbaa !14
  %45 = lshr i32 %44, 16
  %46 = and i32 %45, 255
  %47 = trunc i32 %46 to i8
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 14
  store i8 %47, ptr %49, align 1, !tbaa !18
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.__Bt_Uuid32, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 1, !tbaa !14
  %53 = lshr i32 %52, 24
  %54 = and i32 %53, 255
  %55 = trunc i32 %54 to i8
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 15
  store i8 %55, ptr %57, align 1, !tbaa !18
  br label %58

58:                                               ; preds = %41, %17
  br label %59

59:                                               ; preds = %58, %2
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.__Bt_Base_Uuid_Tbl_Entry, ptr %60, i32 0, i32 1
  %62 = load i8, ptr %61, align 1, !tbaa !9, !range !12, !noundef !13
  %63 = trunc i8 %62 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i1 %63
}

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_Uuid32", !7, i64 0, !16, i64 0, !17, i64 1}
!16 = !{!"_ZTS14__Bt_Uuid_Type", !7, i64 0}
!17 = !{!"int", !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 @BtUuid32To128(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 %30

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 i32, ptr %11, align 1, !tbaa !12
  %13 = trunc i32 %12 to i8
  %14 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 %13, ptr %14, align 1, !tbaa !16
  %15 = load i32, ptr %11, align 1, !tbaa !12
  %16 = lshr i32 %15, 8
  %17 = trunc i32 %16 to i8
  %18 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 %17, ptr %18, align 1, !tbaa !16
  %19 = load i8, ptr %0, align 1
  %.mask = and i8 %19, -64
  %20 = icmp eq i8 %.mask, 64
  br i1 %20, label %21, label %30

21:                                               ; preds = %10
  %22 = load i32, ptr %11, align 1, !tbaa !12
  %23 = lshr i32 %22, 16
  %24 = trunc i32 %23 to i8
  %25 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 %24, ptr %25, align 1, !tbaa !16
  %26 = load i32, ptr %11, align 1, !tbaa !12
  %27 = lshr i32 %26, 24
  %28 = trunc nuw i32 %27 to i8
  %29 = getelementptr inbounds i8, ptr %1, i64 15
  store i8 %28, ptr %29, align 1, !tbaa !16
  br label %30

30:                                               ; preds = %10, %21, %2
  %31 = load i8, ptr %7, align 1, !tbaa !5, !range !10, !noundef !11
  %32 = trunc nuw i8 %31 to i1
  ret i1 %32
}

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_Uuid32", !7, i64 0, !14, i64 0, !15, i64 1}
!14 = !{!"_ZTS14__Bt_Uuid_Type", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass