; LLVM IR from cryspen/libcrux :: sys/hacl/c/src/msvc (Hacl_RSAPSS)

; 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 [70 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 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 i32 @printf(ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_RSAPSS_rsapss_pkey_verify(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7, i32 noundef %8, ptr noundef %9) #4 {
  %11 = alloca i1, align 1
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i8, align 1
  %24 = alloca i32, align 4
  store i8 %0, ptr %12, align 1, !tbaa !5
  store i32 %1, ptr %13, align 4, !tbaa !8
  store i32 %2, ptr %14, align 4, !tbaa !8
  store ptr %3, ptr %15, align 8, !tbaa !10
  store ptr %4, ptr %16, align 8, !tbaa !10
  store i32 %5, ptr %17, align 4, !tbaa !8
  store i32 %6, ptr %18, align 4, !tbaa !8
  store ptr %7, ptr %19, align 8, !tbaa !10
  store i32 %8, ptr %20, align 4, !tbaa !8
  store ptr %9, ptr %21, align 8, !tbaa !10
  br label %25

25:                                               ; preds = %10
  %26 = load i32, ptr %13, align 4, !tbaa !8
  %27 = sub i32 %26, 1
  %28 = udiv i32 %27, 64
  %29 = add i32 %28, 1
  %30 = mul i32 2, %29
  %31 = load i32, ptr %14, align 4, !tbaa !8
  %32 = sub i32 %31, 1
  %33 = udiv i32 %32, 64
  %34 = add i32 %30, %33
  %35 = add i32 %34, 1
  %36 = zext i32 %35 to i64
  %37 = icmp ugt i64 %36, 2305843009213693951
  br i1 %37, label %38, label %40

38:                                               ; preds = %25
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 868)
  call void @exit(i32 noundef 253) #6
  unreachable

40:                                               ; preds = %25
  br label %41

41:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %42 = load i32, ptr %13, align 4, !tbaa !8
  %43 = sub i32 %42, 1
  %44 = udiv i32 %43, 64
  %45 = add i32 %44, 1
  %46 = mul i32 2, %45
  %47 = load i32, ptr %14, align 4, !tbaa !8
  %48 = sub i32 %47, 1
  %49 = udiv i32 %48, 64
  %50 = add i32 %46, %49
  %51 = add i32 %50, 1
  %52 = zext i32 %51 to i64
  %53 = mul i64 %52, 8
  %54 = alloca i8, i64 %53, align 16
  store ptr %54, ptr %22, align 8, !tbaa !10
  %55 = load ptr, ptr %22, align 8, !tbaa !10
  %56 = load i32, ptr %13, align 4, !tbaa !8
  %57 = sub i32 %56, 1
  %58 = udiv i32 %57, 64
  %59 = add i32 %58, 1
  %60 = mul i32 2, %59
  %61 = load i32, ptr %14, align 4, !tbaa !8
  %62 = sub i32 %61, 1
  %63 = udiv i32 %62, 64
  %64 = add i32 %60, %63
  %65 = add i32 %64, 1
  %66 = zext i32 %65 to i64
  %67 = mul i64 %66, 8
  call void @llvm.memset.p0.i64(ptr align 8 %55, i8 0, i64 %67, i1 false)
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #7
  %68 = load i32, ptr %13, align 4, !tbaa !8
  %69 = load i32, ptr %14, align 4, !tbaa !8
  %70 = load ptr, ptr %15, align 8, !tbaa !10
  %71 = load ptr, ptr %16, align 8, !tbaa !10
  %72 = load ptr, ptr %22, align 8, !tbaa !10
  %73 = call zeroext i1 @load_pkey(i32 noundef %68, i32 noundef %69, ptr noundef %70, ptr noundef %71, ptr noundef %72)
  %74 = zext i1 %73 to i8
  store i8 %74, ptr %23, align 1, !tbaa !12
  %75 = load i8, ptr %23, align 1, !tbaa !12, !range !14, !noundef !15
  %76 = trunc i8 %75 to i1
  br i1 %76, label %77, label %88

77:                                               ; preds = %41
  %78 = load i8, ptr %12, align 1, !tbaa !5
  %79 = load i32, ptr %13, align 4, !tbaa !8
  %80 = load i32, ptr %14, align 4, !tbaa !8
  %81 = load ptr, ptr %22, align 8, !tbaa !10
  %82 = load i32, ptr %17, align 4, !tbaa !8
  %83 = load i32, ptr %18, align 4, !tbaa !8
  %84 = load ptr, ptr %19, align 8, !tbaa !10
  %85 = load i32, ptr %20, align 4, !tbaa !8
  %86 = load ptr, ptr %21, align 8, !tbaa !10
  %87 = call zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext %78, i32 noundef %79, i32 noundef %80, ptr noundef %81, i32 noundef %82, i32 noundef %83, ptr noundef %84, i32 noundef %85, ptr noundef %86)
  store i1 %87, ptr %11, align 1
  store i32 1, ptr %24, align 4
  br label %89

88:                                               ; preds = %41
  store i1 false, ptr %11, align 1
  store i32 1, ptr %24, align 4
  br label %89

89:                                               ; preds = %88, %77
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  %90 = load i1, ptr %11, align 1
  ret i1 %90
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @load_pkey(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #5

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 = { noreturn nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { inlinehint 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 #6 = { noreturn nounwind }
attributes #7 = { 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 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_Bool", !6, 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"

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_RSAPSS_rsapss_pkey_verify(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7, i32 noundef %8, ptr noundef %9) local_unnamed_addr #1 {
  %11 = add i32 %1, -1
  %12 = lshr i32 %11, 5
  %13 = and i32 %12, 134217726
  %14 = add i32 %2, -1
  %15 = lshr i32 %14, 6
  %16 = add nuw nsw i32 %13, 3
  %17 = add nuw nsw i32 %16, %15
  %18 = shl nuw nsw i32 %17, 3
  %19 = zext nneg i32 %18 to i64
  %20 = alloca i8, i64 %19, align 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %20, i8 0, i64 %19, i1 false)
  %21 = call zeroext i1 @load_pkey(i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef nonnull %20)
  br i1 %21, label %22, label %24

22:                                               ; preds = %10
  %23 = call zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull %20, i32 noundef %5, i32 noundef %6, ptr noundef %7, i32 noundef %8, ptr noundef %9)
  br label %24

24:                                               ; preds = %10, %22
  %.0 = phi i1 [ %23, %22 ], [ false, %10 ]
  ret i1 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @load_pkey(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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


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