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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local zeroext i1 @BtUuidGetBase(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %11, label %8

8:                                                ; preds = %2
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp sge i32 %9, 4
  br i1 %10, label %11, label %12

11:                                               ; preds = %8, %2
  store i1 false, ptr %3, align 1
  br label %27

12:                                               ; preds = %8
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [4 x %struct.__Bt_Base_Uuid_Tbl_Entry], ptr @_ZL15s_BtBaseUuidTbl, i64 0, i64 %14
  %16 = getelementptr inbounds %struct.__Bt_Base_Uuid_Tbl_Entry, ptr %15, i32 0, i32 1
  %17 = load i8, ptr %16, align 1, !tbaa !11, !range !14, !noundef !15
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %26

19:                                               ; preds = %12
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [4 x %struct.__Bt_Base_Uuid_Tbl_Entry], ptr @_ZL15s_BtBaseUuidTbl, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.__Bt_Base_Uuid_Tbl_Entry, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %20, ptr align 1 %25, i64 16, i1 false)
  store i1 true, ptr %3, align 1
  br label %27

26:                                               ; preds = %12
  store i1 false, ptr %3, align 1
  br label %27

27:                                               ; preds = %26, %19, %11
  %28 = load i1, ptr %3, align 1
  ret i1 %28
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }

!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 = !{!"int", !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, !13, i64 16}
!12 = !{!"_ZTS24__Bt_Base_Uuid_Tbl_Entry", !7, i64 0, !13, i64 16}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}


; 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 noundef zeroext i1 @BtUuidGetBase(i32 noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %or.cond = icmp ugt i32 %0, 3
  br i1 %or.cond, label %10, label %3

3:                                                ; preds = %2
  %4 = zext nneg i32 %0 to i64
  %5 = getelementptr inbounds [4 x %struct.__Bt_Base_Uuid_Tbl_Entry], ptr @_ZL15s_BtBaseUuidTbl, i64 0, i64 %4
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load i8, ptr %6, align 1, !tbaa !5, !range !10, !noundef !11
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %10

9:                                                ; preds = %3
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) %1, ptr noundef nonnull align 1 dereferenceable(16) %5, i64 16, i1 false)
  br label %10

10:                                               ; preds = %3, %2, %9
  %.0 = phi i1 [ true, %9 ], [ false, %2 ], [ false, %3 ]
  ret i1 %.0
}

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


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