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

; 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.2 = external hidden unnamed_addr constant [6 x i32], align 4
@.str.23 = external hidden unnamed_addr constant [6 x i32], align 4
@.str.26 = external hidden unnamed_addr constant [7 x i32], align 4

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

declare i64 @StrnCmp(ptr noundef, ptr noundef, i64 noundef) #1

declare i64 @StrLen(ptr noundef) #1

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

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

declare ptr @AllocateZeroPool(i64 noundef) #1

declare void @FreePool(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @GenerateSubStr(ptr noundef, i64 noundef, ptr noundef, i8 noundef zeroext, ptr noundef) #2

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

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

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

16:                                               ; preds = %3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = call ptr @StrStr(ptr noundef %20, ptr noundef @.str.26)
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  store i8 0, ptr %4, align 1
  store i32 1, ptr %13, align 4
  br label %83

24:                                               ; preds = %19, %16, %3
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  call void @GenerateSubStr(ptr noundef @.str.2, i64 noundef 16, ptr noundef %25, i8 noundef zeroext 1, ptr noundef %8)
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %33

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i64 @StrLen(ptr noundef %29)
  %31 = mul i64 %30, 2
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  call void @GenerateSubStr(ptr noundef @.str.23, i64 noundef %31, ptr noundef %32, i8 noundef zeroext 2, ptr noundef %9)
  br label %34

33:                                               ; preds = %24
  call void @GenerateSubStr(ptr noundef @.str.23, i64 noundef 0, ptr noundef null, i8 noundef zeroext 2, ptr noundef %9)
  br label %34

34:                                               ; preds = %33, %28
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = call i64 @StrLen(ptr noundef %35)
  store i64 %36, ptr %11, align 8, !tbaa !10
  %37 = load i64, ptr %11, align 8, !tbaa !10
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = call i64 @StrLen(ptr noundef %38)
  %40 = add i64 %37, %39
  %41 = add i64 %40, 1
  store i64 %41, ptr %11, align 8, !tbaa !10
  %42 = load i64, ptr %11, align 8, !tbaa !10
  %43 = mul i64 %42, 2
  %44 = call ptr @AllocateZeroPool(i64 noundef %43)
  store ptr %44, ptr %10, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %48

47:                                               ; preds = %34
  br label %66

48:                                               ; preds = %34
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = call ptr @StrCpy(ptr noundef %49, ptr noundef %50)
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = call ptr @StrCat(ptr noundef %52, ptr noundef %53)
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = icmp eq ptr %55, null
  br i1 %56, label %64, label %57

57:                                               ; preds = %48
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = call i64 @StrLen(ptr noundef %60)
  %62 = call i64 @StrnCmp(ptr noundef %58, ptr noundef %59, i64 noundef %61)
  %63 = icmp eq i64 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %57, %48
  store i8 1, ptr %12, align 1, !tbaa !9
  br label %65

65:                                               ; preds = %64, %57
  br label %66

66:                                               ; preds = %65, %47
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %71

69:                                               ; preds = %66
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %70)
  br label %71

71:                                               ; preds = %69, %66
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %76

74:                                               ; preds = %71
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  call void @FreePool(ptr noundef %75)
  br label %76

76:                                               ; preds = %74, %71
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %81

79:                                               ; preds = %76
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  call void @FreePool(ptr noundef %80)
  br label %81

81:                                               ; preds = %79, %76
  %82 = load i8, ptr %12, align 1, !tbaa !9
  store i8 %82, ptr %4, align 1
  store i32 1, ptr %13, align 4
  br label %83

83:                                               ; preds = %81, %23
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %84 = load i8, ptr %4, align 1
  ret i8 %84
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long long", !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"

@.str.2 = external hidden unnamed_addr constant [6 x i32], align 4
@.str.23 = external hidden unnamed_addr constant [6 x i32], align 4
@.str.26 = external hidden unnamed_addr constant [7 x i32], align 4

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

declare i64 @StrnCmp(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare i64 @StrLen(ptr noundef) local_unnamed_addr #1

declare ptr @StrStr(ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #1

declare void @FreePool(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @GenerateSubStr(ptr noundef, i64 noundef, ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #2

declare ptr @StrCpy(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @StrCat(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @IsThisVarstore(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  %6 = icmp eq ptr %1, null
  %7 = icmp ne ptr %2, null
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %8, label %11

8:                                                ; preds = %3
  %9 = tail call ptr @StrStr(ptr noundef nonnull %2, ptr noundef nonnull @.str.26) #3
  %10 = icmp eq ptr %9, null
  br i1 %10, label %45, label %.thread

.thread:                                          ; preds = %8
  call void @GenerateSubStr(ptr noundef nonnull @.str.2, i64 noundef 16, ptr noundef %0, i8 noundef zeroext 1, ptr noundef nonnull %4)
  br label %15

11:                                               ; preds = %3
  call void @GenerateSubStr(ptr noundef nonnull @.str.2, i64 noundef 16, ptr noundef %0, i8 noundef zeroext 1, ptr noundef nonnull %4)
  br i1 %6, label %15, label %12

12:                                               ; preds = %11
  %13 = call i64 @StrLen(ptr noundef nonnull %1) #3
  %14 = shl i64 %13, 1
  call void @GenerateSubStr(ptr noundef nonnull @.str.23, i64 noundef %14, ptr noundef nonnull %1, i8 noundef zeroext 2, ptr noundef nonnull %5)
  br label %16

15:                                               ; preds = %.thread, %11
  call void @GenerateSubStr(ptr noundef nonnull @.str.23, i64 noundef 0, ptr noundef null, i8 noundef zeroext 2, ptr noundef nonnull %5)
  br label %16

16:                                               ; preds = %15, %12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i64 @StrLen(ptr noundef %17) #3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call i64 @StrLen(ptr noundef %19) #3
  %21 = add i64 %20, %18
  %22 = shl i64 %21, 1
  %23 = add i64 %22, 2
  %24 = call ptr @AllocateZeroPool(i64 noundef %23) #3
  %25 = icmp eq ptr %24, null
  br i1 %25, label %37, label %26

26:                                               ; preds = %16
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call ptr @StrCpy(ptr noundef nonnull %24, ptr noundef %27) #3
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call ptr @StrCat(ptr noundef nonnull %24, ptr noundef %29) #3
  %31 = icmp eq ptr %2, null
  br i1 %31, label %36, label %32

32:                                               ; preds = %26
  %33 = call i64 @StrLen(ptr noundef nonnull %24) #3
  %34 = call i64 @StrnCmp(ptr noundef nonnull %2, ptr noundef nonnull %24, i64 noundef %33) #3
  %35 = icmp eq i64 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %32, %26
  br label %37

37:                                               ; preds = %32, %36, %16
  %.0 = phi i8 [ 0, %16 ], [ 1, %36 ], [ 0, %32 ]
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %.not27 = icmp eq ptr %38, null
  br i1 %.not27, label %40, label %39

39:                                               ; preds = %37
  call void @FreePool(ptr noundef nonnull %38) #3
  br label %40

40:                                               ; preds = %39, %37
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %.not28 = icmp eq ptr %41, null
  br i1 %.not28, label %43, label %42

42:                                               ; preds = %40
  call void @FreePool(ptr noundef nonnull %41) #3
  br label %43

43:                                               ; preds = %42, %40
  br i1 %25, label %45, label %44

44:                                               ; preds = %43
  call void @FreePool(ptr noundef nonnull %24) #3
  br label %45

45:                                               ; preds = %43, %44, %8
  %.020 = phi i8 [ 0, %8 ], [ %.0, %44 ], [ %.0, %43 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i8 %.020
}

attributes #0 = { mustprogress 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"}


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