; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (HiiCompareLanguage)

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

@.str = external hidden unnamed_addr constant [148 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #1

declare ptr @AllocateZeroPool(i64 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i64 @AsciiStrSize(ptr noundef) #1

declare void @FreePool(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @HiiCompareLanguage(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call i64 @AsciiStrSize(ptr noundef %11)
  store i64 %12, ptr %7, align 8, !tbaa !9
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = call ptr @AllocateZeroPool(i64 noundef %13)
  store ptr %14, ptr %8, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %2
  %16 = call zeroext i8 @DebugAssertEnabled()
  %17 = icmp ne i8 %16, 0
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @DebugAssert(ptr noundef @.str, i64 noundef 2020, ptr noundef @.str.17)
  br label %22

22:                                               ; preds = %21, %18
  br label %23

23:                                               ; preds = %22, %15
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call ptr @AsciiStrCpy(ptr noundef %26, ptr noundef %27)
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  call void @AsciiHiiToLower(ptr noundef %29)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call i64 @AsciiStrSize(ptr noundef %30)
  store i64 %31, ptr %7, align 8, !tbaa !9
  %32 = load i64, ptr %7, align 8, !tbaa !9
  %33 = call ptr @AllocateZeroPool(i64 noundef %32)
  store ptr %33, ptr %9, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %25
  %35 = call zeroext i8 @DebugAssertEnabled()
  %36 = icmp ne i8 %35, 0
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  call void @DebugAssert(ptr noundef @.str, i64 noundef 2026, ptr noundef @.str.18)
  br label %41

41:                                               ; preds = %40, %37
  br label %42

42:                                               ; preds = %41, %34
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call ptr @AsciiStrCpy(ptr noundef %45, ptr noundef %46)
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  call void @AsciiHiiToLower(ptr noundef %48)
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %81, %44
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %6, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %63

56:                                               ; preds = %49
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = load i64, ptr %6, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %57, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = sext i8 %60 to i32
  %62 = icmp ne i32 %61, 59
  br label %63

63:                                               ; preds = %56, %49
  %64 = phi i1 [ false, %49 ], [ %62, %56 ]
  br i1 %64, label %65, label %84

65:                                               ; preds = %63
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load i64, ptr %6, align 8, !tbaa !9
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !11
  %70 = sext i8 %69 to i32
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load i64, ptr %6, align 8, !tbaa !9
  %73 = getelementptr inbounds i8, ptr %71, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !11
  %75 = sext i8 %74 to i32
  %76 = icmp ne i32 %70, %75
  br i1 %76, label %77, label %80

77:                                               ; preds = %65
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %78)
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  call void @FreePool(ptr noundef %79)
  store i8 0, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %95

80:                                               ; preds = %65
  br label %81

81:                                               ; preds = %80
  %82 = load i64, ptr %6, align 8, !tbaa !9
  %83 = add i64 %82, 1
  store i64 %83, ptr %6, align 8, !tbaa !9
  br label %49, !llvm.loop !12

84:                                               ; preds = %63
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %85)
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  call void @FreePool(ptr noundef %86)
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = load i64, ptr %6, align 8, !tbaa !9
  %89 = getelementptr inbounds i8, ptr %87, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !11
  %91 = sext i8 %90 to i32
  %92 = icmp eq i32 %91, 0
  %93 = zext i1 %92 to i32
  %94 = trunc i32 %93 to i8
  store i8 %94, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %95

95:                                               ; preds = %84, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %96 = load i8, ptr %3, align 1
  ret i8 %96
}

declare ptr @AsciiStrCpy(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @AsciiHiiToLower(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [148 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #0

declare i64 @AsciiStrSize(ptr noundef) local_unnamed_addr #0

declare void @FreePool(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @HiiCompareLanguage(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call i64 @AsciiStrSize(ptr noundef %0) #2
  %4 = tail call ptr @AllocateZeroPool(i64 noundef %3) #2
  %5 = tail call zeroext i8 @DebugAssertEnabled() #2
  %6 = icmp eq i8 %5, 0
  %7 = icmp ne ptr %4, null
  %or.cond = select i1 %6, i1 true, i1 %7
  br i1 %or.cond, label %9, label %8

8:                                                ; preds = %2
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 2020, ptr noundef nonnull @.str.17) #2
  br label %9

9:                                                ; preds = %8, %2
  %10 = tail call ptr @AsciiStrCpy(ptr noundef %4, ptr noundef %0) #2
  tail call void @AsciiHiiToLower(ptr noundef %4)
  %11 = tail call i64 @AsciiStrSize(ptr noundef %1) #2
  %12 = tail call ptr @AllocateZeroPool(i64 noundef %11) #2
  %13 = tail call zeroext i8 @DebugAssertEnabled() #2
  %14 = icmp eq i8 %13, 0
  %15 = icmp ne ptr %12, null
  %or.cond3 = select i1 %14, i1 true, i1 %15
  br i1 %or.cond3, label %17, label %16

16:                                               ; preds = %9
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 2026, ptr noundef nonnull @.str.18) #2
  br label %17

17:                                               ; preds = %16, %9
  %18 = tail call ptr @AsciiStrCpy(ptr noundef %12, ptr noundef %1) #2
  tail call void @AsciiHiiToLower(ptr noundef %12)
  br label %19

19:                                               ; preds = %26, %17
  %.030 = phi i64 [ 0, %17 ], [ %27, %26 ]
  %20 = getelementptr inbounds i8, ptr %4, i64 %.030
  %21 = load i8, ptr %20, align 1, !tbaa !5
  switch i8 %21, label %22 [
    i8 0, label %.critedge
    i8 59, label %.critedge
  ]

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %12, i64 %.030
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %.not33 = icmp eq i8 %21, %24
  br i1 %.not33, label %26, label %25

25:                                               ; preds = %22
  tail call void @FreePool(ptr noundef nonnull %4) #2
  tail call void @FreePool(ptr noundef nonnull %12) #2
  br label %32

26:                                               ; preds = %22
  %27 = add i64 %.030, 1
  br label %19, !llvm.loop !8

.critedge:                                        ; preds = %19, %19
  tail call void @FreePool(ptr noundef nonnull %4) #2
  tail call void @FreePool(ptr noundef %12) #2
  %28 = getelementptr inbounds i8, ptr %1, i64 %.030
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %30 = icmp eq i8 %29, 0
  %31 = zext i1 %30 to i8
  br label %32

32:                                               ; preds = %.critedge, %25
  %.0 = phi i8 [ 0, %25 ], [ %31, %.critedge ]
  ret i8 %.0
}

declare ptr @AsciiStrCpy(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @AsciiHiiToLower(ptr noundef) local_unnamed_addr #1

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass