; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdePkg/Library (EisaIdFromText)

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

declare i64 @StrHexToUintn(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @EisaIdFromText(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i16, ptr %3, i64 0
  %5 = load i16, ptr %4, align 2, !tbaa !9
  %6 = zext i16 %5 to i32
  %7 = sub nsw i32 %6, 65
  %8 = add nsw i32 %7, 1
  %9 = and i32 %8, 31
  %10 = shl i32 %9, 10
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds i16, ptr %11, i64 1
  %13 = load i16, ptr %12, align 2, !tbaa !9
  %14 = zext i16 %13 to i32
  %15 = sub nsw i32 %14, 65
  %16 = add nsw i32 %15, 1
  %17 = and i32 %16, 31
  %18 = shl i32 %17, 5
  %19 = add nsw i32 %10, %18
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds i16, ptr %20, i64 2
  %22 = load i16, ptr %21, align 2, !tbaa !9
  %23 = zext i16 %22 to i32
  %24 = sub nsw i32 %23, 65
  %25 = add nsw i32 %24, 1
  %26 = and i32 %25, 31
  %27 = shl i32 %26, 0
  %28 = add nsw i32 %19, %27
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds i16, ptr %29, i64 3
  %31 = call i64 @StrHexToUintn(ptr noundef %30)
  %32 = shl i64 %31, 16
  %33 = trunc i64 %32 to i32
  %34 = add i32 %28, %33
  ret i32 %34
}

attributes #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 #1 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !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"

declare i64 @StrHexToUintn(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @EisaIdFromText(ptr noundef %0) local_unnamed_addr #1 {
  %2 = load <2 x i16>, ptr %0, align 2, !tbaa !5
  %3 = shl <2 x i16> %2, <i16 10, i16 5>
  %4 = and <2 x i16> %3, <i16 31744, i16 992>
  %shift = shufflevector <2 x i16> %4, <2 x i16> poison, <2 x i32> <i32 1, i32 poison>
  %5 = or disjoint <2 x i16> %shift, %4
  %6 = extractelement <2 x i16> %5, i64 0
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = load i16, ptr %7, align 2, !tbaa !5
  %9 = and i16 %8, 31
  %10 = or disjoint i16 %6, %9
  %11 = zext nneg i16 %10 to i32
  %12 = getelementptr inbounds i8, ptr %0, i64 6
  %13 = tail call i64 @StrHexToUintn(ptr noundef nonnull %12) #2
  %.tr = trunc i64 %13 to i32
  %14 = shl i32 %.tr, 16
  %15 = or disjoint i32 %14, %11
  ret i32 %15
}

attributes #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 #1 = { 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 #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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass