; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/CryptoPkg/Application (CryptestMain)

; 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 [46 x i32], align 4
@.str.1 = external hidden unnamed_addr constant [47 x i32], align 4

; Function Attrs: nounwind uwtable
define dso_local i64 @CryptestMain(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = 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
  %8 = call i64 (ptr, ...) @Print(ptr noundef @.str)
  %9 = call i64 (ptr, ...) @Print(ptr noundef @.str.1)
  %10 = call zeroext i8 @RandomSeed(ptr noundef null, i64 noundef 0)
  %11 = call i64 @ValidateCryptDigest()
  store i64 %11, ptr %6, align 8, !tbaa !9
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %15, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

16:                                               ; preds = %2
  %17 = call i64 @ValidateCryptHmac()
  store i64 %17, ptr %6, align 8, !tbaa !9
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %16
  %21 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %21, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

22:                                               ; preds = %16
  %23 = call i64 @ValidateCryptBlockCipher()
  store i64 %23, ptr %6, align 8, !tbaa !9
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = icmp slt i64 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %22
  %27 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %27, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

28:                                               ; preds = %22
  %29 = call i64 @ValidateCryptRsa()
  store i64 %29, ptr %6, align 8, !tbaa !9
  %30 = load i64, ptr %6, align 8, !tbaa !9
  %31 = icmp slt i64 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %28
  %33 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %33, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

34:                                               ; preds = %28
  %35 = call i64 @ValidateCryptRsa2()
  store i64 %35, ptr %6, align 8, !tbaa !9
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = icmp slt i64 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  %39 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %39, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

40:                                               ; preds = %34
  %41 = call i64 @ValidateCryptPkcs7()
  store i64 %41, ptr %6, align 8, !tbaa !9
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = icmp slt i64 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %40
  %45 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %45, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

46:                                               ; preds = %40
  %47 = call i64 @ValidateAuthenticode()
  store i64 %47, ptr %6, align 8, !tbaa !9
  %48 = load i64, ptr %6, align 8, !tbaa !9
  %49 = icmp slt i64 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %46
  %51 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %51, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

52:                                               ; preds = %46
  %53 = call i64 @ValidateTSCounterSignature()
  store i64 %53, ptr %6, align 8, !tbaa !9
  %54 = load i64, ptr %6, align 8, !tbaa !9
  %55 = icmp slt i64 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %57, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

58:                                               ; preds = %52
  %59 = call i64 @ValidateCryptDh()
  store i64 %59, ptr %6, align 8, !tbaa !9
  %60 = load i64, ptr %6, align 8, !tbaa !9
  %61 = icmp slt i64 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %58
  %63 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %63, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

64:                                               ; preds = %58
  %65 = call i64 @ValidateCryptPrng()
  store i64 %65, ptr %6, align 8, !tbaa !9
  %66 = load i64, ptr %6, align 8, !tbaa !9
  %67 = icmp slt i64 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %64
  %69 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %69, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

70:                                               ; preds = %64
  store i64 0, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %71

71:                                               ; preds = %70, %68, %62, %56, %50, %44, %38, %32, %26, %20, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %72 = load i64, ptr %3, align 8
  ret i64 %72
}

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

declare i64 @Print(ptr noundef, ...) #2

declare zeroext i8 @RandomSeed(ptr noundef, i64 noundef) #2

declare i64 @ValidateCryptDigest() #2

declare i64 @ValidateCryptHmac() #2

declare i64 @ValidateCryptBlockCipher() #2

declare i64 @ValidateCryptRsa() #2

declare i64 @ValidateCryptRsa2() #2

declare i64 @ValidateCryptPkcs7() #2

declare i64 @ValidateAuthenticode() #2

declare i64 @ValidateTSCounterSignature() #2

declare i64 @ValidateCryptDh() #2

declare i64 @ValidateCryptPrng() #2

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

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


; 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 [46 x i32], align 4
@.str.1 = external hidden unnamed_addr constant [47 x i32], align 4

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @CryptestMain(ptr nocapture noundef readnone %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call i64 (ptr, ...) @Print(ptr noundef nonnull @.str) #3
  %4 = tail call i64 (ptr, ...) @Print(ptr noundef nonnull @.str.1) #3
  %5 = tail call zeroext i8 @RandomSeed(ptr noundef null, i64 noundef 0) #3
  %6 = tail call i64 @ValidateCryptDigest() #3
  %7 = icmp slt i64 %6, 0
  br i1 %7, label %34, label %8

8:                                                ; preds = %2
  %9 = tail call i64 @ValidateCryptHmac() #3
  %10 = icmp slt i64 %9, 0
  br i1 %10, label %34, label %11

11:                                               ; preds = %8
  %12 = tail call i64 @ValidateCryptBlockCipher() #3
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %34, label %14

14:                                               ; preds = %11
  %15 = tail call i64 @ValidateCryptRsa() #3
  %16 = icmp slt i64 %15, 0
  br i1 %16, label %34, label %17

17:                                               ; preds = %14
  %18 = tail call i64 @ValidateCryptRsa2() #3
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %34, label %20

20:                                               ; preds = %17
  %21 = tail call i64 @ValidateCryptPkcs7() #3
  %22 = icmp slt i64 %21, 0
  br i1 %22, label %34, label %23

23:                                               ; preds = %20
  %24 = tail call i64 @ValidateAuthenticode() #3
  %25 = icmp slt i64 %24, 0
  br i1 %25, label %34, label %26

26:                                               ; preds = %23
  %27 = tail call i64 @ValidateTSCounterSignature() #3
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %34, label %29

29:                                               ; preds = %26
  %30 = tail call i64 @ValidateCryptDh() #3
  %31 = icmp slt i64 %30, 0
  br i1 %31, label %34, label %32

32:                                               ; preds = %29
  %33 = tail call i64 @ValidateCryptPrng() #3
  %. = tail call i64 @llvm.smin.i64(i64 %33, i64 0)
  br label %34

34:                                               ; preds = %32, %29, %26, %23, %20, %17, %14, %11, %8, %2
  %.0 = phi i64 [ %6, %2 ], [ %9, %8 ], [ %12, %11 ], [ %15, %14 ], [ %18, %17 ], [ %21, %20 ], [ %24, %23 ], [ %27, %26 ], [ %30, %29 ], [ %., %32 ]
  ret i64 %.0
}

declare i64 @Print(ptr noundef, ...) local_unnamed_addr #1

declare zeroext i8 @RandomSeed(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i64 @ValidateCryptDigest() local_unnamed_addr #1

declare i64 @ValidateCryptHmac() local_unnamed_addr #1

declare i64 @ValidateCryptBlockCipher() local_unnamed_addr #1

declare i64 @ValidateCryptRsa() local_unnamed_addr #1

declare i64 @ValidateCryptRsa2() local_unnamed_addr #1

declare i64 @ValidateCryptPkcs7() local_unnamed_addr #1

declare i64 @ValidateAuthenticode() local_unnamed_addr #1

declare i64 @ValidateTSCounterSignature() local_unnamed_addr #1

declare i64 @ValidateCryptDh() local_unnamed_addr #1

declare i64 @ValidateCryptPrng() local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #2

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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)"}


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